mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Add permit amount parameter to correctly execute permit call
This commit is contained in:
parent
20bbae88d3
commit
1faffa2c39
|
@ -27,6 +27,7 @@ contract BaseUniswapAdapter {
|
|||
enum LeftoverAction {DEPOSIT, TRANSFER}
|
||||
|
||||
struct PermitParams {
|
||||
uint256[] amount;
|
||||
uint256[] deadline;
|
||||
uint8[] v;
|
||||
bytes32[] r;
|
||||
|
@ -34,6 +35,7 @@ contract BaseUniswapAdapter {
|
|||
}
|
||||
|
||||
struct PermitSignature {
|
||||
uint256 amount;
|
||||
uint256 deadline;
|
||||
uint8 v;
|
||||
bytes32 r;
|
||||
|
@ -269,7 +271,7 @@ contract BaseUniswapAdapter {
|
|||
IERC20WithPermit(reserveAToken).permit(
|
||||
user,
|
||||
address(this),
|
||||
amount,
|
||||
permitSignature.amount,
|
||||
permitSignature.deadline,
|
||||
permitSignature.v,
|
||||
permitSignature.r,
|
||||
|
|
|
@ -43,6 +43,7 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
* address[] assetToSwapToList List of the addresses of the reserve to be swapped to and deposited
|
||||
* uint256[] minAmountsToReceive List of min amounts to be received from the swap
|
||||
* bool[] swapAllBalance Flag indicating if all the user balance should be swapped
|
||||
* uint256[] permitAmount List of amounts for the permit signature
|
||||
* uint256[] deadline List of deadlines for the permit signature
|
||||
* uint8[] v List of v param for the permit signature
|
||||
* bytes32[] r List of r param for the permit signature
|
||||
|
@ -63,6 +64,7 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
assets.length == decodedParams.assetToSwapToList.length
|
||||
&& assets.length == decodedParams.minAmountsToReceive.length
|
||||
&& assets.length == decodedParams.swapAllBalance.length
|
||||
&& assets.length == decodedParams.permitParams.amount.length
|
||||
&& assets.length == decodedParams.permitParams.deadline.length
|
||||
&& assets.length == decodedParams.permitParams.v.length
|
||||
&& assets.length == decodedParams.permitParams.r.length
|
||||
|
@ -80,6 +82,7 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
decodedParams.minAmountsToReceive[i],
|
||||
decodedParams.swapAllBalance[i],
|
||||
PermitSignature(
|
||||
decodedParams.permitParams.amount[i],
|
||||
decodedParams.permitParams.deadline[i],
|
||||
decodedParams.permitParams.v[i],
|
||||
decodedParams.permitParams.r[i],
|
||||
|
@ -101,10 +104,11 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
* @param amountToSwapList List of amounts to be swapped. If the amount exceeds the balance, the total balance is used for the swap
|
||||
* @param minAmountsToReceive List of min amounts to be received from the swap
|
||||
* @param permitParams List of struct containing the permit signatures
|
||||
* uint256[] deadline List of deadlines for the permit signature
|
||||
* uint8[] v List of v param for the permit signature
|
||||
* bytes32[] r List of r param for the permit signature
|
||||
* bytes32[] s List of s param for the permit signature
|
||||
* uint256 permitAmount Amount for the permit signature
|
||||
* uint256 deadline Deadline for the permit signature
|
||||
* uint8 v param for the permit signature
|
||||
* bytes32 r param for the permit signature
|
||||
* bytes32 s param for the permit signature
|
||||
*/
|
||||
function swapAndDeposit(
|
||||
address[] calldata assetToSwapFromList,
|
||||
|
@ -203,6 +207,7 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
* address[] assetToSwapToList List of the addresses of the reserve to be swapped to and deposited
|
||||
* uint256[] minAmountsToReceive List of min amounts to be received from the swap
|
||||
* bool[] swapAllBalance Flag indicating if all the user balance should be swapped
|
||||
* uint256[] permitAmount List of amounts for the permit signature
|
||||
* uint256[] deadline List of deadlines for the permit signature
|
||||
* uint8[] v List of v param for the permit signature
|
||||
* bytes32[] r List of r param for the permit signature
|
||||
|
@ -214,13 +219,14 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
address[] memory assetToSwapToList,
|
||||
uint256[] memory minAmountsToReceive,
|
||||
bool[] memory swapAllBalance,
|
||||
uint256[] memory permitAmount,
|
||||
uint256[] memory deadline,
|
||||
uint8[] memory v,
|
||||
bytes32[] memory r,
|
||||
bytes32[] memory s
|
||||
) = abi.decode(params, (address[], uint256[], bool[], uint256[], uint8[], bytes32[], bytes32[]));
|
||||
) = abi.decode(params, (address[], uint256[], bool[], uint256[], uint256[], uint8[], bytes32[], bytes32[]));
|
||||
|
||||
return SwapParams(assetToSwapToList, minAmountsToReceive, swapAllBalance, PermitParams(deadline, v, r, s));
|
||||
return SwapParams(assetToSwapToList, minAmountsToReceive, swapAllBalance, PermitParams(permitAmount, deadline, v, r, s));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,6 +47,7 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
* (1) Direct transfer to user
|
||||
* uint256[] repayAmounts List of amounts of debt to be repaid
|
||||
* uint256[] rateModes List of the rate modes of the debt to be repaid
|
||||
* uint256[] permitAmount List of amounts for the permit signature
|
||||
* uint256[] deadline List of deadlines for the permit signature
|
||||
* uint8[] v List of v param for the permit signature
|
||||
* bytes32[] r List of r param for the permit signature
|
||||
|
@ -67,6 +68,7 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
assets.length == decodedParams.assetToSwapToList.length
|
||||
&& assets.length == decodedParams.repayAmounts.length
|
||||
&& assets.length == decodedParams.rateModes.length
|
||||
&& assets.length == decodedParams.permitParams.amount.length
|
||||
&& assets.length == decodedParams.permitParams.deadline.length
|
||||
&& assets.length == decodedParams.permitParams.v.length
|
||||
&& assets.length == decodedParams.permitParams.r.length
|
||||
|
@ -84,6 +86,7 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
decodedParams.leftOverAction,
|
||||
premiums[i],
|
||||
PermitSignature(
|
||||
decodedParams.permitParams.amount[i],
|
||||
decodedParams.permitParams.deadline[i],
|
||||
decodedParams.permitParams.v[i],
|
||||
decodedParams.permitParams.r[i],
|
||||
|
@ -141,6 +144,7 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
* (1) Direct transfer to user
|
||||
* uint256[] repayAmounts List of amounts of debt to be repaid
|
||||
* uint256[] rateModes List of the rate modes of the debt to be repaid
|
||||
* uint256[] permitAmount List of amounts for the permit signature
|
||||
* uint256[] deadline List of deadlines for the permit signature
|
||||
* uint8[] v List of v param for the permit signature
|
||||
* bytes32[] r List of r param for the permit signature
|
||||
|
@ -153,11 +157,12 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
LeftoverAction leftOverAction,
|
||||
uint256[] memory repayAmounts,
|
||||
uint256[] memory rateModes,
|
||||
uint256[] memory permitAmount,
|
||||
uint256[] memory deadline,
|
||||
uint8[] memory v,
|
||||
bytes32[] memory r,
|
||||
bytes32[] memory s
|
||||
) = abi.decode(params, (address[], LeftoverAction, uint256[], uint256[], uint256[], uint8[], bytes32[], bytes32[]));
|
||||
) = abi.decode(params, (address[], LeftoverAction, uint256[], uint256[], uint256[], uint256[], uint8[], bytes32[], bytes32[]));
|
||||
|
||||
return RepayParams(
|
||||
assetToSwapToList,
|
||||
|
@ -165,6 +170,7 @@ contract UniswapRepayAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
repayAmounts,
|
||||
rateModes,
|
||||
PermitParams(
|
||||
permitAmount,
|
||||
deadline,
|
||||
v,
|
||||
r,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user