From f8dba20e0fdcbd5b2eed6f6bc2d3b4f9545fe5be Mon Sep 17 00:00:00 2001 From: emerson Date: Fri, 4 Nov 2022 00:50:58 +0000 Subject: [PATCH] Add swap --- tests/testAdapterGenopets.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/testAdapterGenopets.ts b/tests/testAdapterGenopets.ts index d0ea6d7..ea3d8a0 100644 --- a/tests/testAdapterGenopets.ts +++ b/tests/testAdapterGenopets.ts @@ -58,6 +58,17 @@ describe("Gateway", () => { "Enq8vJucRbkzKA1i1PahJNhMyUTzoVL5Cs8n5rC3NLGn" // GENE-USDC ); const farmId = genopets.getFarmId(mint); + const swapParams: SwapParams = { + protocol: SupportedProtocols.Jupiter, + fromTokenMint: new PublicKey( + "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // USDC + ), + toTokenMint: new PublicKey( + "GENEtH5amGSi8kHAtQoezp1XEXwZJ8vcuePYnXdKrMYz" // GENE + ), + amount: 100, // Swap half of the fromToken to proceed zapIn + slippage: 1, + }; const addLiquidityParams: AddLiquidityParams = { protocol: SupportedProtocols.Raydium, poolId, @@ -78,6 +89,7 @@ describe("Gateway", () => { const gateway = new GatewayBuilder(provider); + await gateway.swap(swapParams); await gateway.addLiquidity(addLiquidityParams); await gateway.stake(stakeParams); @@ -121,6 +133,19 @@ describe("Gateway", () => { connection, farmerId )) as genopets.FarmerInfo; + const swapParams: SwapParams = { + protocol: SupportedProtocols.Jupiter, + fromTokenMint: new PublicKey( + // "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // USDC + "GENEtH5amGSi8kHAtQoezp1XEXwZJ8vcuePYnXdKrMYz" // GENE + ), + toTokenMint: new PublicKey( + "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // USDC + // "GENEtH5amGSi8kHAtQoezp1XEXwZJ8vcuePYnXdKrMYz" // GENE + ), + amount: 100, // Swap half of the fromToken to proceed zapIn + slippage: 1, + }; const harvestParams1: HarvestParams = { protocol: SupportedProtocols.Genopets, @@ -180,7 +205,7 @@ describe("Gateway", () => { // await gateway.harvest(harvestParams3); await gateway.unstake(unstakeParams); await gateway.removeLiquidity(removeLiquidityParams); - // await gateway.swap(swapParams); + await gateway.swap(swapParams); await gateway.finalize();