Skip to content

Commit

Permalink
Add swap
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonliuuu committed Nov 4, 2022
1 parent 8014948 commit f8dba20
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/testAdapterGenopets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -78,6 +89,7 @@ describe("Gateway", () => {

const gateway = new GatewayBuilder(provider);

await gateway.swap(swapParams);
await gateway.addLiquidity(addLiquidityParams);
await gateway.stake(stakeParams);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit f8dba20

Please sign in to comment.