Add build params unit tests helpers

This commit is contained in:
Gerardo Nardelli 2020-11-06 12:12:40 -03:00
parent 1faffa2c39
commit 6aeabbe00b

View File

@ -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 {signTypedData_v4} from 'eth-sig-util';
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util'; import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
@ -212,3 +212,55 @@ export const getSignatureFromTypedData = (
}); });
return fromRpcSig(signature); 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]
);
};