Changes review
The TridentCLPool, TridentCLFactory, and TridentCLPoolDeployer contracts have been updated.
Updated the
deployfunction of theTridentCLPoolDeployercontract. ThebentoBoxargument was added and passed in theparametersstruct to be used in the liquidity pool.
Updated the constructor of the
TridentCLFactorycontract. Added the_bentoBoxargument. This address is used in thecreatePoolfunction to deploy a new liquidity pool.
The changes listed below relate to the TridentCLPool contract:
The BentoBox usage. The most important change here is the use of BentoBox, which stores tokens on behalf of the pool contract, like a vault, and has additional functionalities of its own.
Added the internal
_transferfunction. This function allows direct BentoBox transfers or withdrawals towards thetoaddress. Previously, it was asafeTransferof the specific token towardsto. It assumes thattoken0andtoken1can be both withdrawn and transferred from BentoBox. It is used incollectProtocol(),collect(),swap(), andflash().
Updated the
balance0()and thebalance1()functions. The changes relate to the fact that BentoBox is now the vault for thetoken0and thetoken1. It is important to note that neitherbalance0norbalance1are updated if a direct ERC20 transfer happens to the pool. Therefore, all token transfers must occur through the BentoBox functions.
Updated the
collect(),swap(),flash(), andcollectProtocol()functions. TheunwrapBentoflag was added. This flag is used in the_transferfunction and must determine whether to transfer or to withdraw (e.g., unwrap and then transfer as native) tokens from the vault.
Added new structure
FlashCache. This structure is used in theflashfunction to pack the data set in memory.
Updated the
SwapCachestructure. Added new flagszeroForOneandunwrapBento. This structure is used in theswapfunction. The flagzeroForOnewas already used there but now is grouped with other data into this structure. TheunwrapBentoflag is necessary for the_transferfunction to determine whether to withdraw tokens from the vault or transfer after the swap.