Skip to main content
There are some scripts in the script/interactions folder that can be used to interact with the deployed factory and pools step by step. These are useful to interact with the deployed contracts and to test the pool and factory transaction by transaction or in small group of transactions. Take into account th Any time the <NETWORK> variable shows up in a script it means that it is possible to have one of the following values which correspond to the supported networks:
  • local
  • amoy
  • sepolia

Environment Variable Configuration

Before using the scripts, ensure that the 2 environment variables are set for the target network:
export {CHAIN}_RPC_URL={YOUR_RPC_URL}
export {CHAIN}_DEPLOYER_KEY={YOUR_PRIV_KEY}

Factory

Recap of Factory Configuration

In order to deploy a pool, the factory must be configured with the following parameters:
  • The deployer address must be in the allowed deployer list.
  • The collateral token of the pool must be in the allowed collateral list.

Scripts

Run these scripts in the terminal at the project’s root directory if needed.

addAllowedDeployerAndCollateralToken.sh

Adds a deployer and collateral token address to the allow lists: usage:
./script/interactions/addDeployerAndCollateralToFactory.sh <NETWORK> <YTOKEN_ADDRESS_TO_BE_ALLOWED> <DEPLOYER_ADDRESS_TO_BE_ALLOWED>

createALTBCPool.sh

A custom pool could also be deployed through the factory with a script:
./script/interactions/createALTBCPool.sh <NETWORK> <FACTORY_ADDRESS> <X_TOKEN_ADDRESS> <X_TOKEN_ADDRESS> <FEE> <MIN_PRICE> <LOWER_PRICE> <UPPER_PRICE> <MAX_X_TOKEN_SUPPLY> <IS_LIQUIDITY_REMOVAL_ALLOWED>

Pool

Recap of a Pool Initialization

Once a pool has been deployed, it needs 3 steps to be initialized by the pool owner:
  • Approve the pool to take all the supply of the x token.
  • Add liquidity for x token.
  • Enable swaps.

Scripts

Run these scripts in the terminal at the project’s root directory if needed.

InitializePool.sh

Approves the pool to take the liquidity, adds liquidity to the pool and then enables swaps:
./script/interactions/initializePool.sh <NETWORK> <POOL_ADDRESS> <X_TOKEN_ADDRESS> <X_TOKEN_SUPPLY>

approvePool.sh

Approves a pool to take a certain amount of a token. This can be used to approve any token and any pool. Use before swaps to approve the pool to take your y or x token.
./script/interactions/common/approvePool.sh <NETWORK> <TOKEN_ADDRESS> <POOL_ADDRESS> <ALLOWANCE_IN_WAD>

swap.sh

Tells the pool how much token to sell in exchange for the other one. The script internally computes the amount expected to be received which will be passed into the swap function as a parementer to calculate slippage.
./script/interactions/sellY.sh <NETWORK> <POOL_ADDRESS> <TOKEN_IN_ADDRESS> <AMOUNT_TO_SELL> <MAX_SLIPPAGE>

Internal Scripts

Most of the aforementioned scripts use other scripts to work. These scripts can be found in the subdirectories of the script/interactions folder. The documentation for these scripts can be found inside the sctipt itself.

Other Docs