@cetusprotocol/dlmm-sdk 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +32 -32
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/config/mainnet.ts +1 -1
- package/src/utils/weightUtils.ts +7 -4
package/package.json
CHANGED
package/src/config/mainnet.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const dlmmMainnet: SdkOptions = {
|
|
|
19
19
|
},
|
|
20
20
|
dlmm_router: {
|
|
21
21
|
package_id: '0xc65d59c4aa7c9d53836bdbbb2a1418b02be6a351a767c64d6e4b7e96d26356d2',
|
|
22
|
-
published_at: '
|
|
22
|
+
published_at: '0xab76281e46956e18ce7ae3ab876da0b769e21afca90d2dc00b74bb9161720d28',
|
|
23
23
|
version: 1,
|
|
24
24
|
},
|
|
25
25
|
}
|
package/src/utils/weightUtils.ts
CHANGED
|
@@ -61,9 +61,12 @@ export class WeightUtils {
|
|
|
61
61
|
|
|
62
62
|
const diff_weight = d(DEFAULT_MAX_WEIGHT).sub(d(DEFAULT_MIN_WEIGHT)).floor()
|
|
63
63
|
|
|
64
|
-
const
|
|
64
|
+
const left_end_bin_id = active_id > upper_bin_id ? upper_bin_id : active_id
|
|
65
|
+
const right_start_bin_id = active_id < lower_bin_id ? lower_bin_id : active_id
|
|
65
66
|
|
|
66
|
-
const
|
|
67
|
+
const diff_min_weight = active_id > lower_bin_id ? diff_weight.div(d(left_end_bin_id - lower_bin_id)).floor() : d(0)
|
|
68
|
+
|
|
69
|
+
const diff_max_weight = upper_bin_id > active_id ? diff_weight.div(d(upper_bin_id - right_start_bin_id)).floor() : d(0)
|
|
67
70
|
|
|
68
71
|
let bin_id = lower_bin_id
|
|
69
72
|
let weights: Decimal[] = []
|
|
@@ -72,7 +75,7 @@ export class WeightUtils {
|
|
|
72
75
|
while (bin_id <= upper_bin_id) {
|
|
73
76
|
let weight: Decimal = d(0)
|
|
74
77
|
if (bin_id < active_id) {
|
|
75
|
-
const delta_bin =
|
|
78
|
+
const delta_bin = left_end_bin_id - bin_id
|
|
76
79
|
if (strategy_type === StrategyType.Spot) {
|
|
77
80
|
weight = d(1)
|
|
78
81
|
} else if (strategy_type === StrategyType.BidAsk) {
|
|
@@ -81,7 +84,7 @@ export class WeightUtils {
|
|
|
81
84
|
weight = d(base_weight).sub(diff_min_weight.mul(delta_bin)).floor()
|
|
82
85
|
}
|
|
83
86
|
} else if (bin_id > active_id) {
|
|
84
|
-
const delta_bin = bin_id -
|
|
87
|
+
const delta_bin = bin_id - right_start_bin_id
|
|
85
88
|
if (strategy_type === StrategyType.Spot) {
|
|
86
89
|
weight = d(1)
|
|
87
90
|
} else if (strategy_type === StrategyType.BidAsk) {
|