diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index cbe2b69c..4c67b209 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -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] + ); +};