Skip to content

Commit 0dbe64e

Browse files
committed
fix: process position calculate position amount
1 parent a218966 commit 0dbe64e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919

2020
### Security
2121

22+
## @meteora-ag/dlmm [1.5.3] - PR #213
23+
24+
### Fixed
25+
26+
- fix `processPosition` to use decimal.js calculate `positionXAmount`
27+
2228
## @meteora-ag/dlmm [1.5.2] - PR #209
2329

2430
### Fixed

ts-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@meteora-ag/dlmm",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"description": "",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

ts-client/src/dlmm/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6169,11 +6169,15 @@ export class DLMM {
61696169

61706170
const positionXAmount = binSupply.eq(ZERO)
61716171
? ZERO
6172-
: posShare.mul(bin.xAmount).div(binSupply);
6172+
: new Decimal(posShare.toString())
6173+
.mul(new Decimal(bin.xAmount.toString()))
6174+
.div(new Decimal(binSupply.toString()));
61736175

61746176
const positionYAmount = binSupply.eq(ZERO)
61756177
? ZERO
6176-
: posShare.mul(bin.yAmount).div(binSupply);
6178+
: new Decimal(posShare.toString())
6179+
.mul(new Decimal(bin.yAmount.toString()))
6180+
.div(new Decimal(binSupply.toString()));
61776181

61786182
totalXAmount = totalXAmount.add(new Decimal(positionXAmount.toString()));
61796183
totalYAmount = totalYAmount.add(new Decimal(positionYAmount.toString()));

0 commit comments

Comments
 (0)