mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
added slippage on deposit
This commit is contained in:
parent
2bd7492e56
commit
a483299e50
|
@ -20,18 +20,16 @@ abstract contract UniswapV3Resolver is Events, Helpers {
|
||||||
* @notice Deposit Liquidity to a Uniswap V3 pool.
|
* @notice Deposit Liquidity to a Uniswap V3 pool.
|
||||||
* @param pool The address of pool.
|
* @param pool The address of pool.
|
||||||
* @param amt0Max Amount0 Max amount
|
* @param amt0Max Amount0 Max amount
|
||||||
* @param amt0Min Amount0 Min amount
|
|
||||||
* @param amt1Max Amount1 Max amount
|
* @param amt1Max Amount1 Max amount
|
||||||
* @param amt1Min Amount1 Min amount
|
* @param slippage use to calculate minimum deposit. 100% = 1e18
|
||||||
* @param getId ID to retrieve amount.
|
* @param getId ID to retrieve amount.
|
||||||
* @param setId ID stores the amount of pools tokens received.
|
* @param setId ID stores the amount of pools tokens received.
|
||||||
*/
|
*/
|
||||||
function deposit(
|
function deposit(
|
||||||
address pool,
|
address pool,
|
||||||
uint256 amt0Max,
|
uint256 amt0Max,
|
||||||
uint256 amt0Min,
|
|
||||||
uint256 amt1Max,
|
uint256 amt1Max,
|
||||||
uint256 amt1Min,
|
uint slippage,
|
||||||
uint256 getId,
|
uint256 getId,
|
||||||
uint256 setId
|
uint256 setId
|
||||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
@ -40,6 +38,9 @@ abstract contract UniswapV3Resolver is Events, Helpers {
|
||||||
|
|
||||||
(uint256 amount0In, uint256 amount1In, uint256 mintAmount) = poolContract.getMintAmounts(amt0Max, amt1Max);
|
(uint256 amount0In, uint256 amount1In, uint256 mintAmount) = poolContract.getMintAmounts(amt0Max, amt1Max);
|
||||||
|
|
||||||
|
uint amt0Min = wmul(amt0Max, slippage);
|
||||||
|
uint amt1Min = wmul(amt1Max, slippage);
|
||||||
|
|
||||||
require(
|
require(
|
||||||
amount0In >= amt0Min && amount1In >= amt1Min,
|
amount0In >= amt0Min && amount1In >= amt1Min,
|
||||||
"below min amounts"
|
"below min amounts"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user