Skip to content

Commit

Permalink
comment out referral fee test case
Browse files Browse the repository at this point in the history
  • Loading branch information
McSam94 committed Oct 26, 2023
1 parent 1b3ffbd commit 57e699b
Showing 1 changed file with 78 additions and 76 deletions.
154 changes: 78 additions & 76 deletions ts-client/src/amm/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,44 +91,45 @@ describe('Interact with Devnet pool', () => {
}
});

test('Swap SOL → USDT with referrer fee', async () => {
const referrerSolAta = await getOrCreateATA(provider.connection, NATIVE_MINT, referrer.publicKey, mockWallet.payer);
const inAmountLamport = new BN(0.1 * 10 ** cpPool.tokenB.decimals);

const { swapOutAmount, minSwapOutAmount } = cpPool.getSwapQuote(
new PublicKey(cpPool.tokenB.address),
inAmountLamport,
DEFAULT_SLIPPAGE,
);
expect(swapOutAmount.toNumber()).toBeGreaterThan(0);

const swapTx = await cpPool.swap(
mockWallet.publicKey,
new PublicKey(cpPool.tokenB.address),
inAmountLamport,
minSwapOutAmount,
referrerSolAta,
);

try {
const beforeReferrerTokenBalance = await provider.connection
.getTokenAccountBalance(referrerSolAta)
.then((r) => r.value.uiAmount);

const swapResult = await provider.sendAndConfirm(swapTx);
console.log('Swap Result of SOL → USDT', swapResult);
expect(typeof swapResult).toBe('string');

const afterReferrerTokenBalance = await provider.connection
.getTokenAccountBalance(referrerSolAta)
.then((r) => r.value.uiAmount);

expect(afterReferrerTokenBalance!).toBeGreaterThan(beforeReferrerTokenBalance!);
} catch (error: any) {
console.trace(error);
throw new Error(error.message);
}
});
// zero protocol campaign
// test('Swap SOL → USDT with referrer fee', async () => {
// const referrerSolAta = await getOrCreateATA(provider.connection, NATIVE_MINT, referrer.publicKey, mockWallet.payer);
// const inAmountLamport = new BN(0.1 * 10 ** cpPool.tokenB.decimals);

// const { swapOutAmount, minSwapOutAmount } = cpPool.getSwapQuote(
// new PublicKey(cpPool.tokenB.address),
// inAmountLamport,
// DEFAULT_SLIPPAGE,
// );
// expect(swapOutAmount.toNumber()).toBeGreaterThan(0);

// const swapTx = await cpPool.swap(
// mockWallet.publicKey,
// new PublicKey(cpPool.tokenB.address),
// inAmountLamport,
// minSwapOutAmount,
// referrerSolAta,
// );

// try {
// const beforeReferrerTokenBalance = await provider.connection
// .getTokenAccountBalance(referrerSolAta)
// .then((r) => r.value.uiAmount);

// const swapResult = await provider.sendAndConfirm(swapTx);
// console.log('Swap Result of SOL → USDT', swapResult);
// expect(typeof swapResult).toBe('string');

// const afterReferrerTokenBalance = await provider.connection
// .getTokenAccountBalance(referrerSolAta)
// .then((r) => r.value.uiAmount);

// expect(afterReferrerTokenBalance!).toBeGreaterThan(beforeReferrerTokenBalance!);
// } catch (error: any) {
// console.trace(error);
// throw new Error(error.message);
// }
// });

test('Swap USDT → SOL', async () => {
const inAmountLamport = new BN(0.1 * 10 ** cpPool.tokenA.decimals);
Expand Down Expand Up @@ -236,44 +237,45 @@ describe('Interact with Devnet pool', () => {
}
});

test('Swap SOL → mSOL with referrer fee', async () => {
const referrerSolAta = await getOrCreateATA(provider.connection, NATIVE_MINT, referrer.publicKey, mockWallet.payer);
const inAmountLamport = new BN(0.01 * 10 ** depegPool.tokenA.decimals);

const { swapOutAmount, minSwapOutAmount } = depegPool.getSwapQuote(
new PublicKey(depegPool.tokenA.address),
inAmountLamport,
DEFAULT_SLIPPAGE,
);
expect(swapOutAmount.toNumber()).toBeGreaterThan(0);

const swapTx = await depegPool.swap(
mockWallet.publicKey,
new PublicKey(depegPool.tokenA.address),
inAmountLamport,
minSwapOutAmount,
referrerSolAta,
);

try {
const beforeReferrerTokenBalance = await provider.connection
.getTokenAccountBalance(referrerSolAta)
.then((r) => r.value.uiAmount);

const swapResult = await provider.sendAndConfirm(swapTx);
console.log('Swap Result of SOL → mSOL', swapResult);
expect(typeof swapResult).toBe('string');

const afterReferrerTokenBalance = await provider.connection
.getTokenAccountBalance(referrerSolAta)
.then((r) => r.value.uiAmount);

expect(afterReferrerTokenBalance!).toBeGreaterThan(beforeReferrerTokenBalance!);
} catch (error: any) {
console.trace(error);
throw new Error(error.message);
}
});
// zero protocol campaign
// test('Swap SOL → mSOL with referrer fee', async () => {
// const referrerSolAta = await getOrCreateATA(provider.connection, NATIVE_MINT, referrer.publicKey, mockWallet.payer);
// const inAmountLamport = new BN(0.01 * 10 ** depegPool.tokenA.decimals);

// const { swapOutAmount, minSwapOutAmount } = depegPool.getSwapQuote(
// new PublicKey(depegPool.tokenA.address),
// inAmountLamport,
// DEFAULT_SLIPPAGE,
// );
// expect(swapOutAmount.toNumber()).toBeGreaterThan(0);

// const swapTx = await depegPool.swap(
// mockWallet.publicKey,
// new PublicKey(depegPool.tokenA.address),
// inAmountLamport,
// minSwapOutAmount,
// referrerSolAta,
// );

// try {
// const beforeReferrerTokenBalance = await provider.connection
// .getTokenAccountBalance(referrerSolAta)
// .then((r) => r.value.uiAmount);

// const swapResult = await provider.sendAndConfirm(swapTx);
// console.log('Swap Result of SOL → mSOL', swapResult);
// expect(typeof swapResult).toBe('string');

// const afterReferrerTokenBalance = await provider.connection
// .getTokenAccountBalance(referrerSolAta)
// .then((r) => r.value.uiAmount);

// expect(afterReferrerTokenBalance!).toBeGreaterThan(beforeReferrerTokenBalance!);
// } catch (error: any) {
// console.trace(error);
// throw new Error(error.message);
// }
// });

test('Swap mSOL → SOL', async () => {
const inAmountLamport = new BN(0.01 * 10 ** depegPool.tokenB.decimals);
Expand Down

0 comments on commit 57e699b

Please sign in to comment.