@magmaprotocol/magma-clmm-sdk 0.5.66 → 0.5.68
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/README.md +9 -5
- package/dist/index.d.ts +5 -4
- package/dist/index.js +153 -330
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -330
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -37,7 +37,7 @@ var CachedContent = class {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
// src/utils/common.ts
|
|
40
|
-
import
|
|
40
|
+
import BN12 from "bn.js";
|
|
41
41
|
import { fromB64, fromHEX } from "@mysten/bcs";
|
|
42
42
|
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
43
43
|
import { Secp256k1Keypair } from "@mysten/sui/keypairs/secp256k1";
|
|
@@ -1592,9 +1592,6 @@ function collectFeesQuote(param) {
|
|
|
1592
1592
|
return updateFees(param.position, fee_growth_inside_a, fee_growth_inside_b);
|
|
1593
1593
|
}
|
|
1594
1594
|
|
|
1595
|
-
// src/math/dlmmStrategy.ts
|
|
1596
|
-
import BN10 from "bn.js";
|
|
1597
|
-
|
|
1598
1595
|
// src/math/dlmmWeightToAmounts.ts
|
|
1599
1596
|
import BN9 from "bn.js";
|
|
1600
1597
|
import Decimal3 from "decimal.js";
|
|
@@ -1878,31 +1875,11 @@ function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBi
|
|
|
1878
1875
|
|
|
1879
1876
|
// src/math/dlmmStrategy.ts
|
|
1880
1877
|
var StrategyType = /* @__PURE__ */ ((StrategyType2) => {
|
|
1881
|
-
StrategyType2[StrategyType2["Spot"] =
|
|
1882
|
-
StrategyType2[StrategyType2["Curve"] =
|
|
1883
|
-
StrategyType2[StrategyType2["BidAsk"] =
|
|
1878
|
+
StrategyType2[StrategyType2["Spot"] = 1] = "Spot";
|
|
1879
|
+
StrategyType2[StrategyType2["Curve"] = 2] = "Curve";
|
|
1880
|
+
StrategyType2[StrategyType2["BidAsk"] = 3] = "BidAsk";
|
|
1884
1881
|
return StrategyType2;
|
|
1885
1882
|
})(StrategyType || {});
|
|
1886
|
-
function toWeightDecendingOrder(minBinId, maxBinId) {
|
|
1887
|
-
const distributions = [];
|
|
1888
|
-
for (let i = minBinId; i <= maxBinId; i++) {
|
|
1889
|
-
distributions.push({
|
|
1890
|
-
binId: i,
|
|
1891
|
-
weight: maxBinId - i + 1
|
|
1892
|
-
});
|
|
1893
|
-
}
|
|
1894
|
-
return distributions;
|
|
1895
|
-
}
|
|
1896
|
-
function toWeightAscendingOrder(minBinId, maxBinId) {
|
|
1897
|
-
const distributions = [];
|
|
1898
|
-
for (let i = minBinId; i <= maxBinId; i++) {
|
|
1899
|
-
distributions.push({
|
|
1900
|
-
binId: i,
|
|
1901
|
-
weight: i - minBinId + 1
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
return distributions;
|
|
1905
|
-
}
|
|
1906
1883
|
function toWeightSpotBalanced(minBinId, maxBinId) {
|
|
1907
1884
|
const distributions = [];
|
|
1908
1885
|
for (let i = minBinId; i <= maxBinId; i++) {
|
|
@@ -1977,15 +1954,15 @@ function toWeightBidAsk(minBinId, maxBinId, activeId) {
|
|
|
1977
1954
|
}
|
|
1978
1955
|
function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
1979
1956
|
switch (strategyType) {
|
|
1980
|
-
case
|
|
1957
|
+
case 1 /* Spot */: {
|
|
1981
1958
|
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
1982
1959
|
return autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, weights);
|
|
1983
1960
|
}
|
|
1984
|
-
case
|
|
1961
|
+
case 2 /* Curve */: {
|
|
1985
1962
|
const weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
1986
1963
|
return autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, weights);
|
|
1987
1964
|
}
|
|
1988
|
-
case
|
|
1965
|
+
case 3 /* BidAsk */: {
|
|
1989
1966
|
const weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
1990
1967
|
return autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, weights);
|
|
1991
1968
|
}
|
|
@@ -1995,15 +1972,15 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
1995
1972
|
}
|
|
1996
1973
|
function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
1997
1974
|
switch (strategyType) {
|
|
1998
|
-
case
|
|
1975
|
+
case 1 /* Spot */: {
|
|
1999
1976
|
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
2000
1977
|
return autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2001
1978
|
}
|
|
2002
|
-
case
|
|
1979
|
+
case 2 /* Curve */: {
|
|
2003
1980
|
const weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
2004
1981
|
return autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2005
1982
|
}
|
|
2006
|
-
case
|
|
1983
|
+
case 3 /* BidAsk */: {
|
|
2007
1984
|
const weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
2008
1985
|
return autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2009
1986
|
}
|
|
@@ -2014,178 +1991,17 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
2014
1991
|
function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amountX, amountY, amountXInActiveBin, amountYInActiveBin, strategyType) {
|
|
2015
1992
|
const isSingleSideX = amountY.isZero();
|
|
2016
1993
|
switch (strategyType) {
|
|
2017
|
-
case
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
amountsInBin.push({
|
|
2029
|
-
binId: bin.binId,
|
|
2030
|
-
amountX: new BN10(0),
|
|
2031
|
-
amountY: bin.amount
|
|
2032
|
-
});
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
if (activeId < maxBinId) {
|
|
2036
|
-
const weights = toWeightSpotBalanced(activeId + 1, maxBinId);
|
|
2037
|
-
const amounts = toAmountAskSide(activeId, binStep, amountX, weights);
|
|
2038
|
-
for (const bin of amounts) {
|
|
2039
|
-
amountsInBin.push({
|
|
2040
|
-
binId: bin.binId,
|
|
2041
|
-
amountX: bin.amount,
|
|
2042
|
-
amountY: new BN10(0)
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
} else {
|
|
2047
|
-
if (minBinId < activeId) {
|
|
2048
|
-
const weights = toWeightSpotBalanced(minBinId, activeId - 1);
|
|
2049
|
-
const amountsIntoBidSide = toAmountBidSide(activeId, amountY, weights);
|
|
2050
|
-
for (const bin of amountsIntoBidSide) {
|
|
2051
|
-
amountsInBin.push({
|
|
2052
|
-
binId: bin.binId,
|
|
2053
|
-
amountX: new BN10(0),
|
|
2054
|
-
amountY: bin.amount
|
|
2055
|
-
});
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
if (activeId <= maxBinId) {
|
|
2059
|
-
const weights = toWeightSpotBalanced(activeId, maxBinId);
|
|
2060
|
-
const amountsIntoAskSide = toAmountAskSide(activeId, binStep, amountX, weights);
|
|
2061
|
-
for (const bin of amountsIntoAskSide) {
|
|
2062
|
-
amountsInBin.push({
|
|
2063
|
-
binId: bin.binId,
|
|
2064
|
-
amountX: bin.amount,
|
|
2065
|
-
amountY: new BN10(0)
|
|
2066
|
-
});
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
return amountsInBin;
|
|
2071
|
-
}
|
|
2072
|
-
case 1 /* Curve */: {
|
|
2073
|
-
if (activeId < minBinId) {
|
|
2074
|
-
const weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
2075
|
-
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2076
|
-
}
|
|
2077
|
-
if (activeId > maxBinId) {
|
|
2078
|
-
const weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
2079
|
-
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2080
|
-
}
|
|
2081
|
-
const amountsInBin = [];
|
|
2082
|
-
if (!isSingleSideX) {
|
|
2083
|
-
if (minBinId <= activeId) {
|
|
2084
|
-
const weights = toWeightAscendingOrder(minBinId, activeId);
|
|
2085
|
-
const amounts = toAmountBidSide(activeId, amountY, weights);
|
|
2086
|
-
for (const bin of amounts) {
|
|
2087
|
-
amountsInBin.push({
|
|
2088
|
-
binId: bin.binId,
|
|
2089
|
-
amountX: new BN10(0),
|
|
2090
|
-
amountY: bin.amount
|
|
2091
|
-
});
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
if (activeId < maxBinId) {
|
|
2095
|
-
const weights = toWeightDecendingOrder(activeId + 1, maxBinId);
|
|
2096
|
-
const amounts = toAmountAskSide(activeId, binStep, amountX, weights);
|
|
2097
|
-
for (const bin of amounts) {
|
|
2098
|
-
amountsInBin.push({
|
|
2099
|
-
binId: bin.binId,
|
|
2100
|
-
amountX: bin.amount,
|
|
2101
|
-
amountY: new BN10(0)
|
|
2102
|
-
});
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
} else {
|
|
2106
|
-
if (minBinId < activeId) {
|
|
2107
|
-
const weights = toWeightAscendingOrder(minBinId, activeId - 1);
|
|
2108
|
-
const amountsIntoBidSide = toAmountBidSide(activeId, amountY, weights);
|
|
2109
|
-
for (const bin of amountsIntoBidSide) {
|
|
2110
|
-
amountsInBin.push({
|
|
2111
|
-
binId: bin.binId,
|
|
2112
|
-
amountX: new BN10(0),
|
|
2113
|
-
amountY: bin.amount
|
|
2114
|
-
});
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
if (activeId <= maxBinId) {
|
|
2118
|
-
const weights = toWeightDecendingOrder(activeId, maxBinId);
|
|
2119
|
-
const amountsIntoAskSide = toAmountAskSide(activeId, binStep, amountX, weights);
|
|
2120
|
-
for (const bin of amountsIntoAskSide) {
|
|
2121
|
-
amountsInBin.push({
|
|
2122
|
-
binId: bin.binId,
|
|
2123
|
-
amountX: bin.amount,
|
|
2124
|
-
amountY: new BN10(0)
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
return amountsInBin;
|
|
2130
|
-
}
|
|
2131
|
-
case 2 /* BidAsk */: {
|
|
2132
|
-
if (activeId < minBinId) {
|
|
2133
|
-
const weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
2134
|
-
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2135
|
-
}
|
|
2136
|
-
if (activeId > maxBinId) {
|
|
2137
|
-
const weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
2138
|
-
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2139
|
-
}
|
|
2140
|
-
const amountsInBin = [];
|
|
2141
|
-
if (!isSingleSideX) {
|
|
2142
|
-
if (minBinId <= activeId) {
|
|
2143
|
-
const weights = toWeightDecendingOrder(minBinId, activeId);
|
|
2144
|
-
const amounts = toAmountBidSide(activeId, amountY, weights);
|
|
2145
|
-
for (const bin of amounts) {
|
|
2146
|
-
amountsInBin.push({
|
|
2147
|
-
binId: bin.binId,
|
|
2148
|
-
amountX: new BN10(0),
|
|
2149
|
-
amountY: bin.amount
|
|
2150
|
-
});
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
if (activeId < maxBinId) {
|
|
2154
|
-
const weights = toWeightAscendingOrder(activeId + 1, maxBinId);
|
|
2155
|
-
const amounts = toAmountAskSide(activeId, binStep, amountX, weights);
|
|
2156
|
-
for (const bin of amounts) {
|
|
2157
|
-
amountsInBin.push({
|
|
2158
|
-
binId: bin.binId,
|
|
2159
|
-
amountX: bin.amount,
|
|
2160
|
-
amountY: new BN10(0)
|
|
2161
|
-
});
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
} else {
|
|
2165
|
-
if (minBinId < activeId) {
|
|
2166
|
-
const weights = toWeightDecendingOrder(minBinId, activeId - 1);
|
|
2167
|
-
const amountsIntoBidSide = toAmountBidSide(activeId, amountY, weights);
|
|
2168
|
-
for (const bin of amountsIntoBidSide) {
|
|
2169
|
-
amountsInBin.push({
|
|
2170
|
-
binId: bin.binId,
|
|
2171
|
-
amountX: new BN10(0),
|
|
2172
|
-
amountY: bin.amount
|
|
2173
|
-
});
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
if (activeId <= maxBinId) {
|
|
2177
|
-
const weights = toWeightAscendingOrder(activeId, maxBinId);
|
|
2178
|
-
const amountsIntoAskSide = toAmountAskSide(activeId, binStep, amountX, weights);
|
|
2179
|
-
for (const bin of amountsIntoAskSide) {
|
|
2180
|
-
amountsInBin.push({
|
|
2181
|
-
binId: bin.binId,
|
|
2182
|
-
amountX: bin.amount,
|
|
2183
|
-
amountY: new BN10(0)
|
|
2184
|
-
});
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
return amountsInBin;
|
|
1994
|
+
case 1 /* Spot */: {
|
|
1995
|
+
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
1996
|
+
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
1997
|
+
}
|
|
1998
|
+
case 2 /* Curve */: {
|
|
1999
|
+
const weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
2000
|
+
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2001
|
+
}
|
|
2002
|
+
case 3 /* BidAsk */: {
|
|
2003
|
+
const weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
2004
|
+
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2189
2005
|
}
|
|
2190
2006
|
default:
|
|
2191
2007
|
throw new Error(`Unsupported strategy type: ${strategyType}`);
|
|
@@ -2245,7 +2061,7 @@ function getCoinXYForLiquidity(liquidity, reserveInSize, reserveOutSize, lpSuply
|
|
|
2245
2061
|
}
|
|
2246
2062
|
|
|
2247
2063
|
// src/math/percentage.ts
|
|
2248
|
-
import
|
|
2064
|
+
import BN10 from "bn.js";
|
|
2249
2065
|
var Percentage = class {
|
|
2250
2066
|
numerator;
|
|
2251
2067
|
denominator;
|
|
@@ -2273,8 +2089,8 @@ var Percentage = class {
|
|
|
2273
2089
|
* @returns
|
|
2274
2090
|
*/
|
|
2275
2091
|
static fromFraction(numerator, denominator) {
|
|
2276
|
-
const num = typeof numerator === "number" ? new
|
|
2277
|
-
const denom = typeof denominator === "number" ? new
|
|
2092
|
+
const num = typeof numerator === "number" ? new BN10(numerator.toString()) : numerator;
|
|
2093
|
+
const denom = typeof denominator === "number" ? new BN10(denominator.toString()) : denominator;
|
|
2278
2094
|
return new Percentage(num, denom);
|
|
2279
2095
|
}
|
|
2280
2096
|
};
|
|
@@ -2374,7 +2190,7 @@ function adjustForCoinSlippage(tokenAmount, slippage, adjustUp) {
|
|
|
2374
2190
|
}
|
|
2375
2191
|
|
|
2376
2192
|
// src/math/SplitSwap.ts
|
|
2377
|
-
import
|
|
2193
|
+
import BN11 from "bn.js";
|
|
2378
2194
|
var SplitUnit = /* @__PURE__ */ ((SplitUnit2) => {
|
|
2379
2195
|
SplitUnit2[SplitUnit2["FIVE"] = 5] = "FIVE";
|
|
2380
2196
|
SplitUnit2[SplitUnit2["TEN"] = 10] = "TEN";
|
|
@@ -2432,7 +2248,7 @@ function updateSplitSwapResult(maxIndex, currentIndex, splitSwapResult, stepResu
|
|
|
2432
2248
|
return splitSwapResult;
|
|
2433
2249
|
}
|
|
2434
2250
|
function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
2435
|
-
let currentLiquidity = new
|
|
2251
|
+
let currentLiquidity = new BN11(poolData.liquidity);
|
|
2436
2252
|
let { currentSqrtPrice } = poolData;
|
|
2437
2253
|
let splitSwapResult = {
|
|
2438
2254
|
amountInArray: [],
|
|
@@ -2495,7 +2311,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
|
2495
2311
|
targetSqrtPrice,
|
|
2496
2312
|
currentLiquidity,
|
|
2497
2313
|
remainerAmount,
|
|
2498
|
-
new
|
|
2314
|
+
new BN11(poolData.feeRate),
|
|
2499
2315
|
byAmountIn
|
|
2500
2316
|
);
|
|
2501
2317
|
tempStepResult = stepResult;
|
|
@@ -2507,7 +2323,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
|
2507
2323
|
splitSwapResult.amountOutArray[i] = splitSwapResult.amountOutArray[i].add(stepResult.amountOut);
|
|
2508
2324
|
splitSwapResult.feeAmountArray[i] = splitSwapResult.feeAmountArray[i].add(stepResult.feeAmount);
|
|
2509
2325
|
if (stepResult.nextSqrtPrice.eq(tick.sqrtPrice)) {
|
|
2510
|
-
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new
|
|
2326
|
+
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new BN11(-1)) : tick.liquidityNet;
|
|
2511
2327
|
currentLiquidity = signedLiquidityChange.gt(ZERO) ? currentLiquidity.add(signedLiquidityChange) : currentLiquidity.sub(signedLiquidityChange.abs());
|
|
2512
2328
|
currentSqrtPrice = tick.sqrtPrice;
|
|
2513
2329
|
} else {
|
|
@@ -2532,7 +2348,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
|
2532
2348
|
break;
|
|
2533
2349
|
}
|
|
2534
2350
|
if (tempStepResult.nextSqrtPrice.eq(tick.sqrtPrice)) {
|
|
2535
|
-
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new
|
|
2351
|
+
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new BN11(-1)) : tick.liquidityNet;
|
|
2536
2352
|
currentLiquidity = signedLiquidityChange.gt(ZERO) ? currentLiquidity.add(signedLiquidityChange) : currentLiquidity.sub(signedLiquidityChange.abs());
|
|
2537
2353
|
currentSqrtPrice = tick.sqrtPrice;
|
|
2538
2354
|
} else {
|
|
@@ -2757,7 +2573,7 @@ function buildPool(objects) {
|
|
|
2757
2573
|
const rewarders = [];
|
|
2758
2574
|
fields.rewarder_manager.fields.rewarders.forEach((item) => {
|
|
2759
2575
|
const { emissions_per_second } = item.fields;
|
|
2760
|
-
const emissionSeconds = MathUtil.fromX64(new
|
|
2576
|
+
const emissionSeconds = MathUtil.fromX64(new BN12(emissions_per_second));
|
|
2761
2577
|
const emissionsEveryDay = Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24);
|
|
2762
2578
|
rewarders.push({
|
|
2763
2579
|
emissions_per_second,
|
|
@@ -2949,11 +2765,11 @@ function buildTickData(objects) {
|
|
|
2949
2765
|
const possition = {
|
|
2950
2766
|
objectId: getObjectId(objects),
|
|
2951
2767
|
index: asIntN(BigInt(valueItem.index.fields.bits)),
|
|
2952
|
-
sqrtPrice: new
|
|
2953
|
-
liquidityNet: new
|
|
2954
|
-
liquidityGross: new
|
|
2955
|
-
feeGrowthOutsideA: new
|
|
2956
|
-
feeGrowthOutsideB: new
|
|
2768
|
+
sqrtPrice: new BN12(valueItem.sqrt_price),
|
|
2769
|
+
liquidityNet: new BN12(valueItem.liquidity_net.fields.bits),
|
|
2770
|
+
liquidityGross: new BN12(valueItem.liquidity_gross),
|
|
2771
|
+
feeGrowthOutsideA: new BN12(valueItem.fee_growth_outside_a),
|
|
2772
|
+
feeGrowthOutsideB: new BN12(valueItem.fee_growth_outside_b),
|
|
2957
2773
|
rewardersGrowthOutside: valueItem.rewards_growth_outside
|
|
2958
2774
|
};
|
|
2959
2775
|
return possition;
|
|
@@ -2963,11 +2779,11 @@ function buildTickDataByEvent(fields) {
|
|
|
2963
2779
|
throw new ClmmpoolsError(`Invalid tick fields.`, "InvalidTickFields" /* InvalidTickFields */);
|
|
2964
2780
|
}
|
|
2965
2781
|
const index = asIntN(BigInt(fields.index.bits));
|
|
2966
|
-
const sqrtPrice = new
|
|
2967
|
-
const liquidityNet = new
|
|
2968
|
-
const liquidityGross = new
|
|
2969
|
-
const feeGrowthOutsideA = new
|
|
2970
|
-
const feeGrowthOutsideB = new
|
|
2782
|
+
const sqrtPrice = new BN12(fields.sqrt_price);
|
|
2783
|
+
const liquidityNet = new BN12(fields.liquidity_net.bits);
|
|
2784
|
+
const liquidityGross = new BN12(fields.liquidity_gross);
|
|
2785
|
+
const feeGrowthOutsideA = new BN12(fields.fee_growth_outside_a);
|
|
2786
|
+
const feeGrowthOutsideB = new BN12(fields.fee_growth_outside_b);
|
|
2971
2787
|
const rewardersGrowthOutside = fields.rewards_growth_outside || [];
|
|
2972
2788
|
const tick = {
|
|
2973
2789
|
objectId: "",
|
|
@@ -2986,7 +2802,7 @@ function buildClmmPositionName(pool_index, position_index) {
|
|
|
2986
2802
|
}
|
|
2987
2803
|
|
|
2988
2804
|
// src/utils/tick.ts
|
|
2989
|
-
import
|
|
2805
|
+
import BN13 from "bn.js";
|
|
2990
2806
|
var TickUtil = class {
|
|
2991
2807
|
/**
|
|
2992
2808
|
* Get min tick index.
|
|
@@ -3026,22 +2842,22 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
|
|
|
3026
2842
|
let rewarder_growth_below = growthGlobal[i];
|
|
3027
2843
|
if (tickLower !== null) {
|
|
3028
2844
|
if (pool.current_tick_index < tickLowerIndex) {
|
|
3029
|
-
rewarder_growth_below = growthGlobal[i].sub(new
|
|
2845
|
+
rewarder_growth_below = growthGlobal[i].sub(new BN13(tickLower.rewardersGrowthOutside[i]));
|
|
3030
2846
|
} else {
|
|
3031
2847
|
rewarder_growth_below = tickLower.rewardersGrowthOutside[i];
|
|
3032
2848
|
}
|
|
3033
2849
|
}
|
|
3034
|
-
let rewarder_growth_above = new
|
|
2850
|
+
let rewarder_growth_above = new BN13(0);
|
|
3035
2851
|
if (tickUpper !== null) {
|
|
3036
2852
|
if (pool.current_tick_index >= tickUpperIndex) {
|
|
3037
|
-
rewarder_growth_above = growthGlobal[i].sub(new
|
|
2853
|
+
rewarder_growth_above = growthGlobal[i].sub(new BN13(tickUpper.rewardersGrowthOutside[i]));
|
|
3038
2854
|
} else {
|
|
3039
2855
|
rewarder_growth_above = tickUpper.rewardersGrowthOutside[i];
|
|
3040
2856
|
}
|
|
3041
2857
|
}
|
|
3042
2858
|
const rewGrowthInside = MathUtil.subUnderflowU128(
|
|
3043
|
-
MathUtil.subUnderflowU128(new
|
|
3044
|
-
new
|
|
2859
|
+
MathUtil.subUnderflowU128(new BN13(growthGlobal[i]), new BN13(rewarder_growth_below)),
|
|
2860
|
+
new BN13(rewarder_growth_above)
|
|
3045
2861
|
);
|
|
3046
2862
|
rewarderGrowthInside.push(rewGrowthInside);
|
|
3047
2863
|
}
|
|
@@ -3049,7 +2865,7 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
|
|
|
3049
2865
|
}
|
|
3050
2866
|
|
|
3051
2867
|
// src/utils/transaction-util.ts
|
|
3052
|
-
import
|
|
2868
|
+
import BN14 from "bn.js";
|
|
3053
2869
|
import Decimal7 from "decimal.js";
|
|
3054
2870
|
import { Transaction } from "@mysten/sui/transactions";
|
|
3055
2871
|
function findAdjustCoin(coinPair) {
|
|
@@ -3358,7 +3174,7 @@ var _TransactionUtil = class {
|
|
|
3358
3174
|
const liquidityInput = ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts(
|
|
3359
3175
|
Number(params.tick_lower),
|
|
3360
3176
|
Number(params.tick_upper),
|
|
3361
|
-
new
|
|
3177
|
+
new BN14(coinAmount),
|
|
3362
3178
|
params.fix_amount_a,
|
|
3363
3179
|
true,
|
|
3364
3180
|
slippage,
|
|
@@ -4426,7 +4242,7 @@ var _TransactionUtil = class {
|
|
|
4426
4242
|
const basePath = splitPath.basePaths[i];
|
|
4427
4243
|
a2b.push(basePath.direction);
|
|
4428
4244
|
poolAddress.push(basePath.poolAddress);
|
|
4429
|
-
rawAmountLimit.push(new
|
|
4245
|
+
rawAmountLimit.push(new BN14(basePath.inputAmount.toString()));
|
|
4430
4246
|
if (i === 0) {
|
|
4431
4247
|
coinType.push(basePath.fromCoin, basePath.toCoin);
|
|
4432
4248
|
} else {
|
|
@@ -4434,8 +4250,8 @@ var _TransactionUtil = class {
|
|
|
4434
4250
|
}
|
|
4435
4251
|
}
|
|
4436
4252
|
const onePath = {
|
|
4437
|
-
amountIn: new
|
|
4438
|
-
amountOut: new
|
|
4253
|
+
amountIn: new BN14(splitPath.inputAmount.toString()),
|
|
4254
|
+
amountOut: new BN14(splitPath.outputAmount.toString()),
|
|
4439
4255
|
poolAddress,
|
|
4440
4256
|
a2b,
|
|
4441
4257
|
rawAmountLimit,
|
|
@@ -4792,9 +4608,9 @@ var TxBlock = class {
|
|
|
4792
4608
|
};
|
|
4793
4609
|
|
|
4794
4610
|
// src/utils/deepbook-utils.ts
|
|
4795
|
-
import
|
|
4611
|
+
import BN15 from "bn.js";
|
|
4796
4612
|
import { Transaction as Transaction3 } from "@mysten/sui/transactions";
|
|
4797
|
-
var FLOAT_SCALING = new
|
|
4613
|
+
var FLOAT_SCALING = new BN15(1e9);
|
|
4798
4614
|
var DeepbookUtils = class {
|
|
4799
4615
|
static createAccountCap(senderAddress, sdkOptions, tx, isTransfer = false) {
|
|
4800
4616
|
if (senderAddress.length === 0) {
|
|
@@ -4940,9 +4756,9 @@ var DeepbookUtils = class {
|
|
|
4940
4756
|
static async preSwap(sdk, pool, a2b, amountIn) {
|
|
4941
4757
|
let isExceed = false;
|
|
4942
4758
|
let amountOut = ZERO;
|
|
4943
|
-
let remainAmount = new
|
|
4759
|
+
let remainAmount = new BN15(amountIn);
|
|
4944
4760
|
let feeAmount = ZERO;
|
|
4945
|
-
const initAmountIn = new
|
|
4761
|
+
const initAmountIn = new BN15(amountIn);
|
|
4946
4762
|
if (a2b) {
|
|
4947
4763
|
let bids = await this.getPoolBids(sdk, pool.poolID, pool.baseAsset, pool.quoteAsset);
|
|
4948
4764
|
if (bids === null) {
|
|
@@ -4952,16 +4768,16 @@ var DeepbookUtils = class {
|
|
|
4952
4768
|
return b.price - a.price;
|
|
4953
4769
|
});
|
|
4954
4770
|
for (let i = 0; i < bids.length; i += 1) {
|
|
4955
|
-
const curBidAmount = new
|
|
4956
|
-
const curBidPrice = new
|
|
4957
|
-
const fee = curBidAmount.mul(new
|
|
4771
|
+
const curBidAmount = new BN15(bids[i].quantity);
|
|
4772
|
+
const curBidPrice = new BN15(bids[i].price);
|
|
4773
|
+
const fee = curBidAmount.mul(new BN15(curBidPrice)).mul(new BN15(pool.takerFeeRate)).div(FLOAT_SCALING).div(FLOAT_SCALING);
|
|
4958
4774
|
if (remainAmount.gt(curBidAmount)) {
|
|
4959
4775
|
remainAmount = remainAmount.sub(curBidAmount);
|
|
4960
4776
|
amountOut = amountOut.add(curBidAmount.mul(curBidPrice).div(FLOAT_SCALING).sub(fee));
|
|
4961
4777
|
feeAmount = feeAmount.add(fee);
|
|
4962
4778
|
} else {
|
|
4963
|
-
const curOut = remainAmount.mul(new
|
|
4964
|
-
const curFee = curOut.mul(new
|
|
4779
|
+
const curOut = remainAmount.mul(new BN15(bids[i].price)).div(FLOAT_SCALING);
|
|
4780
|
+
const curFee = curOut.mul(new BN15(pool.takerFeeRate)).div(FLOAT_SCALING);
|
|
4965
4781
|
amountOut = amountOut.add(curOut.sub(curFee));
|
|
4966
4782
|
remainAmount = remainAmount.sub(remainAmount);
|
|
4967
4783
|
feeAmount = feeAmount.add(curFee);
|
|
@@ -4976,15 +4792,15 @@ var DeepbookUtils = class {
|
|
|
4976
4792
|
isExceed = true;
|
|
4977
4793
|
}
|
|
4978
4794
|
for (let i = 0; i < asks.length; i += 1) {
|
|
4979
|
-
const curAskAmount = new
|
|
4980
|
-
const fee = curAskAmount.mul(new
|
|
4795
|
+
const curAskAmount = new BN15(asks[i].price).mul(new BN15(asks[i].quantity)).div(new BN15(1e9));
|
|
4796
|
+
const fee = curAskAmount.mul(new BN15(pool.takerFeeRate)).div(FLOAT_SCALING);
|
|
4981
4797
|
const curAskAmountWithFee = curAskAmount.add(fee);
|
|
4982
4798
|
if (remainAmount.gt(curAskAmount)) {
|
|
4983
|
-
amountOut = amountOut.add(new
|
|
4799
|
+
amountOut = amountOut.add(new BN15(asks[i].quantity));
|
|
4984
4800
|
remainAmount = remainAmount.sub(curAskAmountWithFee);
|
|
4985
4801
|
feeAmount = feeAmount.add(fee);
|
|
4986
4802
|
} else {
|
|
4987
|
-
const splitNums = new
|
|
4803
|
+
const splitNums = new BN15(asks[i].quantity).div(new BN15(pool.lotSize));
|
|
4988
4804
|
const splitAmount = curAskAmountWithFee.div(splitNums);
|
|
4989
4805
|
const swapSplitNum = remainAmount.div(splitAmount);
|
|
4990
4806
|
amountOut = amountOut.add(swapSplitNum.muln(pool.lotSize));
|
|
@@ -5845,7 +5661,7 @@ var PoolModule = class {
|
|
|
5845
5661
|
};
|
|
5846
5662
|
|
|
5847
5663
|
// src/modules/positionModule.ts
|
|
5848
|
-
import
|
|
5664
|
+
import BN16 from "bn.js";
|
|
5849
5665
|
import { Transaction as Transaction5 } from "@mysten/sui/transactions";
|
|
5850
5666
|
import { isValidSuiObjectId } from "@mysten/sui/utils";
|
|
5851
5667
|
var PositionModule = class {
|
|
@@ -6067,8 +5883,8 @@ var PositionModule = class {
|
|
|
6067
5883
|
for (let i = 0; i < valueData.length; i += 1) {
|
|
6068
5884
|
const { parsedJson } = valueData[i];
|
|
6069
5885
|
const posRrewarderResult = {
|
|
6070
|
-
feeOwedA: new
|
|
6071
|
-
feeOwedB: new
|
|
5886
|
+
feeOwedA: new BN16(parsedJson.fee_owned_a),
|
|
5887
|
+
feeOwedB: new BN16(parsedJson.fee_owned_b),
|
|
6072
5888
|
position_id: parsedJson.position_id
|
|
6073
5889
|
};
|
|
6074
5890
|
result.push(posRrewarderResult);
|
|
@@ -6444,7 +6260,7 @@ var PositionModule = class {
|
|
|
6444
6260
|
};
|
|
6445
6261
|
|
|
6446
6262
|
// src/modules/rewarderModule.ts
|
|
6447
|
-
import
|
|
6263
|
+
import BN17 from "bn.js";
|
|
6448
6264
|
import { Transaction as Transaction6 } from "@mysten/sui/transactions";
|
|
6449
6265
|
var RewarderModule = class {
|
|
6450
6266
|
_sdk;
|
|
@@ -6470,7 +6286,7 @@ var RewarderModule = class {
|
|
|
6470
6286
|
}
|
|
6471
6287
|
const emissionsEveryDay = [];
|
|
6472
6288
|
for (const rewarderInfo of rewarderInfos) {
|
|
6473
|
-
const emissionSeconds = MathUtil.fromX64(new
|
|
6289
|
+
const emissionSeconds = MathUtil.fromX64(new BN17(rewarderInfo.emissions_per_second));
|
|
6474
6290
|
emissionsEveryDay.push({
|
|
6475
6291
|
emissions: Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24),
|
|
6476
6292
|
coin_address: rewarderInfo.coinAddress
|
|
@@ -6489,20 +6305,20 @@ var RewarderModule = class {
|
|
|
6489
6305
|
const currentPool = await this.sdk.Pool.getPool(poolID);
|
|
6490
6306
|
const lastTime = currentPool.rewarder_last_updated_time;
|
|
6491
6307
|
currentPool.rewarder_last_updated_time = currentTime.toString();
|
|
6492
|
-
if (Number(currentPool.liquidity) === 0 || currentTime.eq(new
|
|
6308
|
+
if (Number(currentPool.liquidity) === 0 || currentTime.eq(new BN17(lastTime))) {
|
|
6493
6309
|
return currentPool;
|
|
6494
6310
|
}
|
|
6495
|
-
const timeDelta = currentTime.div(new
|
|
6311
|
+
const timeDelta = currentTime.div(new BN17(1e3)).sub(new BN17(lastTime)).add(new BN17(15));
|
|
6496
6312
|
const rewarderInfos = currentPool.rewarder_infos;
|
|
6497
6313
|
for (let i = 0; i < rewarderInfos.length; i += 1) {
|
|
6498
6314
|
const rewarderInfo = rewarderInfos[i];
|
|
6499
6315
|
const rewarderGrowthDelta = MathUtil.checkMulDivFloor(
|
|
6500
6316
|
timeDelta,
|
|
6501
|
-
new
|
|
6502
|
-
new
|
|
6317
|
+
new BN17(rewarderInfo.emissions_per_second),
|
|
6318
|
+
new BN17(currentPool.liquidity),
|
|
6503
6319
|
128
|
|
6504
6320
|
);
|
|
6505
|
-
this.growthGlobal[i] = new
|
|
6321
|
+
this.growthGlobal[i] = new BN17(rewarderInfo.growth_global).add(new BN17(rewarderGrowthDelta));
|
|
6506
6322
|
}
|
|
6507
6323
|
return currentPool;
|
|
6508
6324
|
}
|
|
@@ -6517,7 +6333,7 @@ var RewarderModule = class {
|
|
|
6517
6333
|
*/
|
|
6518
6334
|
async posRewardersAmount(poolID, positionHandle, positionID) {
|
|
6519
6335
|
const currentTime = Date.parse((/* @__PURE__ */ new Date()).toString());
|
|
6520
|
-
const pool = await this.updatePoolRewarder(poolID, new
|
|
6336
|
+
const pool = await this.updatePoolRewarder(poolID, new BN17(currentTime));
|
|
6521
6337
|
const position = await this.sdk.Position.getPositionRewarders(positionHandle, positionID);
|
|
6522
6338
|
if (position === void 0) {
|
|
6523
6339
|
return [];
|
|
@@ -6538,7 +6354,7 @@ var RewarderModule = class {
|
|
|
6538
6354
|
*/
|
|
6539
6355
|
async poolRewardersAmount(accountAddress, poolID) {
|
|
6540
6356
|
const currentTime = Date.parse((/* @__PURE__ */ new Date()).toString());
|
|
6541
|
-
const pool = await this.updatePoolRewarder(poolID, new
|
|
6357
|
+
const pool = await this.updatePoolRewarder(poolID, new BN17(currentTime));
|
|
6542
6358
|
const positions = await this.sdk.Position.getPositionList(accountAddress, [poolID]);
|
|
6543
6359
|
const tickDatas = await this.getPoolLowerAndUpperTicks(pool.ticks_handle, positions);
|
|
6544
6360
|
const rewarderAmount = [ZERO, ZERO, ZERO];
|
|
@@ -6565,38 +6381,38 @@ var RewarderModule = class {
|
|
|
6565
6381
|
const growthInside = [];
|
|
6566
6382
|
const AmountOwed = [];
|
|
6567
6383
|
if (rewardersInside.length > 0) {
|
|
6568
|
-
let growthDelta0 = MathUtil.subUnderflowU128(rewardersInside[0], new
|
|
6569
|
-
if (growthDelta0.gt(new
|
|
6384
|
+
let growthDelta0 = MathUtil.subUnderflowU128(rewardersInside[0], new BN17(position.reward_growth_inside_0));
|
|
6385
|
+
if (growthDelta0.gt(new BN17("3402823669209384634633745948738404"))) {
|
|
6570
6386
|
growthDelta0 = ONE;
|
|
6571
6387
|
}
|
|
6572
|
-
const amountOwed_0 = MathUtil.checkMulShiftRight(new
|
|
6388
|
+
const amountOwed_0 = MathUtil.checkMulShiftRight(new BN17(position.liquidity), growthDelta0, 64, 128);
|
|
6573
6389
|
growthInside.push(rewardersInside[0]);
|
|
6574
6390
|
AmountOwed.push({
|
|
6575
|
-
amount_owed: new
|
|
6391
|
+
amount_owed: new BN17(position.reward_amount_owed_0).add(amountOwed_0),
|
|
6576
6392
|
coin_address: pool.rewarder_infos[0].coinAddress
|
|
6577
6393
|
});
|
|
6578
6394
|
}
|
|
6579
6395
|
if (rewardersInside.length > 1) {
|
|
6580
|
-
let growthDelta_1 = MathUtil.subUnderflowU128(rewardersInside[1], new
|
|
6581
|
-
if (growthDelta_1.gt(new
|
|
6396
|
+
let growthDelta_1 = MathUtil.subUnderflowU128(rewardersInside[1], new BN17(position.reward_growth_inside_1));
|
|
6397
|
+
if (growthDelta_1.gt(new BN17("3402823669209384634633745948738404"))) {
|
|
6582
6398
|
growthDelta_1 = ONE;
|
|
6583
6399
|
}
|
|
6584
|
-
const amountOwed_1 = MathUtil.checkMulShiftRight(new
|
|
6400
|
+
const amountOwed_1 = MathUtil.checkMulShiftRight(new BN17(position.liquidity), growthDelta_1, 64, 128);
|
|
6585
6401
|
growthInside.push(rewardersInside[1]);
|
|
6586
6402
|
AmountOwed.push({
|
|
6587
|
-
amount_owed: new
|
|
6403
|
+
amount_owed: new BN17(position.reward_amount_owed_1).add(amountOwed_1),
|
|
6588
6404
|
coin_address: pool.rewarder_infos[1].coinAddress
|
|
6589
6405
|
});
|
|
6590
6406
|
}
|
|
6591
6407
|
if (rewardersInside.length > 2) {
|
|
6592
|
-
let growthDelta_2 = MathUtil.subUnderflowU128(rewardersInside[2], new
|
|
6593
|
-
if (growthDelta_2.gt(new
|
|
6408
|
+
let growthDelta_2 = MathUtil.subUnderflowU128(rewardersInside[2], new BN17(position.reward_growth_inside_2));
|
|
6409
|
+
if (growthDelta_2.gt(new BN17("3402823669209384634633745948738404"))) {
|
|
6594
6410
|
growthDelta_2 = ONE;
|
|
6595
6411
|
}
|
|
6596
|
-
const amountOwed_2 = MathUtil.checkMulShiftRight(new
|
|
6412
|
+
const amountOwed_2 = MathUtil.checkMulShiftRight(new BN17(position.liquidity), growthDelta_2, 64, 128);
|
|
6597
6413
|
growthInside.push(rewardersInside[2]);
|
|
6598
6414
|
AmountOwed.push({
|
|
6599
|
-
amount_owed: new
|
|
6415
|
+
amount_owed: new BN17(position.reward_amount_owed_2).add(amountOwed_2),
|
|
6600
6416
|
coin_address: pool.rewarder_infos[2].coinAddress
|
|
6601
6417
|
});
|
|
6602
6418
|
}
|
|
@@ -6710,8 +6526,8 @@ var RewarderModule = class {
|
|
|
6710
6526
|
for (let i = 0; i < valueData.length; i += 1) {
|
|
6711
6527
|
const { parsedJson } = valueData[i];
|
|
6712
6528
|
const posRrewarderResult = {
|
|
6713
|
-
feeOwedA: new
|
|
6714
|
-
feeOwedB: new
|
|
6529
|
+
feeOwedA: new BN17(parsedJson.fee_owned_a),
|
|
6530
|
+
feeOwedB: new BN17(parsedJson.fee_owned_b),
|
|
6715
6531
|
position_id: parsedJson.position_id
|
|
6716
6532
|
};
|
|
6717
6533
|
result.push(posRrewarderResult);
|
|
@@ -6774,7 +6590,7 @@ var RewarderModule = class {
|
|
|
6774
6590
|
};
|
|
6775
6591
|
for (let j = 0; j < params[i].rewarderInfo.length; j += 1) {
|
|
6776
6592
|
posRrewarderResult.rewarderAmountOwed.push({
|
|
6777
|
-
amount_owed: new
|
|
6593
|
+
amount_owed: new BN17(valueData[i].parsedJson.data[j]),
|
|
6778
6594
|
coin_address: params[i].rewarderInfo[j].coinAddress
|
|
6779
6595
|
});
|
|
6780
6596
|
}
|
|
@@ -6963,7 +6779,7 @@ var RewarderModule = class {
|
|
|
6963
6779
|
};
|
|
6964
6780
|
|
|
6965
6781
|
// src/modules/routerModule.ts
|
|
6966
|
-
import
|
|
6782
|
+
import BN18 from "bn.js";
|
|
6967
6783
|
import { Graph, GraphEdge, GraphVertex } from "@syntsugar/cc-graph";
|
|
6968
6784
|
import { Transaction as Transaction7 } from "@mysten/sui/transactions";
|
|
6969
6785
|
function _pairSymbol(base, quote) {
|
|
@@ -7245,8 +7061,8 @@ var RouterModule = class {
|
|
|
7245
7061
|
if (swapWithMultiPoolParams != null) {
|
|
7246
7062
|
const preSwapResult2 = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
|
|
7247
7063
|
const onePath2 = {
|
|
7248
|
-
amountIn: new
|
|
7249
|
-
amountOut: new
|
|
7064
|
+
amountIn: new BN18(preSwapResult2.estimatedAmountIn),
|
|
7065
|
+
amountOut: new BN18(preSwapResult2.estimatedAmountOut),
|
|
7250
7066
|
poolAddress: [preSwapResult2.poolAddress],
|
|
7251
7067
|
a2b: [preSwapResult2.aToB],
|
|
7252
7068
|
rawAmountLimit: byAmountIn ? [preSwapResult2.estimatedAmountOut] : [preSwapResult2.estimatedAmountIn],
|
|
@@ -7259,8 +7075,8 @@ var RouterModule = class {
|
|
|
7259
7075
|
priceSlippagePoint
|
|
7260
7076
|
};
|
|
7261
7077
|
const result2 = {
|
|
7262
|
-
amountIn: new
|
|
7263
|
-
amountOut: new
|
|
7078
|
+
amountIn: new BN18(preSwapResult2.estimatedAmountIn),
|
|
7079
|
+
amountOut: new BN18(preSwapResult2.estimatedAmountOut),
|
|
7264
7080
|
paths: [onePath2],
|
|
7265
7081
|
a2b: preSwapResult2.aToB,
|
|
7266
7082
|
b2c: void 0,
|
|
@@ -7282,8 +7098,8 @@ var RouterModule = class {
|
|
|
7282
7098
|
if (swapWithMultiPoolParams != null) {
|
|
7283
7099
|
const preSwapResult2 = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
|
|
7284
7100
|
const onePath2 = {
|
|
7285
|
-
amountIn: new
|
|
7286
|
-
amountOut: new
|
|
7101
|
+
amountIn: new BN18(preSwapResult2.estimatedAmountIn),
|
|
7102
|
+
amountOut: new BN18(preSwapResult2.estimatedAmountOut),
|
|
7287
7103
|
poolAddress: [preSwapResult2.poolAddress],
|
|
7288
7104
|
a2b: [preSwapResult2.aToB],
|
|
7289
7105
|
rawAmountLimit: byAmountIn ? [preSwapResult2.estimatedAmountOut] : [preSwapResult2.estimatedAmountIn],
|
|
@@ -7296,8 +7112,8 @@ var RouterModule = class {
|
|
|
7296
7112
|
priceSlippagePoint
|
|
7297
7113
|
};
|
|
7298
7114
|
const result3 = {
|
|
7299
|
-
amountIn: new
|
|
7300
|
-
amountOut: new
|
|
7115
|
+
amountIn: new BN18(preSwapResult2.estimatedAmountIn),
|
|
7116
|
+
amountOut: new BN18(preSwapResult2.estimatedAmountOut),
|
|
7301
7117
|
paths: [onePath2],
|
|
7302
7118
|
a2b: preSwapResult2.aToB,
|
|
7303
7119
|
b2c: void 0,
|
|
@@ -7378,8 +7194,8 @@ var RouterModule = class {
|
|
|
7378
7194
|
if (swapWithMultiPoolParams != null) {
|
|
7379
7195
|
const preSwapResult = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
|
|
7380
7196
|
const onePath = {
|
|
7381
|
-
amountIn: new
|
|
7382
|
-
amountOut: new
|
|
7197
|
+
amountIn: new BN18(preSwapResult.estimatedAmountIn),
|
|
7198
|
+
amountOut: new BN18(preSwapResult.estimatedAmountOut),
|
|
7383
7199
|
poolAddress: [preSwapResult.poolAddress],
|
|
7384
7200
|
a2b: [preSwapResult.aToB],
|
|
7385
7201
|
rawAmountLimit: byAmountIn ? [preSwapResult.estimatedAmountOut] : [preSwapResult.estimatedAmountIn],
|
|
@@ -7392,8 +7208,8 @@ var RouterModule = class {
|
|
|
7392
7208
|
priceSlippagePoint
|
|
7393
7209
|
};
|
|
7394
7210
|
const result = {
|
|
7395
|
-
amountIn: new
|
|
7396
|
-
amountOut: new
|
|
7211
|
+
amountIn: new BN18(preSwapResult.estimatedAmountIn),
|
|
7212
|
+
amountOut: new BN18(preSwapResult.estimatedAmountOut),
|
|
7397
7213
|
paths: [onePath],
|
|
7398
7214
|
a2b: preSwapResult.aToB,
|
|
7399
7215
|
b2c: void 0,
|
|
@@ -7477,13 +7293,13 @@ var RouterModule = class {
|
|
|
7477
7293
|
continue;
|
|
7478
7294
|
}
|
|
7479
7295
|
if (params[0].byAmountIn) {
|
|
7480
|
-
const amount = new
|
|
7296
|
+
const amount = new BN18(valueData[i].parsedJson.data.amount_out);
|
|
7481
7297
|
if (amount.gt(tempMaxAmount)) {
|
|
7482
7298
|
tempIndex = i;
|
|
7483
7299
|
tempMaxAmount = amount;
|
|
7484
7300
|
}
|
|
7485
7301
|
} else {
|
|
7486
|
-
const amount = params[i].stepNums > 1 ? new
|
|
7302
|
+
const amount = params[i].stepNums > 1 ? new BN18(valueData[i].parsedJson.data.amount_in) : new BN18(valueData[i].parsedJson.data.amount_in).add(new BN18(valueData[i].parsedJson.data.fee_amount));
|
|
7487
7303
|
if (amount.lt(tempMaxAmount)) {
|
|
7488
7304
|
tempIndex = i;
|
|
7489
7305
|
tempMaxAmount = amount;
|
|
@@ -7553,7 +7369,7 @@ var RouterModule = class {
|
|
|
7553
7369
|
};
|
|
7554
7370
|
|
|
7555
7371
|
// src/modules/swapModule.ts
|
|
7556
|
-
import
|
|
7372
|
+
import BN19 from "bn.js";
|
|
7557
7373
|
import Decimal8 from "decimal.js";
|
|
7558
7374
|
import { Transaction as Transaction8 } from "@mysten/sui/transactions";
|
|
7559
7375
|
var AMM_SWAP_MODULE = "amm_swap";
|
|
@@ -7669,13 +7485,13 @@ var SwapModule = class {
|
|
|
7669
7485
|
continue;
|
|
7670
7486
|
}
|
|
7671
7487
|
if (params.byAmountIn) {
|
|
7672
|
-
const amount = new
|
|
7488
|
+
const amount = new BN19(valueData[i].parsedJson.data.amount_out);
|
|
7673
7489
|
if (amount.gt(tempMaxAmount)) {
|
|
7674
7490
|
tempIndex = i;
|
|
7675
7491
|
tempMaxAmount = amount;
|
|
7676
7492
|
}
|
|
7677
7493
|
} else {
|
|
7678
|
-
const amount = new
|
|
7494
|
+
const amount = new BN19(valueData[i].parsedJson.data.amount_out);
|
|
7679
7495
|
if (amount.lt(tempMaxAmount)) {
|
|
7680
7496
|
tempIndex = i;
|
|
7681
7497
|
tempMaxAmount = amount;
|
|
@@ -7739,7 +7555,7 @@ var SwapModule = class {
|
|
|
7739
7555
|
return this.transformSwapData(params, valueData[0].parsedJson.data);
|
|
7740
7556
|
}
|
|
7741
7557
|
transformSwapData(params, data) {
|
|
7742
|
-
const estimatedAmountIn = data.amount_in && data.fee_amount ? new
|
|
7558
|
+
const estimatedAmountIn = data.amount_in && data.fee_amount ? new BN19(data.amount_in).add(new BN19(data.fee_amount)).toString() : "";
|
|
7743
7559
|
return {
|
|
7744
7560
|
poolAddress: params.pool.poolAddress,
|
|
7745
7561
|
currentSqrtPrice: params.currentSqrtPrice,
|
|
@@ -7756,7 +7572,7 @@ var SwapModule = class {
|
|
|
7756
7572
|
transformSwapWithMultiPoolData(params, jsonData) {
|
|
7757
7573
|
const { data } = jsonData;
|
|
7758
7574
|
console.log("json data. ", data);
|
|
7759
|
-
const estimatedAmountIn = data.amount_in && data.fee_amount ? new
|
|
7575
|
+
const estimatedAmountIn = data.amount_in && data.fee_amount ? new BN19(data.amount_in).add(new BN19(data.fee_amount)).toString() : "";
|
|
7760
7576
|
return {
|
|
7761
7577
|
poolAddress: params.poolAddress,
|
|
7762
7578
|
estimatedAmountIn,
|
|
@@ -9269,7 +9085,7 @@ var TokenModule = class {
|
|
|
9269
9085
|
};
|
|
9270
9086
|
|
|
9271
9087
|
// src/modules/routerModuleV2.ts
|
|
9272
|
-
import
|
|
9088
|
+
import BN20 from "bn.js";
|
|
9273
9089
|
import Decimal9 from "decimal.js";
|
|
9274
9090
|
import { v4 as uuidv4 } from "uuid";
|
|
9275
9091
|
import axios from "axios";
|
|
@@ -9313,12 +9129,12 @@ var RouterModuleV2 = class {
|
|
|
9313
9129
|
outputAmount: basePath.output_amount,
|
|
9314
9130
|
inputAmount: basePath.input_amount,
|
|
9315
9131
|
feeRate: basePath.fee_rate,
|
|
9316
|
-
currentSqrtPrice: new
|
|
9317
|
-
afterSqrtPrice: basePath.label === "Magma" ? new
|
|
9132
|
+
currentSqrtPrice: new BN20(basePath.current_sqrt_price.toString()),
|
|
9133
|
+
afterSqrtPrice: basePath.label === "Magma" ? new BN20(basePath.after_sqrt_price.toString()) : ZERO,
|
|
9318
9134
|
fromDecimal: basePath.from_decimal,
|
|
9319
9135
|
toDecimal: basePath.to_decimal,
|
|
9320
9136
|
currentPrice: this.calculatePrice(
|
|
9321
|
-
new
|
|
9137
|
+
new BN20(basePath.current_sqrt_price.toString()),
|
|
9322
9138
|
basePath.from_decimal,
|
|
9323
9139
|
basePath.to_decimal,
|
|
9324
9140
|
basePath.direction,
|
|
@@ -9401,7 +9217,7 @@ var RouterModuleV2 = class {
|
|
|
9401
9217
|
const priceResult = await this.sdk.Router.priceUseV1(
|
|
9402
9218
|
from,
|
|
9403
9219
|
to,
|
|
9404
|
-
new
|
|
9220
|
+
new BN20(amount),
|
|
9405
9221
|
byAmountIn,
|
|
9406
9222
|
priceSplitPoint,
|
|
9407
9223
|
partner,
|
|
@@ -9413,7 +9229,7 @@ var RouterModuleV2 = class {
|
|
|
9413
9229
|
if (path.poolAddress.length > 1) {
|
|
9414
9230
|
const fromDecimal0 = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9415
9231
|
const toDecimal0 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9416
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9232
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
|
|
9417
9233
|
const path0 = {
|
|
9418
9234
|
direction: path.a2b[0],
|
|
9419
9235
|
label: "Magma",
|
|
@@ -9430,7 +9246,7 @@ var RouterModuleV2 = class {
|
|
|
9430
9246
|
};
|
|
9431
9247
|
const fromDecimal1 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9432
9248
|
const toDecimal1 = this.sdk.Router.tokenInfo(path.coinType[2]).decimals;
|
|
9433
|
-
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9249
|
+
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
|
|
9434
9250
|
const path1 = {
|
|
9435
9251
|
direction: path.a2b[1],
|
|
9436
9252
|
label: "Magma",
|
|
@@ -9449,7 +9265,7 @@ var RouterModuleV2 = class {
|
|
|
9449
9265
|
} else {
|
|
9450
9266
|
const fromDecimal = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9451
9267
|
const toDecimal = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9452
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9268
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
|
|
9453
9269
|
const path0 = {
|
|
9454
9270
|
direction: path.a2b[0],
|
|
9455
9271
|
label: "Magma",
|
|
@@ -9534,7 +9350,7 @@ var RouterModuleV2 = class {
|
|
|
9534
9350
|
const priceResult = await this.sdk.Router.priceUseV1(
|
|
9535
9351
|
from,
|
|
9536
9352
|
to,
|
|
9537
|
-
new
|
|
9353
|
+
new BN20(amount),
|
|
9538
9354
|
byAmountIn,
|
|
9539
9355
|
priceSplitPoint,
|
|
9540
9356
|
partner,
|
|
@@ -9546,7 +9362,7 @@ var RouterModuleV2 = class {
|
|
|
9546
9362
|
if (path.poolAddress.length > 1) {
|
|
9547
9363
|
const fromDecimal0 = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9548
9364
|
const toDecimal0 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9549
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9365
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
|
|
9550
9366
|
const path0 = {
|
|
9551
9367
|
direction: path.a2b[0],
|
|
9552
9368
|
label: "Magma",
|
|
@@ -9563,7 +9379,7 @@ var RouterModuleV2 = class {
|
|
|
9563
9379
|
};
|
|
9564
9380
|
const fromDecimal1 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9565
9381
|
const toDecimal1 = this.sdk.Router.tokenInfo(path.coinType[2]).decimals;
|
|
9566
|
-
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9382
|
+
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
|
|
9567
9383
|
const path1 = {
|
|
9568
9384
|
direction: path.a2b[1],
|
|
9569
9385
|
label: "Magma",
|
|
@@ -9582,7 +9398,7 @@ var RouterModuleV2 = class {
|
|
|
9582
9398
|
} else {
|
|
9583
9399
|
const fromDecimal = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9584
9400
|
const toDecimal = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9585
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9401
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new BN20(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
|
|
9586
9402
|
const path0 = {
|
|
9587
9403
|
direction: path.a2b[0],
|
|
9588
9404
|
label: "Magma",
|
|
@@ -10610,10 +10426,11 @@ var DlmmModule = class {
|
|
|
10610
10426
|
});
|
|
10611
10427
|
return tx;
|
|
10612
10428
|
}
|
|
10429
|
+
// async mintByStrategySingle(params: MintByStrategySingleParams): Promise<Transaction> {}
|
|
10613
10430
|
async mintByStrategy(params) {
|
|
10614
10431
|
const tx = new Transaction12();
|
|
10615
10432
|
const slippage = new Decimal10(params.slippage);
|
|
10616
|
-
const lower_slippage = new Decimal10(1).
|
|
10433
|
+
const lower_slippage = new Decimal10(1).sub(slippage.div(new Decimal10(1e4)));
|
|
10617
10434
|
const upper_slippage = new Decimal10(1).plus(slippage.div(new Decimal10(1e4)));
|
|
10618
10435
|
tx.setSender(this.sdk.senderAddress);
|
|
10619
10436
|
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
@@ -10630,13 +10447,13 @@ var DlmmModule = class {
|
|
|
10630
10447
|
let amount_min = 0;
|
|
10631
10448
|
let amount_max = 0;
|
|
10632
10449
|
if (params.fixCoinA) {
|
|
10633
|
-
amount_min = new Decimal10(params.
|
|
10634
|
-
amount_max = new Decimal10(params.
|
|
10450
|
+
amount_min = new Decimal10(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10451
|
+
amount_max = new Decimal10(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10635
10452
|
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10636
10453
|
}
|
|
10637
10454
|
if (params.fixCoinB) {
|
|
10638
|
-
amount_min = new Decimal10(params.
|
|
10639
|
-
amount_max = new Decimal10(params.
|
|
10455
|
+
amount_min = new Decimal10(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10456
|
+
amount_max = new Decimal10(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10640
10457
|
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10641
10458
|
}
|
|
10642
10459
|
if (params.fixCoinA && params.fixCoinB) {
|
|
@@ -10653,8 +10470,8 @@ var DlmmModule = class {
|
|
|
10653
10470
|
tx.pure.u64(params.amountATotal),
|
|
10654
10471
|
tx.pure.u64(params.amountBTotal),
|
|
10655
10472
|
tx.pure.u8(params.strategy),
|
|
10656
|
-
tx.pure.u32(params.min_bin),
|
|
10657
|
-
tx.pure.u32(params.max_bin),
|
|
10473
|
+
tx.pure.u32(get_storage_id_from_real_id(params.min_bin)),
|
|
10474
|
+
tx.pure.u32(get_storage_id_from_real_id(params.max_bin)),
|
|
10658
10475
|
tx.pure.u32(active_min),
|
|
10659
10476
|
tx.pure.u32(active_max),
|
|
10660
10477
|
tx.pure.u64(amount_min),
|
|
@@ -10662,7 +10479,7 @@ var DlmmModule = class {
|
|
|
10662
10479
|
tx.object(CLOCK_ADDRESS)
|
|
10663
10480
|
];
|
|
10664
10481
|
tx.moveCall({
|
|
10665
|
-
target: `${integrate.published_at}::${DlmmScript}::
|
|
10482
|
+
target: `${integrate.published_at}::${DlmmScript}::mint_by_strategy`,
|
|
10666
10483
|
typeArguments,
|
|
10667
10484
|
arguments: args
|
|
10668
10485
|
});
|
|
@@ -10884,7 +10701,8 @@ var DlmmModule = class {
|
|
|
10884
10701
|
async createPairAddLiquidity(params) {
|
|
10885
10702
|
const tx = new Transaction12();
|
|
10886
10703
|
tx.setSender(this.sdk.senderAddress);
|
|
10887
|
-
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10704
|
+
const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10705
|
+
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10888
10706
|
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10889
10707
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10890
10708
|
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
@@ -10892,14 +10710,19 @@ var DlmmModule = class {
|
|
|
10892
10710
|
const amountBTotal = params.amountsY.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10893
10711
|
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coinTypeA, false, true);
|
|
10894
10712
|
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coinTypeB, false, true);
|
|
10713
|
+
const storageIds = [];
|
|
10714
|
+
params.realIds.forEach((i) => {
|
|
10715
|
+
storageIds.push(get_storage_id_from_real_id(i));
|
|
10716
|
+
});
|
|
10895
10717
|
const args = [
|
|
10896
10718
|
tx.object(dlmmConfig.factory),
|
|
10719
|
+
tx.object(global_config_id),
|
|
10897
10720
|
tx.pure.u64(params.baseFee),
|
|
10898
10721
|
tx.pure.u16(params.binStep),
|
|
10899
|
-
tx.pure.u32(params.activeId),
|
|
10722
|
+
tx.pure.u32(get_storage_id_from_real_id(params.activeId)),
|
|
10900
10723
|
primaryCoinAInputs.targetCoin,
|
|
10901
10724
|
primaryCoinBInputs.targetCoin,
|
|
10902
|
-
tx.pure.vector("u32",
|
|
10725
|
+
tx.pure.vector("u32", storageIds),
|
|
10903
10726
|
tx.pure.vector("u64", params.amountsX),
|
|
10904
10727
|
tx.pure.vector("u64", params.amountsY),
|
|
10905
10728
|
tx.pure.address(params.to),
|
|
@@ -11011,8 +10834,8 @@ var DlmmModule = class {
|
|
|
11011
10834
|
const positionLiquidity = await this.getPositionLiquidity({
|
|
11012
10835
|
pair: position.pool,
|
|
11013
10836
|
positionId: position.pos_object_id,
|
|
11014
|
-
coinTypeA: pool
|
|
11015
|
-
coinTypeB: pool
|
|
10837
|
+
coinTypeA: pool.coin_a,
|
|
10838
|
+
coinTypeB: pool.coin_b
|
|
11016
10839
|
});
|
|
11017
10840
|
const rewards_token = pool_reward_coins.get(position.pool) || [];
|
|
11018
10841
|
let positionRewards = { position_id: position.pos_object_id, reward: [], amount: [] };
|
|
@@ -11020,16 +10843,16 @@ var DlmmModule = class {
|
|
|
11020
10843
|
positionRewards = await this.getEarnedRewards({
|
|
11021
10844
|
pool_id: position.pool,
|
|
11022
10845
|
position_id: position.pos_object_id,
|
|
11023
|
-
coin_a: pool
|
|
11024
|
-
coin_b: pool
|
|
10846
|
+
coin_a: pool.coin_a,
|
|
10847
|
+
coin_b: pool.coin_b,
|
|
11025
10848
|
rewards_token: pool_reward_coins.get(position.pool) || []
|
|
11026
10849
|
});
|
|
11027
10850
|
}
|
|
11028
10851
|
const positionFees = await this.getEarnedFees({
|
|
11029
10852
|
pool_id: position.pool,
|
|
11030
10853
|
position_id: position.pos_object_id,
|
|
11031
|
-
coin_a: pool
|
|
11032
|
-
coin_b: pool
|
|
10854
|
+
coin_a: pool.coin_a,
|
|
10855
|
+
coin_b: pool.coin_b
|
|
11033
10856
|
});
|
|
11034
10857
|
return {
|
|
11035
10858
|
position,
|
|
@@ -11088,8 +10911,8 @@ var DlmmModule = class {
|
|
|
11088
10911
|
const positionLiquidity = await this.getPositionLiquidity({
|
|
11089
10912
|
pair: item.pool,
|
|
11090
10913
|
positionId: item.pos_object_id,
|
|
11091
|
-
coinTypeA: pool
|
|
11092
|
-
coinTypeB: pool
|
|
10914
|
+
coinTypeA: pool.coin_a,
|
|
10915
|
+
coinTypeB: pool.coin_b
|
|
11093
10916
|
});
|
|
11094
10917
|
const rewards_token = pool_reward_coins.get(item.pool) || [];
|
|
11095
10918
|
let positionRewards = { position_id: item.pos_object_id, reward: [], amount: [] };
|
|
@@ -11097,16 +10920,16 @@ var DlmmModule = class {
|
|
|
11097
10920
|
positionRewards = await this.getEarnedRewards({
|
|
11098
10921
|
pool_id: item.pool,
|
|
11099
10922
|
position_id: item.pos_object_id,
|
|
11100
|
-
coin_a: pool
|
|
11101
|
-
coin_b: pool
|
|
10923
|
+
coin_a: pool.coin_a,
|
|
10924
|
+
coin_b: pool.coin_b,
|
|
11102
10925
|
rewards_token: pool_reward_coins.get(item.pool) || []
|
|
11103
10926
|
});
|
|
11104
10927
|
}
|
|
11105
10928
|
const positionFees = await this.getEarnedFees({
|
|
11106
10929
|
pool_id: item.pool,
|
|
11107
10930
|
position_id: item.pos_object_id,
|
|
11108
|
-
coin_a: pool
|
|
11109
|
-
coin_b: pool
|
|
10931
|
+
coin_a: pool.coin_a,
|
|
10932
|
+
coin_b: pool.coin_b
|
|
11110
10933
|
});
|
|
11111
10934
|
out.push({
|
|
11112
10935
|
position: item,
|