Step by Step Deployment
Algebra protocol consists of 4 main parts:
💎 Contracts
💾 Subgraphs
⚙️ Backend
🎨 Frontend
To get the gears going you need to setup and connect together all of these 4 parts. Each section relies on the previous one, so, please, follow along this guide to get everything setup.
1. 💎 Contracts
First of all, you need to deploy contracts. Algebra Protocol Contracts divides onto 4 parts:
Core contracts
Farming contracts
Periphery contracts
Plugin
Contracts could be deployed to any EVM-compatible network. To deploy all four parts together, follow these steps:
npm run bootstrap in root directory (Requires npm >= 8.0.0)
add network to hardhat config
create .env file in root directory, add MNEMONIC(private key without 0x) to .env
Update partnerAddress and protocol fee settings in
src/core/scripts/deploy.js
Update wnative address (line 12) and symbol (line 80) for NonfungibleTokenPositionDescriptor in
src/periphery/scripts/deploy.js
npm run deploy --network
network_name
npm run verify --network
network_name
After contracts are deployed, you will get these contracts and their addresses in the console:
AlgebraPoolDeployer
AlgebraFactory
AlgebraCommunityVault
AlgebraVaultFactoryStub
PluginFactory
EntryPoint
TickLens
Quoter
QuoterV2
SwapRouter
NonfungibleTokenPositionDescriptor
Proxy
NonfungiblePositionManager
AlgebraInterfaceMulticall
AlgebraEternalFarming
FarmingCenter
Save these contracts addresses somewhere. You will need them in all next sections.
2. 💾 Subgraphs
Subgraphs are used for blockchain indexing. We use them for:
Tracking DEX data (TVL, Volume, Tokens, Pools, Prices, Ticks, etc.)
Tracking Farming data (Available Farmings, Positions on Farming, Participants Income, etc.)
You can deploy your Subgraph to any of TheGraph or GoldSky supported EVM networks. You can see what chains are supported here:
If your chain is not on a list, you can spin up your one TheGraph node and host it on your server. To do this, you can address TheGraph documentation in graph-node repository:
Usually, you can depend on supported networks without self-hosting.
Algebra Protocol Subgraphs consist of 3 parts:
DEX info (Tokens, Pairs, Ticks, Prices)
Farming (Available Farmings, Participants Positions)
Blocklytics (Tracking blocks)
Refer to the Subgraph repository's README file for deployment instructions.
Save API endpoints for your Subgraphs, you will need them in the next steps.
3. ⚙️ Backend
Algebra Protocol uses backend to keep track of Farming statistics and Pool APRS. We expose these endpoints:
Farmings:
APR
MAX-APR
TVL
Pools:
APR
MAX-APR
Here you will need to use Subgraphs APIs from the previous step. Refer to the backend repository's README file for deployment instructions.
For backend operations, 2 CPUs and 8 GB of memory should suffice. However, you may consider using 4 CPUs to accommodate potential increases in update frequency for performance.
If you can't use your own server for some reason, you can skip this step. But you will not have access to APR and TVL data on client side.
4. 🎨 Frontend
Frontend is divided into 4 parts:
SDK
Smart Router (Optional: Use a dedicated router for custom pools, or opt for a simpler one for base pools).
Client Side Application (Trading, Liquidity Providing, Participation in Farmings, Statistics)
Admin Panel Application (Farmings Creation, Farmings Management)
Here you will need everything from previous steps:
Contract Addresses,
Subgraph APIs,
Backend APIs
4.1. SDK
Update the addresses in
src/constants/addresses.ts
Modify chain name and ID in
src/constants/chainIds.ts
Update Wnative information in
src/entities/wnative.ts
Update the SDK package name and remove any version information (version will be set during publishing) from
package.json
.
4.2. Smart Router
This router supports custom pools. If you do not require custom pools, you can skip this step. To disable the SmartRouter functionality and use a simpler router, set the SmartRouter
flag to false
in the config/app-modules.ts
file in the Client Side Application.
Update addresses in
evm/constants/addresses.ts
Update subgraph endpoints in
evm/chains/src/subgraphs.ts
andevm/v3-router/providers/publicProviders.ts
Configure chain parameters in
evm/chains/src/chainId.ts
,evm/chains/src/chainNames.ts
andevm/v3-router/providers/publicProviders.ts
Update
MULTICALL_ADDRESS
inevm/multicall/src/constants/contracts.ts
Update the SDK link; the router package name and remove any version information (version will be set during publishing) from
package.json
.To enable multihops, define the specific tokens to be used in the
evm/constants/tokens.ts
file.Use the global search feature (Ctrl+Shift+F) to locate all instances of
ChainId.BASE_SEPOLIA
in the project repository and replace them with your custom chain name previously configured in the SDK.
4.3. Client Side Application settings:
Enable all necessary modules in
config/app-modules.ts
.Update deployed contract addresses in
config/contract-addresses.ts
.Configure chain parameters in
config/default-chain.ts
andconfig/wagmi.ts
.Use the global search feature (Ctrl+Shift+F) to locate all instances of
ChainId.BaseSepolia
in the project repository and replace them with your custom chain name previously configured in the SDK.Update subgraph endpoints in
config/graphql-urls.ts
Add stablecoins to
config/tokens.ts
.Update APR endpoints in
config/apr-urls.ts
Update token addresses in
src/components/common/CurrencyLogo/index.tsx
.Update the SDK and router links in both
package.json
4.4. Admin Panel
Update subgraph endpoints in
.env
andcodegen.ts
Update addresses in
src/constants/addresses.ts
Configure chain parameters in
src/constants/default-chain-id.ts
andsrc/wagmi.ts
Update the SDK link in
package.json
Use the global search feature (Ctrl+Shift+F) to locate all instances of
ChainId.BaseSepolia
in the project repository and replace them with your custom chain name previously configured in the SDK.
5. Finish
Now that all the steps have been completed, you have successfully set up the Algebra Protocol!
Now you can explore its features:
Last updated