import { LimoClient } from '@kamino-finance/limo-sdk'; import { RouteParams } from './types'; import BN from 'bn.js'; import { Address, createNoopSigner, Instruction } from '@solana/kit'; export async function getLimoLedgerIxsForRoute(args: { params: RouteParams; limoClient: LimoClient; inputTa: Address; outputTa: Address; maxInputAmountChange: BN; minOutputAmountChange: BN; }): Promise<{ preIx: Instruction; postIx: Instruction }> { const { params, limoClient, inputTa, outputTa, maxInputAmountChange, minOutputAmountChange } = args; const limoLedgerIxs = await limoClient.assertUserSwapBalancesIxs({ user: createNoopSigner(params.executor), inputTa, outputTa, maxInputAmountChange: params.overrideAssertMaxInputAmountChange ? params.overrideAssertMaxInputAmountChange : maxInputAmountChange, minOutputAmountChange: params.overrideAssertMinOutputAmountChange ? params.overrideAssertMinOutputAmountChange : minOutputAmountChange, }); return { preIx: limoLedgerIxs.beforeSwapIx, postIx: limoLedgerIxs.afterSwapIx }; } export function includeLedgerIxs(params: RouteParams): boolean { if (params.assertSwapBalances === undefined) { return false; } return params.assertSwapBalances == true && params.swapType === 'exactIn'; }