Skip to content

Commit

Permalink
Improve swap fee and lm reward claims (MeteoraAg#88)
Browse files Browse the repository at this point in the history
* fix empty reward claims

* bump sdk version

* add change log

* improve fees and lm rewards claiming

* sync changelog
  • Loading branch information
shadeglare authored Jul 17, 2024
1 parent 2932357 commit 0dfd476
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security

## @meteora-ag/dlmm [1.0.49] - PR #88

### Improvement

- Improve the `claimAllRewards` method with a more distinct filtering for claiming non empty swap fees and lm rewards per each kind.
- Filter positions with non zero LM rewards in the `claimAllLMRewards` method.
- Filter positions with non zero swap fees in the `claimAllSwapFee` method.

## @meteora-ag/dlmm [1.0.48] - PR #87

Expand Down Expand Up @@ -227,7 +234,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix create permission lb pair browser compatibility


## @mercurial-finance/dlmm-sdk [1.0.29] - PR #59

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion ts-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meteora-ag/dlmm",
"version": "1.0.49-rc.2",
"version": "1.0.49-rc.3",
"description": "",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
72 changes: 42 additions & 30 deletions ts-client/src/dlmm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3622,13 +3622,16 @@ export class DLMM {
}): Promise<Transaction[]> {
const claimAllTxs = (
await Promise.all(
positions.map(async (position, idx) => {
return await this.createClaimBuildMethod({
owner,
position,
shouldIncludePreIx: idx === 0,
});
})
positions
.filter(({ positionData: { rewardOne, rewardTwo } }) =>
!rewardOne.isZero() || !rewardTwo.isZero())
.map(async (position, idx) => {
return await this.createClaimBuildMethod({
owner,
position,
shouldIncludePreIx: idx === 0,
});
})
)
).flat();

Expand Down Expand Up @@ -3738,14 +3741,17 @@ export class DLMM {
}): Promise<Transaction[]> {
const claimAllTxs = (
await Promise.all(
positions.map(async (position, idx) => {
return await this.createClaimSwapFeeMethod({
owner,
position,
shouldIncludePretIx: idx === 0,
shouldIncludePostIx: idx === positions.length - 1,
});
})
positions
.filter(({ positionData: { feeX, feeY } }) =>
!feeX.isZero() || !feeY.isZero())
.map(async (position, idx, positions) => {
return await this.createClaimSwapFeeMethod({
owner,
position,
shouldIncludePretIx: idx === 0,
shouldIncludePostIx: idx === positions.length - 1,
});
})
)
).flat();

Expand Down Expand Up @@ -4276,26 +4282,32 @@ export class DLMM {

const claimAllSwapFeeTxs = (
await Promise.all(
positions.map(async (position) => {
return await this.createClaimSwapFeeMethod({
owner,
position,
shouldIncludePretIx: false,
shouldIncludePostIx: false,
});
})
positions
.filter(({ positionData: { feeX, feeY } }) =>
!feeX.isZero() || !feeY.isZero())
.map(async (position) => {
return await this.createClaimSwapFeeMethod({
owner,
position,
shouldIncludePretIx: false,
shouldIncludePostIx: false,
});
})
)
).flat();

const claimAllLMTxs = (
await Promise.all(
positions.map(async (position) => {
return await this.createClaimBuildMethod({
owner,
position,
shouldIncludePreIx: false,
});
})
positions
.filter(({ positionData: { rewardOne, rewardTwo } }) =>
!rewardOne.isZero() || !rewardTwo.isZero())
.map(async (position) => {
return await this.createClaimBuildMethod({
owner,
position,
shouldIncludePreIx: false,
});
})
)
).flat();

Expand Down

0 comments on commit 0dfd476

Please sign in to comment.