mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Add build params unit tests helpers
This commit is contained in:
parent
1faffa2c39
commit
6aeabbe00b
|
@ -1,4 +1,4 @@
|
|||
import {Contract, Signer, utils, ethers} from 'ethers';
|
||||
import {Contract, Signer, utils, ethers, BigNumberish} from 'ethers';
|
||||
import {signTypedData_v4} from 'eth-sig-util';
|
||||
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
|
||||
import BigNumber from 'bignumber.js';
|
||||
|
@ -212,3 +212,55 @@ export const getSignatureFromTypedData = (
|
|||
});
|
||||
return fromRpcSig(signature);
|
||||
};
|
||||
|
||||
export const buildLiquiditySwapParams = (
|
||||
assetToSwapToList: tEthereumAddress[],
|
||||
minAmountsToReceive: BigNumberish[],
|
||||
swapAllBalances: BigNumberish[],
|
||||
permitAmounts: BigNumberish[],
|
||||
deadlines: BigNumberish[],
|
||||
v: BigNumberish[],
|
||||
r: (string | Buffer)[],
|
||||
s: (string | Buffer)[]
|
||||
) => {
|
||||
return ethers.utils.defaultAbiCoder.encode(
|
||||
[
|
||||
'address[]',
|
||||
'uint256[]',
|
||||
'bool[]',
|
||||
'uint256[]',
|
||||
'uint256[]',
|
||||
'uint8[]',
|
||||
'bytes32[]',
|
||||
'bytes32[]',
|
||||
],
|
||||
[assetToSwapToList, minAmountsToReceive, swapAllBalances, permitAmounts, deadlines, v, r, s]
|
||||
);
|
||||
};
|
||||
|
||||
export const buildRepayAdapterParams = (
|
||||
assetToSwapToList: tEthereumAddress[],
|
||||
leftoverAction: BigNumberish,
|
||||
repayAmounts: BigNumberish[],
|
||||
rateModes: BigNumberish[],
|
||||
permitAmounts: BigNumberish[],
|
||||
deadlines: BigNumberish[],
|
||||
v: BigNumberish[],
|
||||
r: (string | Buffer)[],
|
||||
s: (string | Buffer)[]
|
||||
) => {
|
||||
return ethers.utils.defaultAbiCoder.encode(
|
||||
[
|
||||
'address[]',
|
||||
'uint256',
|
||||
'uint256[]',
|
||||
'uint256[]',
|
||||
'uint256[]',
|
||||
'uint256[]',
|
||||
'uint8[]',
|
||||
'bytes32[]',
|
||||
'bytes32[]',
|
||||
],
|
||||
[assetToSwapToList, leftoverAction, repayAmounts, rateModes, permitAmounts, deadlines, v, r, s]
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user