UNPKG

@prism-hq/prism-ag

Version:

Prism Aggregator

54 lines (53 loc) 2.5 kB
"use strict"; // import { Program } from "@project-serum/anchor"; // import { PublicKey } from "@solana/web3.js"; // import { LIFINITY_PROGRAM_ID, TRANSITIVE_STATE, Wallet } from "../types/types"; // import BN from "bn.js"; // import { PrismAg } from "./idl"; // import { findProgramAddressSync } from "@project-serum/anchor/dist/cjs/utils/pubkey"; // export async function lifinitySwap( // user: PublicKey, // program: Program<PrismAg>, // route: any, // fromTokenAccount: PublicKey, // toTokenAccount: PublicKey, // fees: any, // hostFees: number, // useT: any = null, // disableFees: any = false, // ) { // let {fromCoin, toCoin, lifinityInfo} = route.routeData; // let [poolSource, poolDestination] = [lifinityInfo.poolPcTokenAccount, lifinityInfo.poolCoinTokenAccount]; // if (lifinityInfo.poolCoinMint == fromCoin.mintAddress) // [poolSource, poolDestination] = [poolDestination, poolSource] // return program.instruction.lifinitySwap( // new BN(route.amountIn * 10 ** fromCoin.decimals), // new BN(route.minimumReceived * 10 ** toCoin.decimals), // useT ? true : false, // new BN(hostFees), // { // accounts:{ // lifinityTokenSwap: new PublicKey(LIFINITY_PROGRAM_ID), // lifinityAuthority: findProgramAddressSync( // [new PublicKey(lifinityInfo.amm).toBuffer()], // new PublicKey(LIFINITY_PROGRAM_ID) // )[0], // lifinityAmm: new PublicKey(lifinityInfo.amm), // authority: user, // fromTokenAccount: fromTokenAccount, // toTokenAccount: toTokenAccount, // poolSource: new PublicKey(poolSource), // poolDestination: new PublicKey(poolDestination), // poolMint: new PublicKey(lifinityInfo.poolMint), // feeAccount: new PublicKey(lifinityInfo.feeAccount), // pythPcAccount: new PublicKey(lifinityInfo.pythPcAccount), // pythAccount: new PublicKey(lifinityInfo.pythAccount), // configAccount: new PublicKey(lifinityInfo.configAccount), // tokenProgram: new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), // feeSweeper: fees.owner, // transitiveState: new PublicKey(TRANSITIVE_STATE), // host: fees.host, // }, // } // ); // }