Skip to content
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[
{
"inputs": [
{
"components": [
{ "internalType": "uint32", "name": "dstEid", "type": "uint32" },
{ "internalType": "bytes32", "name": "to", "type": "bytes32" },
{ "internalType": "uint256", "name": "amountLD", "type": "uint256" },
{ "internalType": "uint256", "name": "minAmountLD", "type": "uint256" },
{ "internalType": "bytes", "name": "extraOptions", "type": "bytes" },
{ "internalType": "bytes", "name": "composeMsg", "type": "bytes" },
{ "internalType": "bytes", "name": "oftCmd", "type": "bytes" }
],
"internalType": "struct SendParam",
"name": "_sendParam",
"type": "tuple"
},
{ "internalType": "bool", "name": "_payInLzToken", "type": "bool" }
],
"name": "quoteSend",
"outputs": [
{
"components": [
{ "internalType": "uint256", "name": "nativeFee", "type": "uint256" },
{ "internalType": "uint256", "name": "lzTokenFee", "type": "uint256" }
],
"internalType": "struct MessagingFee",
"name": "msgFee",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"components": [
{ "internalType": "uint32", "name": "dstEid", "type": "uint32" },
{ "internalType": "bytes32", "name": "to", "type": "bytes32" },
{ "internalType": "uint256", "name": "amountLD", "type": "uint256" },
{ "internalType": "uint256", "name": "minAmountLD", "type": "uint256" },
{ "internalType": "bytes", "name": "extraOptions", "type": "bytes" },
{ "internalType": "bytes", "name": "composeMsg", "type": "bytes" },
{ "internalType": "bytes", "name": "oftCmd", "type": "bytes" }
],
"internalType": "struct SendParam",
"name": "_sendParam",
"type": "tuple"
},
{
"components": [
{ "internalType": "uint256", "name": "nativeFee", "type": "uint256" },
{ "internalType": "uint256", "name": "lzTokenFee", "type": "uint256" }
],
"internalType": "struct MessagingFee",
"name": "_fee",
"type": "tuple"
},
{ "internalType": "address", "name": "_refundAddress", "type": "address" }
],
"name": "send",
"outputs": [
{
"components": [
{ "internalType": "bytes32", "name": "guid", "type": "bytes32" },
{ "internalType": "uint64", "name": "nonce", "type": "uint64" },
{
"components": [
{ "internalType": "uint256", "name": "nativeFee", "type": "uint256" },
{ "internalType": "uint256", "name": "lzTokenFee", "type": "uint256" }
],
"internalType": "struct MessagingFee",
"name": "fee",
"type": "tuple"
}
],
"internalType": "struct MessagingReceipt",
"name": "msgReceipt",
"type": "tuple"
},
{
"components": [
{ "internalType": "uint256", "name": "amountSentLD", "type": "uint256" },
{ "internalType": "uint256", "name": "amountReceivedLD", "type": "uint256" }
],
"internalType": "struct OFTReceipt",
"name": "oftReceipt",
"type": "tuple"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "token",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "approvalRequired",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
}
]
13 changes: 12 additions & 1 deletion src/integration/blockchain/shared/evm/evm-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export abstract class EvmClient extends BlockchainClient {
return EvmUtil.getGasPriceLimitFromHex(txHex, currentGasPrice);
}

async approveContract(asset: Asset, contractAddress: string): Promise<string> {
async approveContract(asset: Asset, contractAddress: string, wait = false): Promise<string> {
const contract = this.getERC20ContractForDex(asset.chainId);

const transaction = await contract.populateTransaction.approve(contractAddress, ethers.constants.MaxInt256);
Expand All @@ -464,9 +464,20 @@ export abstract class EvmClient extends BlockchainClient {

this.setNonce(this.walletAddress, nonce + 1);

if (wait) await tx.wait();

return tx.hash;
}

async checkAndApproveContract(asset: Asset, contractAddress: string, amount: EthersNumber): Promise<string | null> {
const contract = this.getERC20ContractForDex(asset.chainId);
const allowance = await contract.allowance(this.walletAddress, contractAddress);

if (allowance.gte(amount)) return null;

return this.approveContract(asset, contractAddress, true);
}

// --- PUBLIC API - SWAPS --- //

async getUniswapLiquidity(nftContract: string, positionId: number): Promise<[number, number]> {
Expand Down
Loading
Loading