Last active
October 13, 2023 16:01
-
-
Save mkflow27/3918db6e7dd7baf5bc9a3731a9472d6e to your computer and use it in GitHub Desktop.
Csp Join
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test_EXACT_TOKENS_IN_FOR_BPT_OUT() public { | |
TokenData[] memory tokenDataArray = new TokenData[](4); | |
tokenDataArray[0] = TokenData({ | |
token: 0x6B175474E89094C44Da98b954EedeAC495271d0F, //dai | |
rateProvider: address(0), | |
tokenRateCacheDuration: 21600, | |
amount: 100e18 | |
}); | |
tokenDataArray[1] = TokenData({ | |
token: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, //usdc | |
rateProvider: address(0), | |
tokenRateCacheDuration: 21600, | |
amount: 100e6 | |
}); | |
tokenDataArray[2] = TokenData({ | |
token: 0xdAC17F958D2ee523a2206206994597C13D831ec7, //usdt | |
rateProvider: address(0), | |
tokenRateCacheDuration: 21600, | |
amount: 100e6 | |
}); | |
tokenDataArray[3] = TokenData({ | |
token: 0x79c58f70905F734641735BC61e45c19dD9Ad60bC, //BPT | |
rateProvider: address(0), | |
tokenRateCacheDuration: 21600, | |
amount: 0 | |
}); | |
( | |
address[] memory sortedTokensIncludingBpt, | |
, | |
, | |
uint256[] memory sortedAmountsIncludingBpt | |
) = sortTokenDataNumerically(tokenDataArray); | |
uint256[] memory amountsExcludingBpt; | |
(, uint256 bptIndex) = _removeAddressFromArray( | |
sortedTokensIncludingBpt, | |
address(0x79c58f70905F734641735BC61e45c19dD9Ad60bC) | |
); | |
amountsExcludingBpt = _removeIndexFromUint256Array( | |
sortedAmountsIncludingBpt, | |
bptIndex | |
); | |
IAsset[] memory assets = _createNewIAssetArray( | |
sortedTokensIncludingBpt | |
); | |
// EXACT_TOKENS_IN_FOR_BPT_OUT | |
bytes memory userData = abi.encode(1, amountsExcludingBpt, 0); | |
IVault.JoinPoolRequest memory requestData = IVault.JoinPoolRequest({ | |
assets: assets, | |
maxAmountsIn: sortedAmountsIncludingBpt, | |
userData: userData, | |
fromInternalBalance: false | |
}); | |
(uint256 bptOut, uint256[] memory amountsIn) = queries.queryJoin( | |
IPool(0x79c58f70905F734641735BC61e45c19dD9Ad60bC).getPoolId(), | |
address(this), | |
address(this), | |
requestData | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment