/* eslint-disable @typescript-eslint/no-explicit-any */ import { ethers } from "ethers"; import IVelodromeRouter from "../../abi/IVeldodromeRouter.json"; import { Pool } from "../../entities"; import { Dapp, Transaction } from "../../types"; import { getDeadline } from "../../utils/deadline"; import { nonfungiblePositionManagerAddress } from "../../config"; import INonfungiblePositionManager from "../../abi/INonfungiblePositionManager.json"; /** Encode Velodrome router calldata to add liquidity to a stable or volatile pair. */ export async function getVelodromeAddLiquidityTxData( pool: Pool, assetA: string, assetB: string, amountA: ethers.BigNumber | string, amountB: ethers.BigNumber | string, isStable: boolean ): Promise { const iVelodromeRouter = new ethers.utils.Interface(IVelodromeRouter.abi); return iVelodromeRouter.encodeFunctionData(Transaction.ADD_LIQUIDITY, [ assetA, assetB, isStable, amountA, amountB, "0", "0", pool.address, await getDeadline(pool) ]); } /** Encode Velodrome router calldata to remove liquidity from a stable or volatile pair. */ export async function getVelodromeRemoveLiquidityTxData( pool: Pool, assetA: string, assetB: string, amount: ethers.BigNumber | string, isStable: boolean ): Promise { const iVelodromeRouter = new ethers.utils.Interface(IVelodromeRouter.abi); return iVelodromeRouter.encodeFunctionData(Transaction.REMOVE_LIQUIDITY, [ assetA, assetB, isStable, amount, "0", "0", pool.address, await getDeadline(pool) ]); } /** Read the current owner of a Velodrome/Aerodrome/Pancake CL position NFT. */ export async function getClOwner( pool: Pool, dapp: Dapp.VELODROMECL | Dapp.AERODROMECL | Dapp.PANCAKECL, tokenId: string ): Promise { const iNonfungiblePositionManager = new ethers.Contract( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion nonfungiblePositionManagerAddress[pool.network][dapp]!, INonfungiblePositionManager.abi, pool.signer ); return await iNonfungiblePositionManager.ownerOf(tokenId); }