-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for close position, decrease liquidity, and harvest position #653
Add tests for close position, decrease liquidity, and harvest position #653
Conversation
pauldragonfly
commented
Jan 14, 2025
- Add tests for close position
- Add tests for decrease liquidity
- Add tests for harvest position
5df0e68
to
bdd067f
Compare
bdd067f
to
6010ba3
Compare
const tokenAAfter = await fetchToken(rpc, ataAAddress); | ||
const tokenBAfter = await fetchToken(rpc, ataBAddress); | ||
|
||
assert.strictEqual( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything to harvest in this case? Since the pool has no swaps the feesOwed would just be 0 I think.
One swap A->B and a swap B->A for each pool after the position is set up should do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added testHarvestPositionInstructionsWithoutSwaps()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I believe now there are only swaps from A->B which would only generate fees for token A. I think if you do the following 4 swaps you'll cover all cases:
{ inputAmount: 100n, mint: mintAAddress },
{ outputAmount: 100n, mint: mintAAddress },
{ inputAmount: 100n, mint: mintBAddress },
{ outputAmount: 100n, mint: mintBAddress },
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified testHarvestPositionInstructions()
to test after the above 4 swaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Two small remarks
for (const poolName of poolTypes.keys()) { | ||
for (const positionTypeName of positionTypes.keys()) { | ||
const positionName = `${poolName} ${positionTypeName}`; | ||
it(`Should harvest a position for ${positionName}`, async () => { | ||
await testHarvestPositionInstructions(poolName, positionName); | ||
}); | ||
|
||
it(`Should harvest a position without swaps for ${positionName}`, async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: without fees
const tokenAAfter = await fetchToken(rpc, ataAAddress); | ||
const tokenBAfter = await fetchToken(rpc, ataBAddress); | ||
|
||
assert.strictEqual( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I believe now there are only swaps from A->B which would only generate fees for token A. I think if you do the following 4 swaps you'll cover all cases:
{ inputAmount: 100n, mint: mintAAddress },
{ outputAmount: 100n, mint: mintAAddress },
{ inputAmount: 100n, mint: mintBAddress },
{ outputAmount: 100n, mint: mintBAddress },
e778c6d
to
7ff8403
Compare
7ff8403
to
41655b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢