Deploy a Well
See https://basin.exchange/#/build to instead to deploy a Well using the Basin UI.
Basin is a composable DEX protocol, meaning that it has various modular components that can be composed together to create new liquidity pools. These components are Well Functions, Well implementations and network-native oracles known as Pumps.
The simplest way for someone to deploy a new Well is by calling the boreWell
function on the Aquifer (factory) contract. boreWell
accepts the encoded addresses of each Well component as input, along with additional parameters such as the Well's name and symbol and a salt for deterministic address generation. It then verifies that the calldata is valid and clones a pre-deployed Well template with the new parameters. In addition, a mapping of the new Well address to the existing Well Implementation address is stored in the Aquifer contract.
Well Deployer CLI Tool
To reduce complexity and combine the steps below, you can use the CLI tool found on the Beanstak Farms GitHub repository here with instructions on how to use it. If you have any questions or need help using the CLI tool, feel free to reach out on the official Basin Discord. Otherwise, you can follow the steps detailed below.
Step by step guide to deploy a new Well
1. Obtain the addresses of the components to be used in the new Well.
First, obtain the addresses of the 2 ERC-20 tokens to be traded in the new Well. You can find a number of tokens and their addresses on Etherscan or any other block explorer.
Next, obtain the addresses for the desired Well Function, Well Implementation and Pump. You can find the addresses for audited and deployed Well components here.
Finally, decide on a Well name and symbol. These can be any string of your choice but it is recommended to follow the standard format.
The standard name format is
tokenSymbol1:tokenSymbol2 + Well Function name + "Well"
. For example assuming you are creating a well for the tokens wETH and wBTC with a Constant Product 2 function, the name would bewETH:wBTC Constant Product 2 well
.The standard symbol format is
tokenSymbol1 + tokenSymbol2 + Well Function abbreviation + "w"
. For example assuming you are creating a Well for the tokens wETH and wBTC with the Constant Product 2 Well function, the symbol would bewETHwBTCCP2w
.
2. Encode the calldata
After getting the necessary parameters described above for the new Well, you will need to properly encode them for the Aquifer contract. There are 2 parts of calldata that need to be encoded. The first is the init
function call on the Well Implementation contract, to initialize the new Well with the name and symbol. The second is the immutable data of the well, which includes the addresses of the tokens, the Pump and the Well Function. These 2 parts should be encoded separately by using the abi.encodePacked
function in Solidity or the alternative ethers.solidityPacked
in JavaScript using the ethers
library.
Here is an example of how to encode the data using ethers.js
starting with the init
function call. To obtain the Well Implementation ABI, you can take a look at the verified Well Implementation contracts on Etherscan.
Here is an example of how to encode the immutable data of the Well:
The final calldata from the above examples will look something like this:
3. Choose a salt for deterministic address generation.
The salt
is an additional parameter thats used to calculate the address of the deployed well. This allows it to be deployed on different EVM chains and have the same deterministic address, as long it uses the same salt. It also allows for the creation of vanity addresses by mining for a salt value that gives the wanted address. The salt is optional and can be any 32 byte value. It is recommended to use a random value for the salt to know the exact address of new Well before deploying it.
4. Call the boreWell function on the Aquifer contract with the encoded data as parameters.
You are now ready to call the boreWell
function on the Aquifer contract with the encoded data as the parameter! The call would look something like this in JavaScript:
Congratulations! You have now deployed a new Well on Basin. The new Well will be deployed at the address returned by the boreWell
function. You can now use the new Well to provide liquidity and trade tokens.
Important Notes
All of the above can be achieved only assuming all the required components used in the new Well are already deployed. Thorough verification of the components is required beforehand to ensure the Well is deployed correctly. You can find the addresses for audited and deployed versions of each Well component here.
Last updated