Changes review
The TridentCLPool
, TridentCLFactory
, and TridentCLPoolDeployer
contracts have been updated.
Updated the
deploy
function of theTridentCLPoolDeployer
contract. ThebentoBox
argument was added and passed in theparameters
struct to be used in the liquidity pool.
Updated the constructor of the
TridentCLFactory
contract. Added the_bentoBox
argument. This address is used in thecreatePool
function 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
_transfer
function. This function allows direct BentoBox transfers or withdrawals towards theto
address. Previously, it was asafeTransfer
of the specific token towardsto
. It assumes thattoken0
andtoken1
can 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 thetoken0
and thetoken1
. It is important to note that neitherbalance0
norbalance1
are 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. TheunwrapBento
flag was added. This flag is used in the_transfer
function 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 theflash
function to pack the data set in memory.
Updated the
SwapCache
structure. Added new flagszeroForOne
andunwrapBento
. This structure is used in theswap
function. The flagzeroForOne
was already used there but now is grouped with other data into this structure. TheunwrapBento
flag is necessary for the_transfer
function to determine whether to withdraw tokens from the vault or transfer after the swap.