@magmaprotocol/magma-clmm-sdk 0.5.75 → 0.5.77
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 +6 -10
- package/dist/index.d.ts +2 -424
- package/dist/index.js +145 -1594
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -1583
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -37,7 +37,6 @@ var src_exports = {};
|
|
|
37
37
|
__export(src_exports, {
|
|
38
38
|
AMM_SWAP_MODULE: () => AMM_SWAP_MODULE,
|
|
39
39
|
AmountSpecified: () => AmountSpecified,
|
|
40
|
-
BinMath: () => BinMath,
|
|
41
40
|
CLOCK_ADDRESS: () => CLOCK_ADDRESS,
|
|
42
41
|
CachedContent: () => CachedContent,
|
|
43
42
|
ClmmExpectSwapModule: () => ClmmExpectSwapModule,
|
|
@@ -65,7 +64,6 @@ __export(src_exports, {
|
|
|
65
64
|
DeepbookCustodianV2Moudle: () => DeepbookCustodianV2Moudle,
|
|
66
65
|
DeepbookEndpointsV2Moudle: () => DeepbookEndpointsV2Moudle,
|
|
67
66
|
DeepbookUtils: () => DeepbookUtils,
|
|
68
|
-
DlmmScript: () => DlmmScript,
|
|
69
67
|
FEE_RATE_DENOMINATOR: () => FEE_RATE_DENOMINATOR,
|
|
70
68
|
GAS_SYMBOL: () => GAS_SYMBOL,
|
|
71
69
|
GAS_TYPE_ARG: () => GAS_TYPE_ARG,
|
|
@@ -93,7 +91,6 @@ __export(src_exports, {
|
|
|
93
91
|
SUI_SYSTEM_STATE_OBJECT_ID: () => SUI_SYSTEM_STATE_OBJECT_ID,
|
|
94
92
|
SplitSwap: () => SplitSwap,
|
|
95
93
|
SplitUnit: () => SplitUnit,
|
|
96
|
-
StrategyType: () => StrategyType,
|
|
97
94
|
SwapDirection: () => SwapDirection,
|
|
98
95
|
SwapModule: () => SwapModule,
|
|
99
96
|
SwapUtils: () => SwapUtils,
|
|
@@ -115,10 +112,6 @@ __export(src_exports, {
|
|
|
115
112
|
adjustForSlippage: () => adjustForSlippage,
|
|
116
113
|
asIntN: () => asIntN,
|
|
117
114
|
asUintN: () => asUintN,
|
|
118
|
-
autoFillXByStrategy: () => autoFillXByStrategy,
|
|
119
|
-
autoFillXByWeight: () => autoFillXByWeight,
|
|
120
|
-
autoFillYByStrategy: () => autoFillYByStrategy,
|
|
121
|
-
autoFillYByWeight: () => autoFillYByWeight,
|
|
122
115
|
bufferToHex: () => bufferToHex,
|
|
123
116
|
buildClmmPositionName: () => buildClmmPositionName,
|
|
124
117
|
buildNFT: () => buildNFT,
|
|
@@ -157,14 +150,12 @@ __export(src_exports, {
|
|
|
157
150
|
getAmountUnfixedDelta: () => getAmountUnfixedDelta,
|
|
158
151
|
getCoinAFromLiquidity: () => getCoinAFromLiquidity,
|
|
159
152
|
getCoinBFromLiquidity: () => getCoinBFromLiquidity,
|
|
160
|
-
getCoinXYForLiquidity: () => getCoinXYForLiquidity,
|
|
161
153
|
getDefaultSuiInputType: () => getDefaultSuiInputType,
|
|
162
154
|
getDeltaA: () => getDeltaA,
|
|
163
155
|
getDeltaB: () => getDeltaB,
|
|
164
156
|
getDeltaDownFromOutput: () => getDeltaDownFromOutput,
|
|
165
157
|
getDeltaUpFromInput: () => getDeltaUpFromInput,
|
|
166
158
|
getFutureTime: () => getFutureTime,
|
|
167
|
-
getLiquidityAndCoinYByCoinX: () => getLiquidityAndCoinYByCoinX,
|
|
168
159
|
getLiquidityFromCoinA: () => getLiquidityFromCoinA,
|
|
169
160
|
getLiquidityFromCoinB: () => getLiquidityFromCoinB,
|
|
170
161
|
getLowerSqrtPriceFromCoinA: () => getLowerSqrtPriceFromCoinA,
|
|
@@ -188,7 +179,6 @@ __export(src_exports, {
|
|
|
188
179
|
getObjectType: () => getObjectType,
|
|
189
180
|
getObjectVersion: () => getObjectVersion,
|
|
190
181
|
getPackagerConfigs: () => getPackagerConfigs,
|
|
191
|
-
getPriceOfBinByBinId: () => getPriceOfBinByBinId,
|
|
192
182
|
getRewardInTickRange: () => getRewardInTickRange,
|
|
193
183
|
getSuiObjectData: () => getSuiObjectData,
|
|
194
184
|
getTickDataFromUrlData: () => getTickDataFromUrlData,
|
|
@@ -212,16 +202,11 @@ __export(src_exports, {
|
|
|
212
202
|
shortAddress: () => shortAddress,
|
|
213
203
|
shortString: () => shortString,
|
|
214
204
|
tickScore: () => tickScore,
|
|
215
|
-
toAmountAskSide: () => toAmountAskSide,
|
|
216
|
-
toAmountBidSide: () => toAmountBidSide,
|
|
217
|
-
toAmountBothSide: () => toAmountBothSide,
|
|
218
|
-
toAmountsBothSideByStrategy: () => toAmountsBothSideByStrategy,
|
|
219
205
|
toBuffer: () => toBuffer,
|
|
220
206
|
toCoinAmount: () => toCoinAmount,
|
|
221
207
|
toDecimalsAmount: () => toDecimalsAmount,
|
|
222
208
|
transClmmpoolDataWithoutTicks: () => transClmmpoolDataWithoutTicks,
|
|
223
|
-
utf8to16: () => utf8to16
|
|
224
|
-
withLiquiditySlippage: () => withLiquiditySlippage
|
|
209
|
+
utf8to16: () => utf8to16
|
|
225
210
|
});
|
|
226
211
|
module.exports = __toCommonJS(src_exports);
|
|
227
212
|
|
|
@@ -257,7 +242,7 @@ var CachedContent = class {
|
|
|
257
242
|
};
|
|
258
243
|
|
|
259
244
|
// src/utils/common.ts
|
|
260
|
-
var
|
|
245
|
+
var import_bn11 = __toESM(require("bn.js"));
|
|
261
246
|
var import_bcs = require("@mysten/bcs");
|
|
262
247
|
var import_ed25519 = require("@mysten/sui/keypairs/ed25519");
|
|
263
248
|
var import_secp256k1 = require("@mysten/sui/keypairs/secp256k1");
|
|
@@ -523,7 +508,6 @@ var Voter = "voter";
|
|
|
523
508
|
var RewardDistributor = "reward_distributor";
|
|
524
509
|
var Gauge = "gauge";
|
|
525
510
|
var Minter = "minter";
|
|
526
|
-
var DlmmScript = "dlmm_script";
|
|
527
511
|
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
528
512
|
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
529
513
|
var DeepbookCustodianV2Moudle = "custodian_v2";
|
|
@@ -1812,476 +1796,8 @@ function collectFeesQuote(param) {
|
|
|
1812
1796
|
return updateFees(param.position, fee_growth_inside_a, fee_growth_inside_b);
|
|
1813
1797
|
}
|
|
1814
1798
|
|
|
1815
|
-
// src/math/dlmmWeightToAmounts.ts
|
|
1816
|
-
var import_bn9 = __toESM(require("bn.js"));
|
|
1817
|
-
var import_decimal6 = __toESM(require("decimal.js"));
|
|
1818
|
-
var import_calc_dlmm = require("@magmaprotocol/calc_dlmm");
|
|
1819
|
-
function getPriceOfBinByBinId(binId, binStep) {
|
|
1820
|
-
const twoDec = new import_decimal6.default(2);
|
|
1821
|
-
const price = new import_decimal6.default((0, import_calc_dlmm.get_price_x128_from_real_id)(binId, binStep));
|
|
1822
|
-
return price.div(twoDec.pow(128));
|
|
1823
|
-
}
|
|
1824
|
-
function autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, distributions) {
|
|
1825
|
-
const activeBins = distributions.filter((element) => {
|
|
1826
|
-
return element.binId === activeId;
|
|
1827
|
-
});
|
|
1828
|
-
if (activeBins.length === 1) {
|
|
1829
|
-
const p0 = getPriceOfBinByBinId(activeId, binStep);
|
|
1830
|
-
let wx0 = new import_decimal6.default(0);
|
|
1831
|
-
let wy0 = new import_decimal6.default(0);
|
|
1832
|
-
const activeBin = activeBins[0];
|
|
1833
|
-
if (amountXInActiveBin.isZero() && amountYInActiveBin.isZero()) {
|
|
1834
|
-
wx0 = new import_decimal6.default(activeBin.weight).div(p0.mul(new import_decimal6.default(2)));
|
|
1835
|
-
wy0 = new import_decimal6.default(activeBin.weight).div(new import_decimal6.default(2));
|
|
1836
|
-
} else {
|
|
1837
|
-
const amountXInActiveBinDec = new import_decimal6.default(amountXInActiveBin.toString());
|
|
1838
|
-
const amountYInActiveBinDec = new import_decimal6.default(amountYInActiveBin.toString());
|
|
1839
|
-
if (!amountXInActiveBin.isZero()) {
|
|
1840
|
-
wx0 = new import_decimal6.default(activeBin.weight).div(p0.add(amountYInActiveBinDec.div(amountXInActiveBinDec)));
|
|
1841
|
-
}
|
|
1842
|
-
if (!amountYInActiveBin.isZero()) {
|
|
1843
|
-
wy0 = new import_decimal6.default(activeBin.weight).div(new import_decimal6.default(1).add(p0.mul(amountXInActiveBinDec).div(amountYInActiveBinDec)));
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
let totalWeightX2 = wx0;
|
|
1847
|
-
let totalWeightY2 = wy0;
|
|
1848
|
-
distributions.forEach((element) => {
|
|
1849
|
-
if (element.binId < activeId) {
|
|
1850
|
-
totalWeightY2 = totalWeightY2.add(new import_decimal6.default(element.weight));
|
|
1851
|
-
}
|
|
1852
|
-
if (element.binId > activeId) {
|
|
1853
|
-
const price = getPriceOfBinByBinId(element.binId, binStep);
|
|
1854
|
-
const weighPerPrice = new import_decimal6.default(element.weight).div(price);
|
|
1855
|
-
totalWeightX2 = totalWeightX2.add(weighPerPrice);
|
|
1856
|
-
}
|
|
1857
|
-
});
|
|
1858
|
-
const kx2 = totalWeightX2.isZero() ? new import_decimal6.default(1) : new import_decimal6.default(amountX.toString()).div(totalWeightX2);
|
|
1859
|
-
const amountY2 = kx2.mul(totalWeightY2);
|
|
1860
|
-
return new import_bn9.default(amountY2.floor().toString());
|
|
1861
|
-
}
|
|
1862
|
-
let totalWeightX = new import_decimal6.default(0);
|
|
1863
|
-
let totalWeightY = new import_decimal6.default(0);
|
|
1864
|
-
distributions.forEach((element) => {
|
|
1865
|
-
if (element.binId < activeId) {
|
|
1866
|
-
totalWeightY = totalWeightY.add(new import_decimal6.default(element.weight));
|
|
1867
|
-
} else {
|
|
1868
|
-
const price = getPriceOfBinByBinId(element.binId, binStep);
|
|
1869
|
-
const weighPerPrice = new import_decimal6.default(element.weight).div(price);
|
|
1870
|
-
totalWeightX = totalWeightX.add(weighPerPrice);
|
|
1871
|
-
}
|
|
1872
|
-
});
|
|
1873
|
-
const kx = totalWeightX.isZero() ? new import_decimal6.default(1) : new import_decimal6.default(amountX.toString()).div(totalWeightX);
|
|
1874
|
-
const amountY = kx.mul(totalWeightY);
|
|
1875
|
-
return new import_bn9.default(amountY.floor().toString());
|
|
1876
|
-
}
|
|
1877
|
-
function autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, distributions) {
|
|
1878
|
-
const activeBins = distributions.filter((element) => {
|
|
1879
|
-
return element.binId === activeId;
|
|
1880
|
-
});
|
|
1881
|
-
if (activeBins.length === 1) {
|
|
1882
|
-
const p0 = getPriceOfBinByBinId(activeId, binStep);
|
|
1883
|
-
let wx0 = new import_decimal6.default(0);
|
|
1884
|
-
let wy0 = new import_decimal6.default(0);
|
|
1885
|
-
const activeBin = activeBins[0];
|
|
1886
|
-
if (amountXInActiveBin.isZero() && amountYInActiveBin.isZero()) {
|
|
1887
|
-
wx0 = new import_decimal6.default(activeBin.weight).div(p0.mul(new import_decimal6.default(2)));
|
|
1888
|
-
wy0 = new import_decimal6.default(activeBin.weight).div(new import_decimal6.default(2));
|
|
1889
|
-
} else {
|
|
1890
|
-
const amountXInActiveBinDec = new import_decimal6.default(amountXInActiveBin.toString());
|
|
1891
|
-
const amountYInActiveBinDec = new import_decimal6.default(amountYInActiveBin.toString());
|
|
1892
|
-
if (!amountXInActiveBin.isZero()) {
|
|
1893
|
-
wx0 = new import_decimal6.default(activeBin.weight).div(p0.add(amountYInActiveBinDec.div(amountXInActiveBinDec)));
|
|
1894
|
-
}
|
|
1895
|
-
if (!amountYInActiveBin.isZero()) {
|
|
1896
|
-
wy0 = new import_decimal6.default(activeBin.weight).div(new import_decimal6.default(1).add(p0.mul(amountXInActiveBinDec).div(amountYInActiveBinDec)));
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
let totalWeightX2 = wx0;
|
|
1900
|
-
let totalWeightY2 = wy0;
|
|
1901
|
-
distributions.forEach((element) => {
|
|
1902
|
-
if (element.binId < activeId) {
|
|
1903
|
-
totalWeightY2 = totalWeightY2.add(new import_decimal6.default(element.weight));
|
|
1904
|
-
}
|
|
1905
|
-
if (element.binId > activeId) {
|
|
1906
|
-
const price = getPriceOfBinByBinId(element.binId, binStep);
|
|
1907
|
-
const weighPerPrice = new import_decimal6.default(element.weight).div(price);
|
|
1908
|
-
totalWeightX2 = totalWeightX2.add(weighPerPrice);
|
|
1909
|
-
}
|
|
1910
|
-
});
|
|
1911
|
-
const ky2 = totalWeightY2.isZero() ? new import_decimal6.default(1) : new import_decimal6.default(amountY.toString()).div(totalWeightY2);
|
|
1912
|
-
const amountX2 = ky2.mul(totalWeightX2);
|
|
1913
|
-
return new import_bn9.default(amountX2.floor().toString());
|
|
1914
|
-
}
|
|
1915
|
-
let totalWeightX = new import_decimal6.default(0);
|
|
1916
|
-
let totalWeightY = new import_decimal6.default(0);
|
|
1917
|
-
distributions.forEach((element) => {
|
|
1918
|
-
if (element.binId < activeId) {
|
|
1919
|
-
totalWeightY = totalWeightY.add(new import_decimal6.default(element.weight));
|
|
1920
|
-
} else {
|
|
1921
|
-
const price = getPriceOfBinByBinId(element.binId, binStep);
|
|
1922
|
-
const weighPerPrice = new import_decimal6.default(element.weight).div(price);
|
|
1923
|
-
totalWeightX = totalWeightX.add(weighPerPrice);
|
|
1924
|
-
}
|
|
1925
|
-
});
|
|
1926
|
-
const ky = totalWeightY.isZero() ? new import_decimal6.default(1) : new import_decimal6.default(amountY.toString()).div(totalWeightY);
|
|
1927
|
-
const amountX = ky.mul(totalWeightX);
|
|
1928
|
-
return new import_bn9.default(amountX.floor().toString());
|
|
1929
|
-
}
|
|
1930
|
-
function toAmountBidSide(activeId, totalAmount, distributions) {
|
|
1931
|
-
const totalWeight = distributions.reduce((sum, el) => {
|
|
1932
|
-
return el.binId > activeId ? sum : sum.add(el.weight);
|
|
1933
|
-
}, new import_decimal6.default(0));
|
|
1934
|
-
if (totalWeight.cmp(new import_decimal6.default(0)) !== 1) {
|
|
1935
|
-
throw Error("Invalid parameteres");
|
|
1936
|
-
}
|
|
1937
|
-
return distributions.map((bin) => {
|
|
1938
|
-
if (bin.binId > activeId) {
|
|
1939
|
-
return {
|
|
1940
|
-
binId: bin.binId,
|
|
1941
|
-
amount: new import_bn9.default(0)
|
|
1942
|
-
};
|
|
1943
|
-
}
|
|
1944
|
-
return {
|
|
1945
|
-
binId: bin.binId,
|
|
1946
|
-
amount: new import_bn9.default(new import_decimal6.default(totalAmount.toString()).mul(new import_decimal6.default(bin.weight).div(totalWeight)).floor().toString())
|
|
1947
|
-
};
|
|
1948
|
-
});
|
|
1949
|
-
}
|
|
1950
|
-
function toAmountAskSide(activeId, binStep, totalAmount, distributions) {
|
|
1951
|
-
const totalWeight = distributions.reduce((sum, el) => {
|
|
1952
|
-
if (el.binId < activeId) {
|
|
1953
|
-
return sum;
|
|
1954
|
-
}
|
|
1955
|
-
const price = getPriceOfBinByBinId(el.binId, binStep);
|
|
1956
|
-
const weightPerPrice = new import_decimal6.default(el.weight).div(price);
|
|
1957
|
-
return sum.add(weightPerPrice);
|
|
1958
|
-
}, new import_decimal6.default(0));
|
|
1959
|
-
if (totalWeight.cmp(new import_decimal6.default(0)) !== 1) {
|
|
1960
|
-
throw Error("Invalid parameteres");
|
|
1961
|
-
}
|
|
1962
|
-
return distributions.map((bin) => {
|
|
1963
|
-
if (bin.binId < activeId) {
|
|
1964
|
-
return {
|
|
1965
|
-
binId: bin.binId,
|
|
1966
|
-
amount: new import_bn9.default(0)
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
const price = getPriceOfBinByBinId(bin.binId, binStep);
|
|
1970
|
-
const weightPerPrice = new import_decimal6.default(bin.weight).div(price);
|
|
1971
|
-
return {
|
|
1972
|
-
binId: bin.binId,
|
|
1973
|
-
amount: new import_bn9.default(new import_decimal6.default(totalAmount.toString()).mul(weightPerPrice).div(totalWeight).floor().toString())
|
|
1974
|
-
};
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, distributions) {
|
|
1978
|
-
if (activeId > distributions[distributions.length - 1].binId) {
|
|
1979
|
-
const amounts = toAmountBidSide(activeId, amountY, distributions);
|
|
1980
|
-
return amounts.map((bin) => {
|
|
1981
|
-
return {
|
|
1982
|
-
binId: bin.binId,
|
|
1983
|
-
amountX: new import_bn9.default(0),
|
|
1984
|
-
amountY: bin.amount
|
|
1985
|
-
};
|
|
1986
|
-
});
|
|
1987
|
-
}
|
|
1988
|
-
if (activeId < distributions[0].binId) {
|
|
1989
|
-
const amounts = toAmountAskSide(activeId, binStep, amountX, distributions);
|
|
1990
|
-
return amounts.map((bin) => {
|
|
1991
|
-
return {
|
|
1992
|
-
binId: bin.binId,
|
|
1993
|
-
amountX: bin.amount,
|
|
1994
|
-
amountY: new import_bn9.default(0)
|
|
1995
|
-
};
|
|
1996
|
-
});
|
|
1997
|
-
}
|
|
1998
|
-
const activeBins = distributions.filter((element) => {
|
|
1999
|
-
return element.binId === activeId;
|
|
2000
|
-
});
|
|
2001
|
-
if (activeBins.length === 1) {
|
|
2002
|
-
const p0 = getPriceOfBinByBinId(activeId, binStep);
|
|
2003
|
-
let wx0 = new import_decimal6.default(0);
|
|
2004
|
-
let wy0 = new import_decimal6.default(0);
|
|
2005
|
-
const activeBin = activeBins[0];
|
|
2006
|
-
if (amountXInActiveBin.isZero() && amountYInActiveBin.isZero()) {
|
|
2007
|
-
wx0 = new import_decimal6.default(activeBin.weight).div(p0.mul(new import_decimal6.default(2)));
|
|
2008
|
-
wy0 = new import_decimal6.default(activeBin.weight).div(new import_decimal6.default(2));
|
|
2009
|
-
} else {
|
|
2010
|
-
const amountXInActiveBinDec = new import_decimal6.default(amountXInActiveBin.toString());
|
|
2011
|
-
const amountYInActiveBinDec = new import_decimal6.default(amountYInActiveBin.toString());
|
|
2012
|
-
if (!amountXInActiveBin.isZero()) {
|
|
2013
|
-
wx0 = new import_decimal6.default(activeBin.weight).div(p0.add(amountYInActiveBinDec.div(amountXInActiveBinDec)));
|
|
2014
|
-
}
|
|
2015
|
-
if (!amountYInActiveBin.isZero()) {
|
|
2016
|
-
wy0 = new import_decimal6.default(activeBin.weight).div(new import_decimal6.default(1).add(p0.mul(amountXInActiveBinDec).div(amountYInActiveBinDec)));
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
let totalWeightX2 = wx0;
|
|
2020
|
-
let totalWeightY2 = wy0;
|
|
2021
|
-
distributions.forEach((element) => {
|
|
2022
|
-
if (element.binId < activeId) {
|
|
2023
|
-
totalWeightY2 = totalWeightY2.add(new import_decimal6.default(element.weight));
|
|
2024
|
-
}
|
|
2025
|
-
if (element.binId > activeId) {
|
|
2026
|
-
const price = getPriceOfBinByBinId(element.binId, binStep);
|
|
2027
|
-
const weighPerPrice = new import_decimal6.default(element.weight).div(price);
|
|
2028
|
-
totalWeightX2 = totalWeightX2.add(weighPerPrice);
|
|
2029
|
-
}
|
|
2030
|
-
});
|
|
2031
|
-
const kx2 = new import_decimal6.default(amountX.toString()).div(totalWeightX2);
|
|
2032
|
-
const ky2 = new import_decimal6.default(amountY.toString()).div(totalWeightY2);
|
|
2033
|
-
const k2 = kx2.lessThan(ky2) ? kx2 : ky2;
|
|
2034
|
-
return distributions.map((bin) => {
|
|
2035
|
-
if (bin.binId < activeId) {
|
|
2036
|
-
const amount = k2.mul(new import_decimal6.default(bin.weight));
|
|
2037
|
-
return {
|
|
2038
|
-
binId: bin.binId,
|
|
2039
|
-
amountX: new import_bn9.default(0),
|
|
2040
|
-
amountY: new import_bn9.default(amount.floor().toString())
|
|
2041
|
-
};
|
|
2042
|
-
}
|
|
2043
|
-
if (bin.binId > activeId) {
|
|
2044
|
-
const price = getPriceOfBinByBinId(bin.binId, binStep);
|
|
2045
|
-
const weighPerPrice = new import_decimal6.default(bin.weight).div(price);
|
|
2046
|
-
const amount = k2.mul(weighPerPrice);
|
|
2047
|
-
return {
|
|
2048
|
-
binId: bin.binId,
|
|
2049
|
-
amountX: new import_bn9.default(amount.floor().toString()),
|
|
2050
|
-
amountY: new import_bn9.default(0)
|
|
2051
|
-
};
|
|
2052
|
-
}
|
|
2053
|
-
const amountXActiveBin = k2.mul(wx0);
|
|
2054
|
-
const amountYActiveBin = k2.mul(wy0);
|
|
2055
|
-
return {
|
|
2056
|
-
binId: bin.binId,
|
|
2057
|
-
amountX: new import_bn9.default(amountXActiveBin.floor().toString()),
|
|
2058
|
-
amountY: new import_bn9.default(amountYActiveBin.floor().toString())
|
|
2059
|
-
};
|
|
2060
|
-
});
|
|
2061
|
-
}
|
|
2062
|
-
let totalWeightX = new import_decimal6.default(0);
|
|
2063
|
-
let totalWeightY = new import_decimal6.default(0);
|
|
2064
|
-
distributions.forEach((element) => {
|
|
2065
|
-
if (element.binId < activeId) {
|
|
2066
|
-
totalWeightY = totalWeightY.add(new import_decimal6.default(element.weight));
|
|
2067
|
-
} else {
|
|
2068
|
-
const price = getPriceOfBinByBinId(element.binId, binStep);
|
|
2069
|
-
const weighPerPrice = new import_decimal6.default(element.weight).div(price);
|
|
2070
|
-
totalWeightX = totalWeightX.add(weighPerPrice);
|
|
2071
|
-
}
|
|
2072
|
-
});
|
|
2073
|
-
const kx = new import_decimal6.default(amountX.toString()).div(totalWeightX);
|
|
2074
|
-
const ky = new import_decimal6.default(amountY.toString()).div(totalWeightY);
|
|
2075
|
-
const k = kx.lessThan(ky) ? kx : ky;
|
|
2076
|
-
return distributions.map((bin) => {
|
|
2077
|
-
if (bin.binId < activeId) {
|
|
2078
|
-
const amount2 = k.mul(new import_decimal6.default(bin.weight));
|
|
2079
|
-
return {
|
|
2080
|
-
binId: bin.binId,
|
|
2081
|
-
amountX: new import_bn9.default(0),
|
|
2082
|
-
amountY: new import_bn9.default(amount2.floor().toString())
|
|
2083
|
-
};
|
|
2084
|
-
}
|
|
2085
|
-
const price = getPriceOfBinByBinId(bin.binId, binStep);
|
|
2086
|
-
const weighPerPrice = new import_decimal6.default(bin.weight).div(price);
|
|
2087
|
-
const amount = k.mul(weighPerPrice);
|
|
2088
|
-
return {
|
|
2089
|
-
binId: bin.binId,
|
|
2090
|
-
amountX: new import_bn9.default(amount.floor().toString()),
|
|
2091
|
-
amountY: new import_bn9.default(0)
|
|
2092
|
-
};
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
// src/math/dlmmStrategy.ts
|
|
2097
|
-
var StrategyType = /* @__PURE__ */ ((StrategyType2) => {
|
|
2098
|
-
StrategyType2[StrategyType2["Spot"] = 1] = "Spot";
|
|
2099
|
-
StrategyType2[StrategyType2["Curve"] = 2] = "Curve";
|
|
2100
|
-
StrategyType2[StrategyType2["BidAsk"] = 3] = "BidAsk";
|
|
2101
|
-
return StrategyType2;
|
|
2102
|
-
})(StrategyType || {});
|
|
2103
|
-
function toWeightSpotBalanced(minBinId, maxBinId) {
|
|
2104
|
-
const distributions = [];
|
|
2105
|
-
for (let i = minBinId; i <= maxBinId; i++) {
|
|
2106
|
-
distributions.push({
|
|
2107
|
-
binId: i,
|
|
2108
|
-
weight: 1
|
|
2109
|
-
});
|
|
2110
|
-
}
|
|
2111
|
-
return distributions;
|
|
2112
|
-
}
|
|
2113
|
-
var DEFAULT_MAX_WEIGHT = 2e3;
|
|
2114
|
-
var DEFAULT_MIN_WEIGHT = 200;
|
|
2115
|
-
function toWeightCurve(minBinId, maxBinId, activeId) {
|
|
2116
|
-
if (activeId < minBinId || activeId > maxBinId) {
|
|
2117
|
-
throw new ClmmpoolsError("Invalid strategy params", "InvalidParams" /* InvalidParams */);
|
|
2118
|
-
}
|
|
2119
|
-
const maxWeight = DEFAULT_MAX_WEIGHT;
|
|
2120
|
-
const minWeight = DEFAULT_MIN_WEIGHT;
|
|
2121
|
-
const diffWeight = maxWeight - minWeight;
|
|
2122
|
-
const diffMinWeight = activeId > minBinId ? Math.floor(diffWeight / (activeId - minBinId)) : 0;
|
|
2123
|
-
const diffMaxWeight = maxBinId > activeId ? Math.floor(diffWeight / (maxBinId - activeId)) : 0;
|
|
2124
|
-
const distributions = [];
|
|
2125
|
-
for (let i = minBinId; i <= maxBinId; i++) {
|
|
2126
|
-
if (i < activeId) {
|
|
2127
|
-
distributions.push({
|
|
2128
|
-
binId: i,
|
|
2129
|
-
weight: maxWeight - (activeId - i) * diffMinWeight
|
|
2130
|
-
});
|
|
2131
|
-
} else if (i > activeId) {
|
|
2132
|
-
distributions.push({
|
|
2133
|
-
binId: i,
|
|
2134
|
-
weight: maxWeight - (i - activeId) * diffMaxWeight
|
|
2135
|
-
});
|
|
2136
|
-
} else {
|
|
2137
|
-
distributions.push({
|
|
2138
|
-
binId: i,
|
|
2139
|
-
weight: maxWeight
|
|
2140
|
-
});
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
return distributions;
|
|
2144
|
-
}
|
|
2145
|
-
function toWeightBidAsk(minBinId, maxBinId, activeId) {
|
|
2146
|
-
if (activeId < minBinId || activeId > maxBinId) {
|
|
2147
|
-
throw new ClmmpoolsError("Invalid strategy params", "InvalidParams" /* InvalidParams */);
|
|
2148
|
-
}
|
|
2149
|
-
const maxWeight = DEFAULT_MAX_WEIGHT;
|
|
2150
|
-
const minWeight = DEFAULT_MIN_WEIGHT;
|
|
2151
|
-
const diffWeight = maxWeight - minWeight;
|
|
2152
|
-
const diffMinWeight = activeId > minBinId ? Math.floor(diffWeight / (activeId - minBinId)) : 0;
|
|
2153
|
-
const diffMaxWeight = maxBinId > activeId ? Math.floor(diffWeight / (maxBinId - activeId)) : 0;
|
|
2154
|
-
const distributions = [];
|
|
2155
|
-
for (let i = minBinId; i <= maxBinId; i++) {
|
|
2156
|
-
if (i < activeId) {
|
|
2157
|
-
distributions.push({
|
|
2158
|
-
binId: i,
|
|
2159
|
-
weight: minWeight + (activeId - i) * diffMinWeight
|
|
2160
|
-
});
|
|
2161
|
-
} else if (i > activeId) {
|
|
2162
|
-
distributions.push({
|
|
2163
|
-
binId: i,
|
|
2164
|
-
weight: minWeight + (i - activeId) * diffMaxWeight
|
|
2165
|
-
});
|
|
2166
|
-
} else {
|
|
2167
|
-
distributions.push({
|
|
2168
|
-
binId: i,
|
|
2169
|
-
weight: minWeight
|
|
2170
|
-
});
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
return distributions;
|
|
2174
|
-
}
|
|
2175
|
-
function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
2176
|
-
switch (strategyType) {
|
|
2177
|
-
case 1 /* Spot */: {
|
|
2178
|
-
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
2179
|
-
return autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2180
|
-
}
|
|
2181
|
-
case 2 /* Curve */: {
|
|
2182
|
-
const weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
2183
|
-
return autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2184
|
-
}
|
|
2185
|
-
case 3 /* BidAsk */: {
|
|
2186
|
-
const weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
2187
|
-
return autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2188
|
-
}
|
|
2189
|
-
default:
|
|
2190
|
-
throw new Error(`Unsupported strategy type: ${strategyType}`);
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
2194
|
-
switch (strategyType) {
|
|
2195
|
-
case 1 /* Spot */: {
|
|
2196
|
-
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
2197
|
-
return autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2198
|
-
}
|
|
2199
|
-
case 2 /* Curve */: {
|
|
2200
|
-
const weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
2201
|
-
return autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2202
|
-
}
|
|
2203
|
-
case 3 /* BidAsk */: {
|
|
2204
|
-
const weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
2205
|
-
return autoFillXByWeight(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2206
|
-
}
|
|
2207
|
-
default:
|
|
2208
|
-
throw new Error(`Unsupported strategy type: ${strategyType}`);
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amountX, amountY, amountXInActiveBin, amountYInActiveBin, strategyType) {
|
|
2212
|
-
const isSingleSideX = amountY.isZero();
|
|
2213
|
-
switch (strategyType) {
|
|
2214
|
-
case 1 /* Spot */: {
|
|
2215
|
-
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
2216
|
-
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2217
|
-
}
|
|
2218
|
-
case 2 /* Curve */: {
|
|
2219
|
-
const weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
2220
|
-
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2221
|
-
}
|
|
2222
|
-
case 3 /* BidAsk */: {
|
|
2223
|
-
const weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
2224
|
-
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
2225
|
-
}
|
|
2226
|
-
default:
|
|
2227
|
-
throw new Error(`Unsupported strategy type: ${strategyType}`);
|
|
2228
|
-
}
|
|
2229
|
-
}
|
|
2230
|
-
|
|
2231
|
-
// src/math/LiquidityHelper.ts
|
|
2232
|
-
var import_decimal8 = __toESM(require("decimal.js"));
|
|
2233
|
-
|
|
2234
|
-
// src/utils/numbers.ts
|
|
2235
|
-
var import_decimal7 = __toESM(require("decimal.js"));
|
|
2236
|
-
function d(value) {
|
|
2237
|
-
if (import_decimal7.default.isDecimal(value)) {
|
|
2238
|
-
return value;
|
|
2239
|
-
}
|
|
2240
|
-
return new import_decimal7.default(value === void 0 ? 0 : value);
|
|
2241
|
-
}
|
|
2242
|
-
function decimalsMultiplier(decimals) {
|
|
2243
|
-
return d(10).pow(d(decimals).abs());
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
// src/math/LiquidityHelper.ts
|
|
2247
|
-
function withLiquiditySlippage(value, slippage, mode) {
|
|
2248
|
-
return d(value)[mode](d(value).mul(slippage)).toDP(0);
|
|
2249
|
-
}
|
|
2250
|
-
function getLiquidityAndCoinYByCoinX(coinInVal, reserveInSize, reserveOutSize, lpSupply) {
|
|
2251
|
-
if (coinInVal.lessThanOrEqualTo(0)) {
|
|
2252
|
-
throw new ClmmpoolsError("coinInVal is less than zero", "InvalidCoinAmount" /* InvalidCoinAmount */);
|
|
2253
|
-
}
|
|
2254
|
-
if (reserveInSize.lessThanOrEqualTo(0) || reserveOutSize.lessThanOrEqualTo(0)) {
|
|
2255
|
-
return -1;
|
|
2256
|
-
}
|
|
2257
|
-
const coinYAmount = coinInVal.mul(reserveOutSize).div(reserveInSize);
|
|
2258
|
-
const sqrtSupply = lpSupply;
|
|
2259
|
-
const lpX = coinInVal.div(reserveInSize).mul(sqrtSupply);
|
|
2260
|
-
const lpY = coinYAmount.div(reserveOutSize).mul(sqrtSupply);
|
|
2261
|
-
const lpAmount = import_decimal8.default.min(lpX, lpY);
|
|
2262
|
-
return {
|
|
2263
|
-
coinYAmount,
|
|
2264
|
-
lpAmount
|
|
2265
|
-
};
|
|
2266
|
-
}
|
|
2267
|
-
function getCoinXYForLiquidity(liquidity, reserveInSize, reserveOutSize, lpSuply) {
|
|
2268
|
-
if (liquidity.lessThanOrEqualTo(0)) {
|
|
2269
|
-
throw new ClmmpoolsError("liquidity can't be equal or less than zero", "InvalidLiquidityAmount" /* InvalidLiquidityAmount */);
|
|
2270
|
-
}
|
|
2271
|
-
if (reserveInSize.lessThanOrEqualTo(0) || reserveOutSize.lessThanOrEqualTo(0)) {
|
|
2272
|
-
throw new ClmmpoolsError("reserveInSize or reserveOutSize can not be equal or less than zero", "InvalidReserveAmount" /* InvalidReserveAmount */);
|
|
2273
|
-
}
|
|
2274
|
-
const sqrtSupply = lpSuply;
|
|
2275
|
-
const coinXAmount = liquidity.div(sqrtSupply).mul(reserveInSize);
|
|
2276
|
-
const coinYAmount = liquidity.div(sqrtSupply).mul(reserveOutSize);
|
|
2277
|
-
return {
|
|
2278
|
-
coinXAmount,
|
|
2279
|
-
coinYAmount
|
|
2280
|
-
};
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
1799
|
// src/math/percentage.ts
|
|
2284
|
-
var
|
|
1800
|
+
var import_bn9 = __toESM(require("bn.js"));
|
|
2285
1801
|
var Percentage = class {
|
|
2286
1802
|
numerator;
|
|
2287
1803
|
denominator;
|
|
@@ -2309,8 +1825,8 @@ var Percentage = class {
|
|
|
2309
1825
|
* @returns
|
|
2310
1826
|
*/
|
|
2311
1827
|
static fromFraction(numerator, denominator) {
|
|
2312
|
-
const num = typeof numerator === "number" ? new
|
|
2313
|
-
const denom = typeof denominator === "number" ? new
|
|
1828
|
+
const num = typeof numerator === "number" ? new import_bn9.default(numerator.toString()) : numerator;
|
|
1829
|
+
const denom = typeof denominator === "number" ? new import_bn9.default(denominator.toString()) : denominator;
|
|
2314
1830
|
return new Percentage(num, denom);
|
|
2315
1831
|
}
|
|
2316
1832
|
};
|
|
@@ -2410,7 +1926,7 @@ function adjustForCoinSlippage(tokenAmount, slippage, adjustUp) {
|
|
|
2410
1926
|
}
|
|
2411
1927
|
|
|
2412
1928
|
// src/math/SplitSwap.ts
|
|
2413
|
-
var
|
|
1929
|
+
var import_bn10 = __toESM(require("bn.js"));
|
|
2414
1930
|
var SplitUnit = /* @__PURE__ */ ((SplitUnit2) => {
|
|
2415
1931
|
SplitUnit2[SplitUnit2["FIVE"] = 5] = "FIVE";
|
|
2416
1932
|
SplitUnit2[SplitUnit2["TEN"] = 10] = "TEN";
|
|
@@ -2468,7 +1984,7 @@ function updateSplitSwapResult(maxIndex, currentIndex, splitSwapResult, stepResu
|
|
|
2468
1984
|
return splitSwapResult;
|
|
2469
1985
|
}
|
|
2470
1986
|
function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
2471
|
-
let currentLiquidity = new
|
|
1987
|
+
let currentLiquidity = new import_bn10.default(poolData.liquidity);
|
|
2472
1988
|
let { currentSqrtPrice } = poolData;
|
|
2473
1989
|
let splitSwapResult = {
|
|
2474
1990
|
amountInArray: [],
|
|
@@ -2531,7 +2047,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
|
2531
2047
|
targetSqrtPrice,
|
|
2532
2048
|
currentLiquidity,
|
|
2533
2049
|
remainerAmount,
|
|
2534
|
-
new
|
|
2050
|
+
new import_bn10.default(poolData.feeRate),
|
|
2535
2051
|
byAmountIn
|
|
2536
2052
|
);
|
|
2537
2053
|
tempStepResult = stepResult;
|
|
@@ -2543,7 +2059,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
|
2543
2059
|
splitSwapResult.amountOutArray[i] = splitSwapResult.amountOutArray[i].add(stepResult.amountOut);
|
|
2544
2060
|
splitSwapResult.feeAmountArray[i] = splitSwapResult.feeAmountArray[i].add(stepResult.feeAmount);
|
|
2545
2061
|
if (stepResult.nextSqrtPrice.eq(tick.sqrtPrice)) {
|
|
2546
|
-
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new
|
|
2062
|
+
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new import_bn10.default(-1)) : tick.liquidityNet;
|
|
2547
2063
|
currentLiquidity = signedLiquidityChange.gt(ZERO) ? currentLiquidity.add(signedLiquidityChange) : currentLiquidity.sub(signedLiquidityChange.abs());
|
|
2548
2064
|
currentSqrtPrice = tick.sqrtPrice;
|
|
2549
2065
|
} else {
|
|
@@ -2568,7 +2084,7 @@ function computeSplitSwap(a2b, byAmountIn, amounts, poolData, swapTicks) {
|
|
|
2568
2084
|
break;
|
|
2569
2085
|
}
|
|
2570
2086
|
if (tempStepResult.nextSqrtPrice.eq(tick.sqrtPrice)) {
|
|
2571
|
-
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new
|
|
2087
|
+
signedLiquidityChange = a2b ? tick.liquidityNet.mul(new import_bn10.default(-1)) : tick.liquidityNet;
|
|
2572
2088
|
currentLiquidity = signedLiquidityChange.gt(ZERO) ? currentLiquidity.add(signedLiquidityChange) : currentLiquidity.sub(signedLiquidityChange.abs());
|
|
2573
2089
|
currentSqrtPrice = tick.sqrtPrice;
|
|
2574
2090
|
} else {
|
|
@@ -2623,22 +2139,17 @@ var SplitSwap = class {
|
|
|
2623
2139
|
}
|
|
2624
2140
|
};
|
|
2625
2141
|
|
|
2626
|
-
// src/
|
|
2627
|
-
var
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
const twoDec = new import_decimal9.default(2);
|
|
2632
|
-
const price = new import_decimal9.default((0, import_calc_dlmm2.get_price_x128_from_real_id)(binId, binStep));
|
|
2633
|
-
return price.div(twoDec.pow(128)).mul(import_decimal9.default.pow(10, decimalsA - decimalsB));
|
|
2634
|
-
}
|
|
2635
|
-
static getBinIdFromPrice(price, binStep, decimalsA, decimalsB) {
|
|
2636
|
-
const twoDec = new import_decimal9.default(2);
|
|
2637
|
-
const tenDec = new import_decimal9.default(10);
|
|
2638
|
-
const realid = (0, import_calc_dlmm2.get_real_id_from_price_x128)(new import_decimal9.default(price).mul(tenDec.pow(decimalsB - decimalsA)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(), binStep);
|
|
2639
|
-
return realid;
|
|
2142
|
+
// src/utils/numbers.ts
|
|
2143
|
+
var import_decimal6 = __toESM(require("decimal.js"));
|
|
2144
|
+
function d(value) {
|
|
2145
|
+
if (import_decimal6.default.isDecimal(value)) {
|
|
2146
|
+
return value;
|
|
2640
2147
|
}
|
|
2641
|
-
|
|
2148
|
+
return new import_decimal6.default(value === void 0 ? 0 : value);
|
|
2149
|
+
}
|
|
2150
|
+
function decimalsMultiplier(decimals) {
|
|
2151
|
+
return d(10).pow(d(decimals).abs());
|
|
2152
|
+
}
|
|
2642
2153
|
|
|
2643
2154
|
// src/utils/objects.ts
|
|
2644
2155
|
function getSuiObjectData(resp) {
|
|
@@ -2793,7 +2304,7 @@ function buildPool(objects) {
|
|
|
2793
2304
|
const rewarders = [];
|
|
2794
2305
|
fields.rewarder_manager.fields.rewarders.forEach((item) => {
|
|
2795
2306
|
const { emissions_per_second } = item.fields;
|
|
2796
|
-
const emissionSeconds = MathUtil.fromX64(new
|
|
2307
|
+
const emissionSeconds = MathUtil.fromX64(new import_bn11.default(emissions_per_second));
|
|
2797
2308
|
const emissionsEveryDay = Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24);
|
|
2798
2309
|
rewarders.push({
|
|
2799
2310
|
emissions_per_second,
|
|
@@ -2985,11 +2496,11 @@ function buildTickData(objects) {
|
|
|
2985
2496
|
const possition = {
|
|
2986
2497
|
objectId: getObjectId(objects),
|
|
2987
2498
|
index: asIntN(BigInt(valueItem.index.fields.bits)),
|
|
2988
|
-
sqrtPrice: new
|
|
2989
|
-
liquidityNet: new
|
|
2990
|
-
liquidityGross: new
|
|
2991
|
-
feeGrowthOutsideA: new
|
|
2992
|
-
feeGrowthOutsideB: new
|
|
2499
|
+
sqrtPrice: new import_bn11.default(valueItem.sqrt_price),
|
|
2500
|
+
liquidityNet: new import_bn11.default(valueItem.liquidity_net.fields.bits),
|
|
2501
|
+
liquidityGross: new import_bn11.default(valueItem.liquidity_gross),
|
|
2502
|
+
feeGrowthOutsideA: new import_bn11.default(valueItem.fee_growth_outside_a),
|
|
2503
|
+
feeGrowthOutsideB: new import_bn11.default(valueItem.fee_growth_outside_b),
|
|
2993
2504
|
rewardersGrowthOutside: valueItem.rewards_growth_outside
|
|
2994
2505
|
};
|
|
2995
2506
|
return possition;
|
|
@@ -2999,11 +2510,11 @@ function buildTickDataByEvent(fields) {
|
|
|
2999
2510
|
throw new ClmmpoolsError(`Invalid tick fields.`, "InvalidTickFields" /* InvalidTickFields */);
|
|
3000
2511
|
}
|
|
3001
2512
|
const index = asIntN(BigInt(fields.index.bits));
|
|
3002
|
-
const sqrtPrice = new
|
|
3003
|
-
const liquidityNet = new
|
|
3004
|
-
const liquidityGross = new
|
|
3005
|
-
const feeGrowthOutsideA = new
|
|
3006
|
-
const feeGrowthOutsideB = new
|
|
2513
|
+
const sqrtPrice = new import_bn11.default(fields.sqrt_price);
|
|
2514
|
+
const liquidityNet = new import_bn11.default(fields.liquidity_net.bits);
|
|
2515
|
+
const liquidityGross = new import_bn11.default(fields.liquidity_gross);
|
|
2516
|
+
const feeGrowthOutsideA = new import_bn11.default(fields.fee_growth_outside_a);
|
|
2517
|
+
const feeGrowthOutsideB = new import_bn11.default(fields.fee_growth_outside_b);
|
|
3007
2518
|
const rewardersGrowthOutside = fields.rewards_growth_outside || [];
|
|
3008
2519
|
const tick = {
|
|
3009
2520
|
objectId: "",
|
|
@@ -3022,7 +2533,7 @@ function buildClmmPositionName(pool_index, position_index) {
|
|
|
3022
2533
|
}
|
|
3023
2534
|
|
|
3024
2535
|
// src/utils/tick.ts
|
|
3025
|
-
var
|
|
2536
|
+
var import_bn12 = __toESM(require("bn.js"));
|
|
3026
2537
|
var TickUtil = class {
|
|
3027
2538
|
/**
|
|
3028
2539
|
* Get min tick index.
|
|
@@ -3062,22 +2573,22 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
|
|
|
3062
2573
|
let rewarder_growth_below = growthGlobal[i];
|
|
3063
2574
|
if (tickLower !== null) {
|
|
3064
2575
|
if (pool.current_tick_index < tickLowerIndex) {
|
|
3065
|
-
rewarder_growth_below = growthGlobal[i].sub(new
|
|
2576
|
+
rewarder_growth_below = growthGlobal[i].sub(new import_bn12.default(tickLower.rewardersGrowthOutside[i]));
|
|
3066
2577
|
} else {
|
|
3067
2578
|
rewarder_growth_below = tickLower.rewardersGrowthOutside[i];
|
|
3068
2579
|
}
|
|
3069
2580
|
}
|
|
3070
|
-
let rewarder_growth_above = new
|
|
2581
|
+
let rewarder_growth_above = new import_bn12.default(0);
|
|
3071
2582
|
if (tickUpper !== null) {
|
|
3072
2583
|
if (pool.current_tick_index >= tickUpperIndex) {
|
|
3073
|
-
rewarder_growth_above = growthGlobal[i].sub(new
|
|
2584
|
+
rewarder_growth_above = growthGlobal[i].sub(new import_bn12.default(tickUpper.rewardersGrowthOutside[i]));
|
|
3074
2585
|
} else {
|
|
3075
2586
|
rewarder_growth_above = tickUpper.rewardersGrowthOutside[i];
|
|
3076
2587
|
}
|
|
3077
2588
|
}
|
|
3078
2589
|
const rewGrowthInside = MathUtil.subUnderflowU128(
|
|
3079
|
-
MathUtil.subUnderflowU128(new
|
|
3080
|
-
new
|
|
2590
|
+
MathUtil.subUnderflowU128(new import_bn12.default(growthGlobal[i]), new import_bn12.default(rewarder_growth_below)),
|
|
2591
|
+
new import_bn12.default(rewarder_growth_above)
|
|
3081
2592
|
);
|
|
3082
2593
|
rewarderGrowthInside.push(rewGrowthInside);
|
|
3083
2594
|
}
|
|
@@ -3085,8 +2596,8 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
|
|
|
3085
2596
|
}
|
|
3086
2597
|
|
|
3087
2598
|
// src/utils/transaction-util.ts
|
|
3088
|
-
var
|
|
3089
|
-
var
|
|
2599
|
+
var import_bn13 = __toESM(require("bn.js"));
|
|
2600
|
+
var import_decimal7 = __toESM(require("decimal.js"));
|
|
3090
2601
|
var import_transactions = require("@mysten/sui/transactions");
|
|
3091
2602
|
function findAdjustCoin(coinPair) {
|
|
3092
2603
|
const isAdjustCoinA = CoinAssist.isSuiCoin(coinPair.coinTypeA);
|
|
@@ -3094,7 +2605,7 @@ function findAdjustCoin(coinPair) {
|
|
|
3094
2605
|
return { isAdjustCoinA, isAdjustCoinB };
|
|
3095
2606
|
}
|
|
3096
2607
|
function reverSlippageAmount(slippageAmount, slippage) {
|
|
3097
|
-
return
|
|
2608
|
+
return import_decimal7.default.ceil(d(slippageAmount).div(1 + slippage)).toString();
|
|
3098
2609
|
}
|
|
3099
2610
|
async function printTransaction(tx, isPrint = true) {
|
|
3100
2611
|
console.log(`inputs`, tx.blockData.inputs);
|
|
@@ -3394,7 +2905,7 @@ var _TransactionUtil = class {
|
|
|
3394
2905
|
const liquidityInput = ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts(
|
|
3395
2906
|
Number(params.tick_lower),
|
|
3396
2907
|
Number(params.tick_upper),
|
|
3397
|
-
new
|
|
2908
|
+
new import_bn13.default(coinAmount),
|
|
3398
2909
|
params.fix_amount_a,
|
|
3399
2910
|
true,
|
|
3400
2911
|
slippage,
|
|
@@ -3468,12 +2979,12 @@ var _TransactionUtil = class {
|
|
|
3468
2979
|
max_amount_a = params.amount_a;
|
|
3469
2980
|
min_amount_a = params.amount_a;
|
|
3470
2981
|
max_amount_b = params.amount_b;
|
|
3471
|
-
min_amount_b = new
|
|
2982
|
+
min_amount_b = new import_decimal7.default(params.amount_b).div(new import_decimal7.default(1).plus(new import_decimal7.default(params.slippage))).mul(new import_decimal7.default(1).minus(new import_decimal7.default(params.slippage))).toDecimalPlaces(0).toNumber();
|
|
3472
2983
|
} else {
|
|
3473
2984
|
max_amount_b = params.amount_b;
|
|
3474
2985
|
min_amount_b = params.amount_b;
|
|
3475
2986
|
max_amount_a = params.amount_a;
|
|
3476
|
-
min_amount_a = new
|
|
2987
|
+
min_amount_a = new import_decimal7.default(params.amount_a).div(new import_decimal7.default(1).plus(new import_decimal7.default(params.slippage))).mul(new import_decimal7.default(1).minus(new import_decimal7.default(params.slippage))).toDecimalPlaces(0).toNumber();
|
|
3477
2988
|
}
|
|
3478
2989
|
const args = params.is_open ? [
|
|
3479
2990
|
tx.object(clmmConfig.global_config_id),
|
|
@@ -4462,7 +3973,7 @@ var _TransactionUtil = class {
|
|
|
4462
3973
|
const basePath = splitPath.basePaths[i];
|
|
4463
3974
|
a2b.push(basePath.direction);
|
|
4464
3975
|
poolAddress.push(basePath.poolAddress);
|
|
4465
|
-
rawAmountLimit.push(new
|
|
3976
|
+
rawAmountLimit.push(new import_bn13.default(basePath.inputAmount.toString()));
|
|
4466
3977
|
if (i === 0) {
|
|
4467
3978
|
coinType.push(basePath.fromCoin, basePath.toCoin);
|
|
4468
3979
|
} else {
|
|
@@ -4470,8 +3981,8 @@ var _TransactionUtil = class {
|
|
|
4470
3981
|
}
|
|
4471
3982
|
}
|
|
4472
3983
|
const onePath = {
|
|
4473
|
-
amountIn: new
|
|
4474
|
-
amountOut: new
|
|
3984
|
+
amountIn: new import_bn13.default(splitPath.inputAmount.toString()),
|
|
3985
|
+
amountOut: new import_bn13.default(splitPath.outputAmount.toString()),
|
|
4475
3986
|
poolAddress,
|
|
4476
3987
|
a2b,
|
|
4477
3988
|
rawAmountLimit,
|
|
@@ -4828,9 +4339,9 @@ var TxBlock = class {
|
|
|
4828
4339
|
};
|
|
4829
4340
|
|
|
4830
4341
|
// src/utils/deepbook-utils.ts
|
|
4831
|
-
var
|
|
4342
|
+
var import_bn14 = __toESM(require("bn.js"));
|
|
4832
4343
|
var import_transactions3 = require("@mysten/sui/transactions");
|
|
4833
|
-
var FLOAT_SCALING = new
|
|
4344
|
+
var FLOAT_SCALING = new import_bn14.default(1e9);
|
|
4834
4345
|
var DeepbookUtils = class {
|
|
4835
4346
|
static createAccountCap(senderAddress, sdkOptions, tx, isTransfer = false) {
|
|
4836
4347
|
if (senderAddress.length === 0) {
|
|
@@ -4976,9 +4487,9 @@ var DeepbookUtils = class {
|
|
|
4976
4487
|
static async preSwap(sdk, pool, a2b, amountIn) {
|
|
4977
4488
|
let isExceed = false;
|
|
4978
4489
|
let amountOut = ZERO;
|
|
4979
|
-
let remainAmount = new
|
|
4490
|
+
let remainAmount = new import_bn14.default(amountIn);
|
|
4980
4491
|
let feeAmount = ZERO;
|
|
4981
|
-
const initAmountIn = new
|
|
4492
|
+
const initAmountIn = new import_bn14.default(amountIn);
|
|
4982
4493
|
if (a2b) {
|
|
4983
4494
|
let bids = await this.getPoolBids(sdk, pool.poolID, pool.baseAsset, pool.quoteAsset);
|
|
4984
4495
|
if (bids === null) {
|
|
@@ -4988,16 +4499,16 @@ var DeepbookUtils = class {
|
|
|
4988
4499
|
return b.price - a.price;
|
|
4989
4500
|
});
|
|
4990
4501
|
for (let i = 0; i < bids.length; i += 1) {
|
|
4991
|
-
const curBidAmount = new
|
|
4992
|
-
const curBidPrice = new
|
|
4993
|
-
const fee = curBidAmount.mul(new
|
|
4502
|
+
const curBidAmount = new import_bn14.default(bids[i].quantity);
|
|
4503
|
+
const curBidPrice = new import_bn14.default(bids[i].price);
|
|
4504
|
+
const fee = curBidAmount.mul(new import_bn14.default(curBidPrice)).mul(new import_bn14.default(pool.takerFeeRate)).div(FLOAT_SCALING).div(FLOAT_SCALING);
|
|
4994
4505
|
if (remainAmount.gt(curBidAmount)) {
|
|
4995
4506
|
remainAmount = remainAmount.sub(curBidAmount);
|
|
4996
4507
|
amountOut = amountOut.add(curBidAmount.mul(curBidPrice).div(FLOAT_SCALING).sub(fee));
|
|
4997
4508
|
feeAmount = feeAmount.add(fee);
|
|
4998
4509
|
} else {
|
|
4999
|
-
const curOut = remainAmount.mul(new
|
|
5000
|
-
const curFee = curOut.mul(new
|
|
4510
|
+
const curOut = remainAmount.mul(new import_bn14.default(bids[i].price)).div(FLOAT_SCALING);
|
|
4511
|
+
const curFee = curOut.mul(new import_bn14.default(pool.takerFeeRate)).div(FLOAT_SCALING);
|
|
5001
4512
|
amountOut = amountOut.add(curOut.sub(curFee));
|
|
5002
4513
|
remainAmount = remainAmount.sub(remainAmount);
|
|
5003
4514
|
feeAmount = feeAmount.add(curFee);
|
|
@@ -5012,15 +4523,15 @@ var DeepbookUtils = class {
|
|
|
5012
4523
|
isExceed = true;
|
|
5013
4524
|
}
|
|
5014
4525
|
for (let i = 0; i < asks.length; i += 1) {
|
|
5015
|
-
const curAskAmount = new
|
|
5016
|
-
const fee = curAskAmount.mul(new
|
|
4526
|
+
const curAskAmount = new import_bn14.default(asks[i].price).mul(new import_bn14.default(asks[i].quantity)).div(new import_bn14.default(1e9));
|
|
4527
|
+
const fee = curAskAmount.mul(new import_bn14.default(pool.takerFeeRate)).div(FLOAT_SCALING);
|
|
5017
4528
|
const curAskAmountWithFee = curAskAmount.add(fee);
|
|
5018
4529
|
if (remainAmount.gt(curAskAmount)) {
|
|
5019
|
-
amountOut = amountOut.add(new
|
|
4530
|
+
amountOut = amountOut.add(new import_bn14.default(asks[i].quantity));
|
|
5020
4531
|
remainAmount = remainAmount.sub(curAskAmountWithFee);
|
|
5021
4532
|
feeAmount = feeAmount.add(fee);
|
|
5022
4533
|
} else {
|
|
5023
|
-
const splitNums = new
|
|
4534
|
+
const splitNums = new import_bn14.default(asks[i].quantity).div(new import_bn14.default(pool.lotSize));
|
|
5024
4535
|
const splitAmount = curAskAmountWithFee.div(splitNums);
|
|
5025
4536
|
const swapSplitNum = remainAmount.div(splitAmount);
|
|
5026
4537
|
amountOut = amountOut.add(swapSplitNum.muln(pool.lotSize));
|
|
@@ -5881,7 +5392,7 @@ var PoolModule = class {
|
|
|
5881
5392
|
};
|
|
5882
5393
|
|
|
5883
5394
|
// src/modules/positionModule.ts
|
|
5884
|
-
var
|
|
5395
|
+
var import_bn15 = __toESM(require("bn.js"));
|
|
5885
5396
|
var import_transactions5 = require("@mysten/sui/transactions");
|
|
5886
5397
|
var import_utils15 = require("@mysten/sui/utils");
|
|
5887
5398
|
var PositionModule = class {
|
|
@@ -6103,8 +5614,8 @@ var PositionModule = class {
|
|
|
6103
5614
|
for (let i = 0; i < valueData.length; i += 1) {
|
|
6104
5615
|
const { parsedJson } = valueData[i];
|
|
6105
5616
|
const posRrewarderResult = {
|
|
6106
|
-
feeOwedA: new
|
|
6107
|
-
feeOwedB: new
|
|
5617
|
+
feeOwedA: new import_bn15.default(parsedJson.fee_owned_a),
|
|
5618
|
+
feeOwedB: new import_bn15.default(parsedJson.fee_owned_b),
|
|
6108
5619
|
position_id: parsedJson.position_id
|
|
6109
5620
|
};
|
|
6110
5621
|
result.push(posRrewarderResult);
|
|
@@ -6480,7 +5991,7 @@ var PositionModule = class {
|
|
|
6480
5991
|
};
|
|
6481
5992
|
|
|
6482
5993
|
// src/modules/rewarderModule.ts
|
|
6483
|
-
var
|
|
5994
|
+
var import_bn16 = __toESM(require("bn.js"));
|
|
6484
5995
|
var import_transactions6 = require("@mysten/sui/transactions");
|
|
6485
5996
|
var RewarderModule = class {
|
|
6486
5997
|
_sdk;
|
|
@@ -6506,7 +6017,7 @@ var RewarderModule = class {
|
|
|
6506
6017
|
}
|
|
6507
6018
|
const emissionsEveryDay = [];
|
|
6508
6019
|
for (const rewarderInfo of rewarderInfos) {
|
|
6509
|
-
const emissionSeconds = MathUtil.fromX64(new
|
|
6020
|
+
const emissionSeconds = MathUtil.fromX64(new import_bn16.default(rewarderInfo.emissions_per_second));
|
|
6510
6021
|
emissionsEveryDay.push({
|
|
6511
6022
|
emissions: Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24),
|
|
6512
6023
|
coin_address: rewarderInfo.coinAddress
|
|
@@ -6525,20 +6036,20 @@ var RewarderModule = class {
|
|
|
6525
6036
|
const currentPool = await this.sdk.Pool.getPool(poolID);
|
|
6526
6037
|
const lastTime = currentPool.rewarder_last_updated_time;
|
|
6527
6038
|
currentPool.rewarder_last_updated_time = currentTime.toString();
|
|
6528
|
-
if (Number(currentPool.liquidity) === 0 || currentTime.eq(new
|
|
6039
|
+
if (Number(currentPool.liquidity) === 0 || currentTime.eq(new import_bn16.default(lastTime))) {
|
|
6529
6040
|
return currentPool;
|
|
6530
6041
|
}
|
|
6531
|
-
const timeDelta = currentTime.div(new
|
|
6042
|
+
const timeDelta = currentTime.div(new import_bn16.default(1e3)).sub(new import_bn16.default(lastTime)).add(new import_bn16.default(15));
|
|
6532
6043
|
const rewarderInfos = currentPool.rewarder_infos;
|
|
6533
6044
|
for (let i = 0; i < rewarderInfos.length; i += 1) {
|
|
6534
6045
|
const rewarderInfo = rewarderInfos[i];
|
|
6535
6046
|
const rewarderGrowthDelta = MathUtil.checkMulDivFloor(
|
|
6536
6047
|
timeDelta,
|
|
6537
|
-
new
|
|
6538
|
-
new
|
|
6048
|
+
new import_bn16.default(rewarderInfo.emissions_per_second),
|
|
6049
|
+
new import_bn16.default(currentPool.liquidity),
|
|
6539
6050
|
128
|
|
6540
6051
|
);
|
|
6541
|
-
this.growthGlobal[i] = new
|
|
6052
|
+
this.growthGlobal[i] = new import_bn16.default(rewarderInfo.growth_global).add(new import_bn16.default(rewarderGrowthDelta));
|
|
6542
6053
|
}
|
|
6543
6054
|
return currentPool;
|
|
6544
6055
|
}
|
|
@@ -6553,7 +6064,7 @@ var RewarderModule = class {
|
|
|
6553
6064
|
*/
|
|
6554
6065
|
async posRewardersAmount(poolID, positionHandle, positionID) {
|
|
6555
6066
|
const currentTime = Date.parse((/* @__PURE__ */ new Date()).toString());
|
|
6556
|
-
const pool = await this.updatePoolRewarder(poolID, new
|
|
6067
|
+
const pool = await this.updatePoolRewarder(poolID, new import_bn16.default(currentTime));
|
|
6557
6068
|
const position = await this.sdk.Position.getPositionRewarders(positionHandle, positionID);
|
|
6558
6069
|
if (position === void 0) {
|
|
6559
6070
|
return [];
|
|
@@ -6574,7 +6085,7 @@ var RewarderModule = class {
|
|
|
6574
6085
|
*/
|
|
6575
6086
|
async poolRewardersAmount(accountAddress, poolID) {
|
|
6576
6087
|
const currentTime = Date.parse((/* @__PURE__ */ new Date()).toString());
|
|
6577
|
-
const pool = await this.updatePoolRewarder(poolID, new
|
|
6088
|
+
const pool = await this.updatePoolRewarder(poolID, new import_bn16.default(currentTime));
|
|
6578
6089
|
const positions = await this.sdk.Position.getPositionList(accountAddress, [poolID]);
|
|
6579
6090
|
const tickDatas = await this.getPoolLowerAndUpperTicks(pool.ticks_handle, positions);
|
|
6580
6091
|
const rewarderAmount = [ZERO, ZERO, ZERO];
|
|
@@ -6601,38 +6112,38 @@ var RewarderModule = class {
|
|
|
6601
6112
|
const growthInside = [];
|
|
6602
6113
|
const AmountOwed = [];
|
|
6603
6114
|
if (rewardersInside.length > 0) {
|
|
6604
|
-
let growthDelta0 = MathUtil.subUnderflowU128(rewardersInside[0], new
|
|
6605
|
-
if (growthDelta0.gt(new
|
|
6115
|
+
let growthDelta0 = MathUtil.subUnderflowU128(rewardersInside[0], new import_bn16.default(position.reward_growth_inside_0));
|
|
6116
|
+
if (growthDelta0.gt(new import_bn16.default("3402823669209384634633745948738404"))) {
|
|
6606
6117
|
growthDelta0 = ONE;
|
|
6607
6118
|
}
|
|
6608
|
-
const amountOwed_0 = MathUtil.checkMulShiftRight(new
|
|
6119
|
+
const amountOwed_0 = MathUtil.checkMulShiftRight(new import_bn16.default(position.liquidity), growthDelta0, 64, 128);
|
|
6609
6120
|
growthInside.push(rewardersInside[0]);
|
|
6610
6121
|
AmountOwed.push({
|
|
6611
|
-
amount_owed: new
|
|
6122
|
+
amount_owed: new import_bn16.default(position.reward_amount_owed_0).add(amountOwed_0),
|
|
6612
6123
|
coin_address: pool.rewarder_infos[0].coinAddress
|
|
6613
6124
|
});
|
|
6614
6125
|
}
|
|
6615
6126
|
if (rewardersInside.length > 1) {
|
|
6616
|
-
let growthDelta_1 = MathUtil.subUnderflowU128(rewardersInside[1], new
|
|
6617
|
-
if (growthDelta_1.gt(new
|
|
6127
|
+
let growthDelta_1 = MathUtil.subUnderflowU128(rewardersInside[1], new import_bn16.default(position.reward_growth_inside_1));
|
|
6128
|
+
if (growthDelta_1.gt(new import_bn16.default("3402823669209384634633745948738404"))) {
|
|
6618
6129
|
growthDelta_1 = ONE;
|
|
6619
6130
|
}
|
|
6620
|
-
const amountOwed_1 = MathUtil.checkMulShiftRight(new
|
|
6131
|
+
const amountOwed_1 = MathUtil.checkMulShiftRight(new import_bn16.default(position.liquidity), growthDelta_1, 64, 128);
|
|
6621
6132
|
growthInside.push(rewardersInside[1]);
|
|
6622
6133
|
AmountOwed.push({
|
|
6623
|
-
amount_owed: new
|
|
6134
|
+
amount_owed: new import_bn16.default(position.reward_amount_owed_1).add(amountOwed_1),
|
|
6624
6135
|
coin_address: pool.rewarder_infos[1].coinAddress
|
|
6625
6136
|
});
|
|
6626
6137
|
}
|
|
6627
6138
|
if (rewardersInside.length > 2) {
|
|
6628
|
-
let growthDelta_2 = MathUtil.subUnderflowU128(rewardersInside[2], new
|
|
6629
|
-
if (growthDelta_2.gt(new
|
|
6139
|
+
let growthDelta_2 = MathUtil.subUnderflowU128(rewardersInside[2], new import_bn16.default(position.reward_growth_inside_2));
|
|
6140
|
+
if (growthDelta_2.gt(new import_bn16.default("3402823669209384634633745948738404"))) {
|
|
6630
6141
|
growthDelta_2 = ONE;
|
|
6631
6142
|
}
|
|
6632
|
-
const amountOwed_2 = MathUtil.checkMulShiftRight(new
|
|
6143
|
+
const amountOwed_2 = MathUtil.checkMulShiftRight(new import_bn16.default(position.liquidity), growthDelta_2, 64, 128);
|
|
6633
6144
|
growthInside.push(rewardersInside[2]);
|
|
6634
6145
|
AmountOwed.push({
|
|
6635
|
-
amount_owed: new
|
|
6146
|
+
amount_owed: new import_bn16.default(position.reward_amount_owed_2).add(amountOwed_2),
|
|
6636
6147
|
coin_address: pool.rewarder_infos[2].coinAddress
|
|
6637
6148
|
});
|
|
6638
6149
|
}
|
|
@@ -6746,8 +6257,8 @@ var RewarderModule = class {
|
|
|
6746
6257
|
for (let i = 0; i < valueData.length; i += 1) {
|
|
6747
6258
|
const { parsedJson } = valueData[i];
|
|
6748
6259
|
const posRrewarderResult = {
|
|
6749
|
-
feeOwedA: new
|
|
6750
|
-
feeOwedB: new
|
|
6260
|
+
feeOwedA: new import_bn16.default(parsedJson.fee_owned_a),
|
|
6261
|
+
feeOwedB: new import_bn16.default(parsedJson.fee_owned_b),
|
|
6751
6262
|
position_id: parsedJson.position_id
|
|
6752
6263
|
};
|
|
6753
6264
|
result.push(posRrewarderResult);
|
|
@@ -6810,7 +6321,7 @@ var RewarderModule = class {
|
|
|
6810
6321
|
};
|
|
6811
6322
|
for (let j = 0; j < params[i].rewarderInfo.length; j += 1) {
|
|
6812
6323
|
posRrewarderResult.rewarderAmountOwed.push({
|
|
6813
|
-
amount_owed: new
|
|
6324
|
+
amount_owed: new import_bn16.default(valueData[i].parsedJson.data[j]),
|
|
6814
6325
|
coin_address: params[i].rewarderInfo[j].coinAddress
|
|
6815
6326
|
});
|
|
6816
6327
|
}
|
|
@@ -6881,43 +6392,21 @@ var RewarderModule = class {
|
|
|
6881
6392
|
* @param tx
|
|
6882
6393
|
* @returns
|
|
6883
6394
|
*/
|
|
6884
|
-
async batchCollectRewardePayload(params, tx
|
|
6395
|
+
async batchCollectRewardePayload(params, tx) {
|
|
6885
6396
|
if (!checkInvalidSuiAddress(this._sdk.senderAddress)) {
|
|
6886
6397
|
throw new ClmmpoolsError("this config sdk senderAddress is not set right", "InvalidSendAddress" /* InvalidSendAddress */);
|
|
6887
6398
|
}
|
|
6888
6399
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress, null);
|
|
6889
6400
|
tx = tx || new import_transactions6.Transaction();
|
|
6890
|
-
const
|
|
6401
|
+
const coinIdList = [];
|
|
6891
6402
|
params.forEach((item) => {
|
|
6892
6403
|
const coinTypeA = normalizeCoinType(item.coinTypeA);
|
|
6893
6404
|
const coinTypeB = normalizeCoinType(item.coinTypeB);
|
|
6894
6405
|
if (item.collect_fee) {
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
coinAInput = {
|
|
6900
|
-
targetCoin: inputCoinA,
|
|
6901
|
-
remainCoins: [],
|
|
6902
|
-
isMintZeroCoin: true,
|
|
6903
|
-
tragetCoinAmount: "0"
|
|
6904
|
-
};
|
|
6905
|
-
coinIdMaps.push({ coin: coinAInput, coin_addr: coinTypeA });
|
|
6906
|
-
}
|
|
6907
|
-
let coinBInput = null;
|
|
6908
|
-
if (coinBInput == null) {
|
|
6909
|
-
if (inputCoinB == null) {
|
|
6910
|
-
coinBInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeB, false, true);
|
|
6911
|
-
} else {
|
|
6912
|
-
coinBInput = {
|
|
6913
|
-
targetCoin: inputCoinB,
|
|
6914
|
-
remainCoins: [],
|
|
6915
|
-
isMintZeroCoin: true,
|
|
6916
|
-
tragetCoinAmount: "0"
|
|
6917
|
-
};
|
|
6918
|
-
}
|
|
6919
|
-
coinIdMaps.push({ coin: coinBInput, coin_addr: coinTypeB });
|
|
6920
|
-
}
|
|
6406
|
+
const coinAInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeA, false, true);
|
|
6407
|
+
const coinBInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinTypeB, false, true);
|
|
6408
|
+
coinIdList.push({ coin: coinAInput, coin_addr: coinTypeA });
|
|
6409
|
+
coinIdList.push({ coin: coinBInput, coin_addr: coinTypeB });
|
|
6921
6410
|
tx = this._sdk.Position.createCollectFeeNoSendPaylod(
|
|
6922
6411
|
{
|
|
6923
6412
|
pool_id: item.pool_id,
|
|
@@ -6933,15 +6422,15 @@ var RewarderModule = class {
|
|
|
6933
6422
|
const primaryCoinInputs = [];
|
|
6934
6423
|
item.rewarder_coin_types.forEach((type) => {
|
|
6935
6424
|
const coinType = normalizeCoinType(type);
|
|
6936
|
-
|
|
6937
|
-
if (coinInput === void 0) {
|
|
6938
|
-
coinInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinType, false, true);
|
|
6939
|
-
coinIdMaps.push({ coin: coinInput, coin_addr: coinType });
|
|
6940
|
-
}
|
|
6425
|
+
const coinInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(0), coinType, false, true);
|
|
6941
6426
|
primaryCoinInputs.push(coinInput.targetCoin);
|
|
6427
|
+
coinIdList.push({ coin: coinInput, coin_addr: coinType });
|
|
6942
6428
|
});
|
|
6943
6429
|
tx = this.createCollectRewarderNoSendPaylod(item, tx, primaryCoinInputs);
|
|
6944
6430
|
});
|
|
6431
|
+
coinIdList.forEach((item) => {
|
|
6432
|
+
TransactionUtil.buildTransferCoin(this._sdk, tx, item.coin.targetCoin, item.coin_addr, this._sdk.senderAddress);
|
|
6433
|
+
});
|
|
6945
6434
|
return tx;
|
|
6946
6435
|
}
|
|
6947
6436
|
createCollectRewarderPaylod(params, tx, primaryCoinInputs) {
|
|
@@ -6991,7 +6480,7 @@ var RewarderModule = class {
|
|
|
6991
6480
|
};
|
|
6992
6481
|
|
|
6993
6482
|
// src/modules/routerModule.ts
|
|
6994
|
-
var
|
|
6483
|
+
var import_bn17 = __toESM(require("bn.js"));
|
|
6995
6484
|
var import_cc_graph = require("@syntsugar/cc-graph");
|
|
6996
6485
|
var import_transactions7 = require("@mysten/sui/transactions");
|
|
6997
6486
|
function _pairSymbol(base, quote) {
|
|
@@ -7273,8 +6762,8 @@ var RouterModule = class {
|
|
|
7273
6762
|
if (swapWithMultiPoolParams != null) {
|
|
7274
6763
|
const preSwapResult2 = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
|
|
7275
6764
|
const onePath2 = {
|
|
7276
|
-
amountIn: new
|
|
7277
|
-
amountOut: new
|
|
6765
|
+
amountIn: new import_bn17.default(preSwapResult2.estimatedAmountIn),
|
|
6766
|
+
amountOut: new import_bn17.default(preSwapResult2.estimatedAmountOut),
|
|
7278
6767
|
poolAddress: [preSwapResult2.poolAddress],
|
|
7279
6768
|
a2b: [preSwapResult2.aToB],
|
|
7280
6769
|
rawAmountLimit: byAmountIn ? [preSwapResult2.estimatedAmountOut] : [preSwapResult2.estimatedAmountIn],
|
|
@@ -7287,8 +6776,8 @@ var RouterModule = class {
|
|
|
7287
6776
|
priceSlippagePoint
|
|
7288
6777
|
};
|
|
7289
6778
|
const result2 = {
|
|
7290
|
-
amountIn: new
|
|
7291
|
-
amountOut: new
|
|
6779
|
+
amountIn: new import_bn17.default(preSwapResult2.estimatedAmountIn),
|
|
6780
|
+
amountOut: new import_bn17.default(preSwapResult2.estimatedAmountOut),
|
|
7292
6781
|
paths: [onePath2],
|
|
7293
6782
|
a2b: preSwapResult2.aToB,
|
|
7294
6783
|
b2c: void 0,
|
|
@@ -7310,8 +6799,8 @@ var RouterModule = class {
|
|
|
7310
6799
|
if (swapWithMultiPoolParams != null) {
|
|
7311
6800
|
const preSwapResult2 = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
|
|
7312
6801
|
const onePath2 = {
|
|
7313
|
-
amountIn: new
|
|
7314
|
-
amountOut: new
|
|
6802
|
+
amountIn: new import_bn17.default(preSwapResult2.estimatedAmountIn),
|
|
6803
|
+
amountOut: new import_bn17.default(preSwapResult2.estimatedAmountOut),
|
|
7315
6804
|
poolAddress: [preSwapResult2.poolAddress],
|
|
7316
6805
|
a2b: [preSwapResult2.aToB],
|
|
7317
6806
|
rawAmountLimit: byAmountIn ? [preSwapResult2.estimatedAmountOut] : [preSwapResult2.estimatedAmountIn],
|
|
@@ -7324,8 +6813,8 @@ var RouterModule = class {
|
|
|
7324
6813
|
priceSlippagePoint
|
|
7325
6814
|
};
|
|
7326
6815
|
const result3 = {
|
|
7327
|
-
amountIn: new
|
|
7328
|
-
amountOut: new
|
|
6816
|
+
amountIn: new import_bn17.default(preSwapResult2.estimatedAmountIn),
|
|
6817
|
+
amountOut: new import_bn17.default(preSwapResult2.estimatedAmountOut),
|
|
7329
6818
|
paths: [onePath2],
|
|
7330
6819
|
a2b: preSwapResult2.aToB,
|
|
7331
6820
|
b2c: void 0,
|
|
@@ -7406,8 +6895,8 @@ var RouterModule = class {
|
|
|
7406
6895
|
if (swapWithMultiPoolParams != null) {
|
|
7407
6896
|
const preSwapResult = await this.sdk.Swap.preSwapWithMultiPool(swapWithMultiPoolParams);
|
|
7408
6897
|
const onePath = {
|
|
7409
|
-
amountIn: new
|
|
7410
|
-
amountOut: new
|
|
6898
|
+
amountIn: new import_bn17.default(preSwapResult.estimatedAmountIn),
|
|
6899
|
+
amountOut: new import_bn17.default(preSwapResult.estimatedAmountOut),
|
|
7411
6900
|
poolAddress: [preSwapResult.poolAddress],
|
|
7412
6901
|
a2b: [preSwapResult.aToB],
|
|
7413
6902
|
rawAmountLimit: byAmountIn ? [preSwapResult.estimatedAmountOut] : [preSwapResult.estimatedAmountIn],
|
|
@@ -7420,8 +6909,8 @@ var RouterModule = class {
|
|
|
7420
6909
|
priceSlippagePoint
|
|
7421
6910
|
};
|
|
7422
6911
|
const result = {
|
|
7423
|
-
amountIn: new
|
|
7424
|
-
amountOut: new
|
|
6912
|
+
amountIn: new import_bn17.default(preSwapResult.estimatedAmountIn),
|
|
6913
|
+
amountOut: new import_bn17.default(preSwapResult.estimatedAmountOut),
|
|
7425
6914
|
paths: [onePath],
|
|
7426
6915
|
a2b: preSwapResult.aToB,
|
|
7427
6916
|
b2c: void 0,
|
|
@@ -7505,13 +6994,13 @@ var RouterModule = class {
|
|
|
7505
6994
|
continue;
|
|
7506
6995
|
}
|
|
7507
6996
|
if (params[0].byAmountIn) {
|
|
7508
|
-
const amount = new
|
|
6997
|
+
const amount = new import_bn17.default(valueData[i].parsedJson.data.amount_out);
|
|
7509
6998
|
if (amount.gt(tempMaxAmount)) {
|
|
7510
6999
|
tempIndex = i;
|
|
7511
7000
|
tempMaxAmount = amount;
|
|
7512
7001
|
}
|
|
7513
7002
|
} else {
|
|
7514
|
-
const amount = params[i].stepNums > 1 ? new
|
|
7003
|
+
const amount = params[i].stepNums > 1 ? new import_bn17.default(valueData[i].parsedJson.data.amount_in) : new import_bn17.default(valueData[i].parsedJson.data.amount_in).add(new import_bn17.default(valueData[i].parsedJson.data.fee_amount));
|
|
7515
7004
|
if (amount.lt(tempMaxAmount)) {
|
|
7516
7005
|
tempIndex = i;
|
|
7517
7006
|
tempMaxAmount = amount;
|
|
@@ -7581,8 +7070,8 @@ var RouterModule = class {
|
|
|
7581
7070
|
};
|
|
7582
7071
|
|
|
7583
7072
|
// src/modules/swapModule.ts
|
|
7584
|
-
var
|
|
7585
|
-
var
|
|
7073
|
+
var import_bn18 = __toESM(require("bn.js"));
|
|
7074
|
+
var import_decimal8 = __toESM(require("decimal.js"));
|
|
7586
7075
|
var import_transactions8 = require("@mysten/sui/transactions");
|
|
7587
7076
|
var AMM_SWAP_MODULE = "amm_swap";
|
|
7588
7077
|
var POOL_STRUCT = "Pool";
|
|
@@ -7600,14 +7089,14 @@ var SwapModule = class {
|
|
|
7600
7089
|
const pathCount = item.basePaths.length;
|
|
7601
7090
|
if (pathCount > 0) {
|
|
7602
7091
|
const path = item.basePaths[0];
|
|
7603
|
-
const feeRate = path.label === "Magma" ? new
|
|
7092
|
+
const feeRate = path.label === "Magma" ? new import_decimal8.default(path.feeRate).div(10 ** 6) : new import_decimal8.default(path.feeRate).div(10 ** 9);
|
|
7604
7093
|
const feeAmount = d(path.inputAmount).div(10 ** path.fromDecimal).mul(feeRate);
|
|
7605
7094
|
fee = fee.add(feeAmount);
|
|
7606
7095
|
if (pathCount > 1) {
|
|
7607
7096
|
const path2 = item.basePaths[1];
|
|
7608
|
-
const price1 = path.direction ? path.currentPrice : new
|
|
7609
|
-
const price2 = path2.direction ? path2.currentPrice : new
|
|
7610
|
-
const feeRate2 = path2.label === "Magma" ? new
|
|
7097
|
+
const price1 = path.direction ? path.currentPrice : new import_decimal8.default(1).div(path.currentPrice);
|
|
7098
|
+
const price2 = path2.direction ? path2.currentPrice : new import_decimal8.default(1).div(path2.currentPrice);
|
|
7099
|
+
const feeRate2 = path2.label === "Magma" ? new import_decimal8.default(path2.feeRate).div(10 ** 6) : new import_decimal8.default(path2.feeRate).div(10 ** 9);
|
|
7611
7100
|
const feeAmount2 = d(path2.outputAmount).div(10 ** path2.toDecimal).mul(feeRate2);
|
|
7612
7101
|
const fee2 = feeAmount2.div(price1.mul(price2));
|
|
7613
7102
|
fee = fee.add(fee2);
|
|
@@ -7625,17 +7114,17 @@ var SwapModule = class {
|
|
|
7625
7114
|
const outputAmount = d(path.outputAmount).div(10 ** path.toDecimal);
|
|
7626
7115
|
const inputAmount = d(path.inputAmount).div(10 ** path.fromDecimal);
|
|
7627
7116
|
const rate = outputAmount.div(inputAmount);
|
|
7628
|
-
const cprice = path.direction ? new
|
|
7117
|
+
const cprice = path.direction ? new import_decimal8.default(path.currentPrice) : new import_decimal8.default(1).div(path.currentPrice);
|
|
7629
7118
|
impactValue = impactValue.add(this.calculateSingleImpact(rate, cprice));
|
|
7630
7119
|
}
|
|
7631
7120
|
if (pathCount === 2) {
|
|
7632
7121
|
const path = item.basePaths[0];
|
|
7633
7122
|
const path2 = item.basePaths[1];
|
|
7634
|
-
const cprice1 = path.direction ? new
|
|
7635
|
-
const cprice2 = path2.direction ? new
|
|
7123
|
+
const cprice1 = path.direction ? new import_decimal8.default(path.currentPrice) : new import_decimal8.default(1).div(path.currentPrice);
|
|
7124
|
+
const cprice2 = path2.direction ? new import_decimal8.default(path2.currentPrice) : new import_decimal8.default(1).div(path2.currentPrice);
|
|
7636
7125
|
const cprice = cprice1.mul(cprice2);
|
|
7637
|
-
const outputAmount = new
|
|
7638
|
-
const inputAmount = new
|
|
7126
|
+
const outputAmount = new import_decimal8.default(path2.outputAmount).div(10 ** path2.toDecimal);
|
|
7127
|
+
const inputAmount = new import_decimal8.default(path.inputAmount).div(10 ** path.fromDecimal);
|
|
7639
7128
|
const rate = outputAmount.div(inputAmount);
|
|
7640
7129
|
impactValue = impactValue.add(this.calculateSingleImpact(rate, cprice));
|
|
7641
7130
|
}
|
|
@@ -7697,13 +7186,13 @@ var SwapModule = class {
|
|
|
7697
7186
|
continue;
|
|
7698
7187
|
}
|
|
7699
7188
|
if (params.byAmountIn) {
|
|
7700
|
-
const amount = new
|
|
7189
|
+
const amount = new import_bn18.default(valueData[i].parsedJson.data.amount_out);
|
|
7701
7190
|
if (amount.gt(tempMaxAmount)) {
|
|
7702
7191
|
tempIndex = i;
|
|
7703
7192
|
tempMaxAmount = amount;
|
|
7704
7193
|
}
|
|
7705
7194
|
} else {
|
|
7706
|
-
const amount = new
|
|
7195
|
+
const amount = new import_bn18.default(valueData[i].parsedJson.data.amount_out);
|
|
7707
7196
|
if (amount.lt(tempMaxAmount)) {
|
|
7708
7197
|
tempIndex = i;
|
|
7709
7198
|
tempMaxAmount = amount;
|
|
@@ -7767,7 +7256,7 @@ var SwapModule = class {
|
|
|
7767
7256
|
return this.transformSwapData(params, valueData[0].parsedJson.data);
|
|
7768
7257
|
}
|
|
7769
7258
|
transformSwapData(params, data) {
|
|
7770
|
-
const estimatedAmountIn = data.amount_in && data.fee_amount ? new
|
|
7259
|
+
const estimatedAmountIn = data.amount_in && data.fee_amount ? new import_bn18.default(data.amount_in).add(new import_bn18.default(data.fee_amount)).toString() : "";
|
|
7771
7260
|
return {
|
|
7772
7261
|
poolAddress: params.pool.poolAddress,
|
|
7773
7262
|
currentSqrtPrice: params.currentSqrtPrice,
|
|
@@ -7784,7 +7273,7 @@ var SwapModule = class {
|
|
|
7784
7273
|
transformSwapWithMultiPoolData(params, jsonData) {
|
|
7785
7274
|
const { data } = jsonData;
|
|
7786
7275
|
console.log("json data. ", data);
|
|
7787
|
-
const estimatedAmountIn = data.amount_in && data.fee_amount ? new
|
|
7276
|
+
const estimatedAmountIn = data.amount_in && data.fee_amount ? new import_bn18.default(data.amount_in).add(new import_bn18.default(data.fee_amount)).toString() : "";
|
|
7788
7277
|
return {
|
|
7789
7278
|
poolAddress: params.poolAddress,
|
|
7790
7279
|
estimatedAmountIn,
|
|
@@ -9297,8 +8786,8 @@ var TokenModule = class {
|
|
|
9297
8786
|
};
|
|
9298
8787
|
|
|
9299
8788
|
// src/modules/routerModuleV2.ts
|
|
9300
|
-
var
|
|
9301
|
-
var
|
|
8789
|
+
var import_bn19 = __toESM(require("bn.js"));
|
|
8790
|
+
var import_decimal9 = __toESM(require("decimal.js"));
|
|
9302
8791
|
var import_uuid = require("uuid");
|
|
9303
8792
|
var import_axios = __toESM(require("axios"));
|
|
9304
8793
|
var RouterModuleV2 = class {
|
|
@@ -9315,7 +8804,7 @@ var RouterModuleV2 = class {
|
|
|
9315
8804
|
if (label === "Magma") {
|
|
9316
8805
|
return TickMath.sqrtPriceX64ToPrice(currentSqrtPrice, decimalA, decimalB);
|
|
9317
8806
|
}
|
|
9318
|
-
return new
|
|
8807
|
+
return new import_decimal9.default(currentSqrtPrice.toString()).div(new import_decimal9.default(10).pow(new import_decimal9.default(decimalB + 9 - decimalA)));
|
|
9319
8808
|
}
|
|
9320
8809
|
parseJsonResult(data) {
|
|
9321
8810
|
const result = {
|
|
@@ -9341,12 +8830,12 @@ var RouterModuleV2 = class {
|
|
|
9341
8830
|
outputAmount: basePath.output_amount,
|
|
9342
8831
|
inputAmount: basePath.input_amount,
|
|
9343
8832
|
feeRate: basePath.fee_rate,
|
|
9344
|
-
currentSqrtPrice: new
|
|
9345
|
-
afterSqrtPrice: basePath.label === "Magma" ? new
|
|
8833
|
+
currentSqrtPrice: new import_bn19.default(basePath.current_sqrt_price.toString()),
|
|
8834
|
+
afterSqrtPrice: basePath.label === "Magma" ? new import_bn19.default(basePath.after_sqrt_price.toString()) : ZERO,
|
|
9346
8835
|
fromDecimal: basePath.from_decimal,
|
|
9347
8836
|
toDecimal: basePath.to_decimal,
|
|
9348
8837
|
currentPrice: this.calculatePrice(
|
|
9349
|
-
new
|
|
8838
|
+
new import_bn19.default(basePath.current_sqrt_price.toString()),
|
|
9350
8839
|
basePath.from_decimal,
|
|
9351
8840
|
basePath.to_decimal,
|
|
9352
8841
|
basePath.direction,
|
|
@@ -9429,7 +8918,7 @@ var RouterModuleV2 = class {
|
|
|
9429
8918
|
const priceResult = await this.sdk.Router.priceUseV1(
|
|
9430
8919
|
from,
|
|
9431
8920
|
to,
|
|
9432
|
-
new
|
|
8921
|
+
new import_bn19.default(amount),
|
|
9433
8922
|
byAmountIn,
|
|
9434
8923
|
priceSplitPoint,
|
|
9435
8924
|
partner,
|
|
@@ -9441,7 +8930,7 @@ var RouterModuleV2 = class {
|
|
|
9441
8930
|
if (path.poolAddress.length > 1) {
|
|
9442
8931
|
const fromDecimal0 = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9443
8932
|
const toDecimal0 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9444
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
8933
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
|
|
9445
8934
|
const path0 = {
|
|
9446
8935
|
direction: path.a2b[0],
|
|
9447
8936
|
label: "Magma",
|
|
@@ -9458,7 +8947,7 @@ var RouterModuleV2 = class {
|
|
|
9458
8947
|
};
|
|
9459
8948
|
const fromDecimal1 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9460
8949
|
const toDecimal1 = this.sdk.Router.tokenInfo(path.coinType[2]).decimals;
|
|
9461
|
-
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new
|
|
8950
|
+
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
|
|
9462
8951
|
const path1 = {
|
|
9463
8952
|
direction: path.a2b[1],
|
|
9464
8953
|
label: "Magma",
|
|
@@ -9477,7 +8966,7 @@ var RouterModuleV2 = class {
|
|
|
9477
8966
|
} else {
|
|
9478
8967
|
const fromDecimal = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9479
8968
|
const toDecimal = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9480
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
8969
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
|
|
9481
8970
|
const path0 = {
|
|
9482
8971
|
direction: path.a2b[0],
|
|
9483
8972
|
label: "Magma",
|
|
@@ -9562,7 +9051,7 @@ var RouterModuleV2 = class {
|
|
|
9562
9051
|
const priceResult = await this.sdk.Router.priceUseV1(
|
|
9563
9052
|
from,
|
|
9564
9053
|
to,
|
|
9565
|
-
new
|
|
9054
|
+
new import_bn19.default(amount),
|
|
9566
9055
|
byAmountIn,
|
|
9567
9056
|
priceSplitPoint,
|
|
9568
9057
|
partner,
|
|
@@ -9574,7 +9063,7 @@ var RouterModuleV2 = class {
|
|
|
9574
9063
|
if (path.poolAddress.length > 1) {
|
|
9575
9064
|
const fromDecimal0 = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9576
9065
|
const toDecimal0 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9577
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9066
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), fromDecimal0, toDecimal0) : TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), toDecimal0, fromDecimal0);
|
|
9578
9067
|
const path0 = {
|
|
9579
9068
|
direction: path.a2b[0],
|
|
9580
9069
|
label: "Magma",
|
|
@@ -9591,7 +9080,7 @@ var RouterModuleV2 = class {
|
|
|
9591
9080
|
};
|
|
9592
9081
|
const fromDecimal1 = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9593
9082
|
const toDecimal1 = this.sdk.Router.tokenInfo(path.coinType[2]).decimals;
|
|
9594
|
-
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9083
|
+
const currentPrice1 = path.a2b[1] ? TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[1]), fromDecimal1, toDecimal1) : TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[1]), toDecimal1, fromDecimal1);
|
|
9595
9084
|
const path1 = {
|
|
9596
9085
|
direction: path.a2b[1],
|
|
9597
9086
|
label: "Magma",
|
|
@@ -9610,7 +9099,7 @@ var RouterModuleV2 = class {
|
|
|
9610
9099
|
} else {
|
|
9611
9100
|
const fromDecimal = this.sdk.Router.tokenInfo(path.coinType[0]).decimals;
|
|
9612
9101
|
const toDecimal = this.sdk.Router.tokenInfo(path.coinType[1]).decimals;
|
|
9613
|
-
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new
|
|
9102
|
+
const currentPrice = path.a2b[0] ? TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), fromDecimal, toDecimal) : TickMath.sqrtPriceX64ToPrice(new import_bn19.default(priceResult.currentSqrtPrice[0]), toDecimal, fromDecimal);
|
|
9614
9103
|
const path0 = {
|
|
9615
9104
|
direction: path.a2b[0],
|
|
9616
9105
|
label: "Magma",
|
|
@@ -10483,21 +9972,6 @@ var GaugeModule = class {
|
|
|
10483
9972
|
});
|
|
10484
9973
|
return tx;
|
|
10485
9974
|
}
|
|
10486
|
-
async getAllRewardByPositions(paramsList) {
|
|
10487
|
-
const tx = new import_transactions11.Transaction();
|
|
10488
|
-
const { integrate } = this.sdk.sdkOptions;
|
|
10489
|
-
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
10490
|
-
paramsList.forEach((params) => {
|
|
10491
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB, magma_token];
|
|
10492
|
-
const args = [tx.object(params.gaugeId), tx.object(params.poolId), tx.object(params.positionId), tx.object(CLOCK_ADDRESS)];
|
|
10493
|
-
tx.moveCall({
|
|
10494
|
-
target: `${integrate.published_at}::${Gauge}::get_reward_by_position`,
|
|
10495
|
-
arguments: args,
|
|
10496
|
-
typeArguments
|
|
10497
|
-
});
|
|
10498
|
-
});
|
|
10499
|
-
return tx;
|
|
10500
|
-
}
|
|
10501
9975
|
async getEpochRewardByPool(pool, incentive_tokens) {
|
|
10502
9976
|
const tx = new import_transactions11.Transaction();
|
|
10503
9977
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -10530,893 +10004,8 @@ var GaugeModule = class {
|
|
|
10530
10004
|
}
|
|
10531
10005
|
};
|
|
10532
10006
|
|
|
10533
|
-
// src/
|
|
10534
|
-
var
|
|
10535
|
-
var import_calc_dlmm3 = require("@magmaprotocol/calc_dlmm");
|
|
10536
|
-
var import_decimal13 = __toESM(require("decimal.js"));
|
|
10537
|
-
var DlmmModule = class {
|
|
10538
|
-
_sdk;
|
|
10539
|
-
_cache = {};
|
|
10540
|
-
constructor(sdk) {
|
|
10541
|
-
this._sdk = sdk;
|
|
10542
|
-
}
|
|
10543
|
-
get sdk() {
|
|
10544
|
-
return this._sdk;
|
|
10545
|
-
}
|
|
10546
|
-
async getPoolInfo(pools) {
|
|
10547
|
-
const objects = await this._sdk.fullClient.batchGetObjects(pools, { showContent: true });
|
|
10548
|
-
const poolList = [];
|
|
10549
|
-
objects.forEach((obj) => {
|
|
10550
|
-
if (obj.error != null || obj.data?.content?.dataType !== "moveObject") {
|
|
10551
|
-
throw new ClmmpoolsError(`Invalid objects. error: ${obj.error}`, "InvalidType" /* InvalidType */);
|
|
10552
|
-
}
|
|
10553
|
-
const fields = getObjectFields(obj);
|
|
10554
|
-
poolList.push({
|
|
10555
|
-
pool_id: fields.id.id,
|
|
10556
|
-
bin_step: fields.bin_step,
|
|
10557
|
-
coin_a: fields.x.fields.name,
|
|
10558
|
-
coin_b: fields.y.fields.name,
|
|
10559
|
-
base_factor: fields.params.fields.base_factor,
|
|
10560
|
-
base_fee: fields.params.fields.base_factor / 1e4 * (fields.bin_step / 1e4),
|
|
10561
|
-
active_index: fields.params.fields.active_index
|
|
10562
|
-
});
|
|
10563
|
-
});
|
|
10564
|
-
return poolList;
|
|
10565
|
-
}
|
|
10566
|
-
// eg: fetch pool active_index
|
|
10567
|
-
async fetchPairParams(params) {
|
|
10568
|
-
const tx = new import_transactions12.Transaction();
|
|
10569
|
-
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10570
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10571
|
-
const args = [tx.object(params.pair)];
|
|
10572
|
-
tx.moveCall({
|
|
10573
|
-
target: `${integrate.published_at}::${DlmmScript}::fetch_pair_params`,
|
|
10574
|
-
arguments: args,
|
|
10575
|
-
typeArguments
|
|
10576
|
-
});
|
|
10577
|
-
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10578
|
-
transactionBlock: tx,
|
|
10579
|
-
sender: simulationAccount.address
|
|
10580
|
-
});
|
|
10581
|
-
if (simulateRes.error != null) {
|
|
10582
|
-
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10583
|
-
}
|
|
10584
|
-
let res = {
|
|
10585
|
-
base_factor: 0,
|
|
10586
|
-
filter_period: 0,
|
|
10587
|
-
decay_period: 0,
|
|
10588
|
-
reduction_factor: 0,
|
|
10589
|
-
variable_fee_control: 0,
|
|
10590
|
-
protocol_share: 0,
|
|
10591
|
-
max_volatility_accumulator: 0,
|
|
10592
|
-
volatility_accumulator: 0,
|
|
10593
|
-
volatility_reference: 0,
|
|
10594
|
-
index_reference: 0,
|
|
10595
|
-
time_of_last_update: 0,
|
|
10596
|
-
oracle_index: 0,
|
|
10597
|
-
active_index: 0
|
|
10598
|
-
};
|
|
10599
|
-
simulateRes.events?.forEach((item) => {
|
|
10600
|
-
console.log(extractStructTagFromType(item.type).name);
|
|
10601
|
-
if (extractStructTagFromType(item.type).name === `EventPairParams`) {
|
|
10602
|
-
res = item.parsedJson.params;
|
|
10603
|
-
}
|
|
10604
|
-
});
|
|
10605
|
-
return res;
|
|
10606
|
-
}
|
|
10607
|
-
// NOTE: x, y should be sorted
|
|
10608
|
-
async createPairPayload(params) {
|
|
10609
|
-
const storage_id = (0, import_calc_dlmm3.get_storage_id_from_real_id)(
|
|
10610
|
-
BinMath.getBinIdFromPrice(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal)
|
|
10611
|
-
);
|
|
10612
|
-
const tx = new import_transactions12.Transaction();
|
|
10613
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10614
|
-
const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10615
|
-
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10616
|
-
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10617
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10618
|
-
const args = [
|
|
10619
|
-
tx.object(dlmmConfig.factory),
|
|
10620
|
-
tx.object(global_config_id),
|
|
10621
|
-
tx.pure.u64(params.base_fee),
|
|
10622
|
-
tx.pure.u16(params.bin_step),
|
|
10623
|
-
tx.pure.u32(storage_id)
|
|
10624
|
-
];
|
|
10625
|
-
tx.moveCall({
|
|
10626
|
-
target: `${integrate.published_at}::${DlmmScript}::create_pair`,
|
|
10627
|
-
typeArguments,
|
|
10628
|
-
arguments: args
|
|
10629
|
-
});
|
|
10630
|
-
return tx;
|
|
10631
|
-
}
|
|
10632
|
-
// async mintByStrategySingle(params: MintByStrategySingleParams): Promise<Transaction> {}
|
|
10633
|
-
async mintByStrategy(params) {
|
|
10634
|
-
const tx = new import_transactions12.Transaction();
|
|
10635
|
-
const slippage = new import_decimal13.default(params.slippage);
|
|
10636
|
-
const lower_slippage = new import_decimal13.default(1).sub(slippage.div(new import_decimal13.default(1e4)));
|
|
10637
|
-
const upper_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
10638
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10639
|
-
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10640
|
-
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10641
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10642
|
-
const price = (0, import_calc_dlmm3.get_price_x128_from_real_id)(params.active_bin, params.bin_step);
|
|
10643
|
-
const min_price = new import_decimal13.default(price).mul(lower_slippage);
|
|
10644
|
-
const max_price = new import_decimal13.default(price).mul(upper_slippage);
|
|
10645
|
-
const active_min = (0, import_calc_dlmm3.get_storage_id_from_real_id)((0, import_calc_dlmm3.get_real_id_from_price_x128)(min_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10646
|
-
const active_max = (0, import_calc_dlmm3.get_storage_id_from_real_id)((0, import_calc_dlmm3.get_real_id_from_price_x128)(max_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10647
|
-
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10648
|
-
let primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10649
|
-
let primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10650
|
-
let amount_min = 0;
|
|
10651
|
-
let amount_max = 0;
|
|
10652
|
-
if (params.fixCoinA) {
|
|
10653
|
-
amount_min = new import_decimal13.default(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10654
|
-
amount_max = new import_decimal13.default(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10655
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10656
|
-
}
|
|
10657
|
-
if (params.fixCoinB) {
|
|
10658
|
-
amount_min = new import_decimal13.default(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10659
|
-
amount_max = new import_decimal13.default(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10660
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10661
|
-
}
|
|
10662
|
-
if (params.fixCoinA && params.fixCoinB) {
|
|
10663
|
-
} else if (params.fixCoinA) {
|
|
10664
|
-
params.amountBTotal = 0;
|
|
10665
|
-
} else if (params.fixCoinB) {
|
|
10666
|
-
params.amountATotal = 0;
|
|
10667
|
-
}
|
|
10668
|
-
const args = [
|
|
10669
|
-
tx.object(params.pair),
|
|
10670
|
-
tx.object(dlmmConfig.factory),
|
|
10671
|
-
primaryCoinAInputs.targetCoin,
|
|
10672
|
-
primaryCoinBInputs.targetCoin,
|
|
10673
|
-
tx.pure.u64(params.amountATotal),
|
|
10674
|
-
tx.pure.u64(params.amountBTotal),
|
|
10675
|
-
tx.pure.u8(params.strategy),
|
|
10676
|
-
tx.pure.u32((0, import_calc_dlmm3.get_storage_id_from_real_id)(params.min_bin)),
|
|
10677
|
-
tx.pure.u32((0, import_calc_dlmm3.get_storage_id_from_real_id)(params.max_bin)),
|
|
10678
|
-
tx.pure.u32(active_min),
|
|
10679
|
-
tx.pure.u32(active_max),
|
|
10680
|
-
tx.pure.u64(amount_min),
|
|
10681
|
-
tx.pure.u64(amount_max),
|
|
10682
|
-
tx.object(CLOCK_ADDRESS)
|
|
10683
|
-
];
|
|
10684
|
-
tx.moveCall({
|
|
10685
|
-
target: `${integrate.published_at}::${DlmmScript}::mint_by_strategy`,
|
|
10686
|
-
typeArguments,
|
|
10687
|
-
arguments: args
|
|
10688
|
-
});
|
|
10689
|
-
return tx;
|
|
10690
|
-
}
|
|
10691
|
-
// Create a position by percent
|
|
10692
|
-
async mintPercent(params) {
|
|
10693
|
-
const tx = new import_transactions12.Transaction();
|
|
10694
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10695
|
-
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10696
|
-
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10697
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10698
|
-
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10699
|
-
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10700
|
-
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10701
|
-
const args = [
|
|
10702
|
-
tx.object(params.pair),
|
|
10703
|
-
tx.object(dlmmConfig.factory),
|
|
10704
|
-
primaryCoinAInputs.targetCoin,
|
|
10705
|
-
primaryCoinBInputs.targetCoin,
|
|
10706
|
-
tx.pure.u64(params.amountATotal),
|
|
10707
|
-
tx.pure.u64(params.amountBTotal),
|
|
10708
|
-
tx.pure.vector("u32", params.storageIds),
|
|
10709
|
-
tx.pure.vector("u64", params.binsAPercent),
|
|
10710
|
-
tx.pure.vector("u64", params.binsBPercent),
|
|
10711
|
-
tx.pure.address(params.to),
|
|
10712
|
-
tx.object(CLOCK_ADDRESS)
|
|
10713
|
-
];
|
|
10714
|
-
tx.moveCall({
|
|
10715
|
-
target: `${integrate.published_at}::${DlmmScript}::mint_percent`,
|
|
10716
|
-
typeArguments,
|
|
10717
|
-
arguments: args
|
|
10718
|
-
});
|
|
10719
|
-
return tx;
|
|
10720
|
-
}
|
|
10721
|
-
// Create a position by amount
|
|
10722
|
-
async createPositionByAmount(params) {
|
|
10723
|
-
const tx = new import_transactions12.Transaction();
|
|
10724
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10725
|
-
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10726
|
-
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10727
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10728
|
-
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10729
|
-
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10730
|
-
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10731
|
-
const args = [
|
|
10732
|
-
tx.object(params.pair),
|
|
10733
|
-
tx.object(dlmmConfig.factory),
|
|
10734
|
-
primaryCoinAInputs.targetCoin,
|
|
10735
|
-
primaryCoinBInputs.targetCoin,
|
|
10736
|
-
tx.pure.vector("u32", params.storageIds),
|
|
10737
|
-
tx.pure.vector("u64", params.amountsA),
|
|
10738
|
-
tx.pure.vector("u64", params.amountsB),
|
|
10739
|
-
tx.pure.address(params.to),
|
|
10740
|
-
tx.object(CLOCK_ADDRESS)
|
|
10741
|
-
];
|
|
10742
|
-
tx.moveCall({
|
|
10743
|
-
target: `${integrate.published_at}::${DlmmScript}::mint_amounts`,
|
|
10744
|
-
typeArguments,
|
|
10745
|
-
arguments: args
|
|
10746
|
-
});
|
|
10747
|
-
return tx;
|
|
10748
|
-
}
|
|
10749
|
-
async addLiquidity(params) {
|
|
10750
|
-
if (params.rewards_token.length === 0) {
|
|
10751
|
-
return this._raisePositionByAmounts(params);
|
|
10752
|
-
}
|
|
10753
|
-
return this._raisePositionByAmountsReward(params);
|
|
10754
|
-
}
|
|
10755
|
-
async _raisePositionByAmounts(params) {
|
|
10756
|
-
const tx = new import_transactions12.Transaction();
|
|
10757
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10758
|
-
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10759
|
-
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10760
|
-
const typeArguments = [params.coin_a, params.coin_b];
|
|
10761
|
-
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10762
|
-
const amountATotal = params.amounts_a.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10763
|
-
const amountBTotal = params.amounts_b.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10764
|
-
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coin_a, false, true);
|
|
10765
|
-
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coin_b, false, true);
|
|
10766
|
-
const args = [
|
|
10767
|
-
tx.object(params.pool_id),
|
|
10768
|
-
tx.object(dlmmConfig.factory),
|
|
10769
|
-
tx.object(params.position_id),
|
|
10770
|
-
primaryCoinAInputs.targetCoin,
|
|
10771
|
-
primaryCoinBInputs.targetCoin,
|
|
10772
|
-
tx.pure.vector("u64", params.amounts_a),
|
|
10773
|
-
tx.pure.vector("u64", params.amounts_b),
|
|
10774
|
-
tx.pure.address(params.receiver),
|
|
10775
|
-
tx.object(CLOCK_ADDRESS)
|
|
10776
|
-
];
|
|
10777
|
-
tx.moveCall({
|
|
10778
|
-
target: `${integrate.published_at}::${DlmmScript}::raise_position_by_amounts`,
|
|
10779
|
-
typeArguments,
|
|
10780
|
-
arguments: args
|
|
10781
|
-
});
|
|
10782
|
-
return tx;
|
|
10783
|
-
}
|
|
10784
|
-
async _raisePositionByAmountsReward(params) {
|
|
10785
|
-
const tx = new import_transactions12.Transaction();
|
|
10786
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10787
|
-
const { dlmm_pool, integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10788
|
-
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10789
|
-
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10790
|
-
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10791
|
-
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10792
|
-
const amountATotal = params.amounts_a.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10793
|
-
const amountBTotal = params.amounts_b.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10794
|
-
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coin_a, false, true);
|
|
10795
|
-
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coin_b, false, true);
|
|
10796
|
-
const args = [
|
|
10797
|
-
tx.object(params.pool_id),
|
|
10798
|
-
tx.object(dlmmConfig.factory),
|
|
10799
|
-
tx.object(clmmConfigs.global_vault_id),
|
|
10800
|
-
tx.object(params.position_id),
|
|
10801
|
-
primaryCoinAInputs.targetCoin,
|
|
10802
|
-
primaryCoinBInputs.targetCoin,
|
|
10803
|
-
tx.pure.vector("u64", params.amounts_a),
|
|
10804
|
-
tx.pure.vector("u64", params.amounts_b),
|
|
10805
|
-
tx.pure.address(params.receiver),
|
|
10806
|
-
tx.object(CLOCK_ADDRESS)
|
|
10807
|
-
];
|
|
10808
|
-
tx.moveCall({
|
|
10809
|
-
target: `${integrate.published_at}::${DlmmScript}::raise_position_by_amounts_reward${params.rewards_token.length}`,
|
|
10810
|
-
typeArguments,
|
|
10811
|
-
arguments: args
|
|
10812
|
-
});
|
|
10813
|
-
return tx;
|
|
10814
|
-
}
|
|
10815
|
-
async burnPosition(params) {
|
|
10816
|
-
const tx = new import_transactions12.Transaction();
|
|
10817
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10818
|
-
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10819
|
-
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10820
|
-
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10821
|
-
let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
10822
|
-
let target = `${integrate.published_at}::${DlmmScript}::burn_position`;
|
|
10823
|
-
if (params.rewards_token.length > 0) {
|
|
10824
|
-
args = [tx.object(params.pool_id), tx.object(clmmConfigs.global_vault_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
10825
|
-
target = `${integrate.published_at}::${DlmmScript}::burn_position_reward${params.rewards_token.length}`;
|
|
10826
|
-
}
|
|
10827
|
-
tx.moveCall({
|
|
10828
|
-
target,
|
|
10829
|
-
typeArguments,
|
|
10830
|
-
arguments: args
|
|
10831
|
-
});
|
|
10832
|
-
return tx;
|
|
10833
|
-
}
|
|
10834
|
-
async shrinkPosition(params) {
|
|
10835
|
-
const tx = new import_transactions12.Transaction();
|
|
10836
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10837
|
-
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10838
|
-
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10839
|
-
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10840
|
-
let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.pure.u64(params.delta_percentage), tx.object(CLOCK_ADDRESS)];
|
|
10841
|
-
let target = `${integrate.published_at}::${DlmmScript}::shrink_position`;
|
|
10842
|
-
if (params.rewards_token.length > 0) {
|
|
10843
|
-
args = [
|
|
10844
|
-
tx.object(params.pool_id),
|
|
10845
|
-
tx.object(clmmConfigs.global_vault_id),
|
|
10846
|
-
tx.object(params.position_id),
|
|
10847
|
-
tx.pure.u64(params.delta_percentage),
|
|
10848
|
-
tx.object(CLOCK_ADDRESS)
|
|
10849
|
-
];
|
|
10850
|
-
target = `${integrate.published_at}::${DlmmScript}::shrink_position_reward${params.rewards_token.length}`;
|
|
10851
|
-
}
|
|
10852
|
-
tx.moveCall({
|
|
10853
|
-
target,
|
|
10854
|
-
typeArguments,
|
|
10855
|
-
arguments: args
|
|
10856
|
-
});
|
|
10857
|
-
return tx;
|
|
10858
|
-
}
|
|
10859
|
-
async collectFeeAndReward(params) {
|
|
10860
|
-
let tx = new import_transactions12.Transaction();
|
|
10861
|
-
tx = await this.collectFees(params);
|
|
10862
|
-
if (params.rewards_token.length > 0) {
|
|
10863
|
-
tx = await this.collectReward(params);
|
|
10864
|
-
}
|
|
10865
|
-
return tx;
|
|
10866
|
-
}
|
|
10867
|
-
async collectReward(params, transaction) {
|
|
10868
|
-
const tx = transaction || new import_transactions12.Transaction();
|
|
10869
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10870
|
-
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10871
|
-
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10872
|
-
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10873
|
-
const args = [
|
|
10874
|
-
tx.object(params.pool_id),
|
|
10875
|
-
tx.object(clmmConfigs.global_vault_id),
|
|
10876
|
-
tx.object(params.position_id),
|
|
10877
|
-
tx.object(CLOCK_ADDRESS)
|
|
10878
|
-
];
|
|
10879
|
-
let target = `${integrate.published_at}::${DlmmScript}::collect_reward`;
|
|
10880
|
-
if (params.rewards_token.length > 1) {
|
|
10881
|
-
target = `${integrate.published_at}::${DlmmScript}::collect_reward${params.rewards_token.length}`;
|
|
10882
|
-
}
|
|
10883
|
-
tx.moveCall({
|
|
10884
|
-
target,
|
|
10885
|
-
typeArguments,
|
|
10886
|
-
arguments: args
|
|
10887
|
-
});
|
|
10888
|
-
return tx;
|
|
10889
|
-
}
|
|
10890
|
-
async collectFees(params, transaction) {
|
|
10891
|
-
const tx = transaction || new import_transactions12.Transaction();
|
|
10892
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10893
|
-
const { integrate } = this.sdk.sdkOptions;
|
|
10894
|
-
const typeArguments = [params.coin_a, params.coin_b];
|
|
10895
|
-
const args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
10896
|
-
const target = `${integrate.published_at}::${DlmmScript}::collect_fees`;
|
|
10897
|
-
tx.moveCall({
|
|
10898
|
-
target,
|
|
10899
|
-
typeArguments,
|
|
10900
|
-
arguments: args
|
|
10901
|
-
});
|
|
10902
|
-
return tx;
|
|
10903
|
-
}
|
|
10904
|
-
async createPairAddLiquidity(params) {
|
|
10905
|
-
const tx = new import_transactions12.Transaction();
|
|
10906
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10907
|
-
const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10908
|
-
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10909
|
-
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10910
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10911
|
-
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10912
|
-
const amountATotal = params.amountsX.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10913
|
-
const amountBTotal = params.amountsY.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10914
|
-
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coinTypeA, false, true);
|
|
10915
|
-
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coinTypeB, false, true);
|
|
10916
|
-
const storageIds = [];
|
|
10917
|
-
params.realIds.forEach((i) => {
|
|
10918
|
-
storageIds.push((0, import_calc_dlmm3.get_storage_id_from_real_id)(i));
|
|
10919
|
-
});
|
|
10920
|
-
const args = [
|
|
10921
|
-
tx.object(dlmmConfig.factory),
|
|
10922
|
-
tx.object(global_config_id),
|
|
10923
|
-
tx.pure.u64(params.baseFee),
|
|
10924
|
-
tx.pure.u16(params.binStep),
|
|
10925
|
-
tx.pure.u32((0, import_calc_dlmm3.get_storage_id_from_real_id)(params.activeId)),
|
|
10926
|
-
primaryCoinAInputs.targetCoin,
|
|
10927
|
-
primaryCoinBInputs.targetCoin,
|
|
10928
|
-
tx.pure.vector("u32", storageIds),
|
|
10929
|
-
tx.pure.vector("u64", params.amountsX),
|
|
10930
|
-
tx.pure.vector("u64", params.amountsY),
|
|
10931
|
-
tx.pure.address(params.to),
|
|
10932
|
-
tx.object(CLOCK_ADDRESS)
|
|
10933
|
-
];
|
|
10934
|
-
const target = `${integrate.published_at}::${DlmmScript}::create_pair_add_liquidity`;
|
|
10935
|
-
tx.moveCall({
|
|
10936
|
-
target,
|
|
10937
|
-
typeArguments,
|
|
10938
|
-
arguments: args
|
|
10939
|
-
});
|
|
10940
|
-
return tx;
|
|
10941
|
-
}
|
|
10942
|
-
async swap(params) {
|
|
10943
|
-
const tx = new import_transactions12.Transaction();
|
|
10944
|
-
tx.setSender(this.sdk.senderAddress);
|
|
10945
|
-
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10946
|
-
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10947
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10948
|
-
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10949
|
-
const primaryCoinInputA = TransactionUtil.buildCoinForAmount(
|
|
10950
|
-
tx,
|
|
10951
|
-
allCoinAsset,
|
|
10952
|
-
params.swapForY ? BigInt(params.amountIn) : BigInt(0),
|
|
10953
|
-
params.coinTypeA,
|
|
10954
|
-
false,
|
|
10955
|
-
true
|
|
10956
|
-
);
|
|
10957
|
-
const primaryCoinInputB = TransactionUtil.buildCoinForAmount(
|
|
10958
|
-
tx,
|
|
10959
|
-
allCoinAsset,
|
|
10960
|
-
params.swapForY ? BigInt(0) : BigInt(params.amountIn),
|
|
10961
|
-
params.coinTypeB,
|
|
10962
|
-
false,
|
|
10963
|
-
true
|
|
10964
|
-
);
|
|
10965
|
-
const args = [
|
|
10966
|
-
tx.object(params.pair),
|
|
10967
|
-
tx.object(global_config_id),
|
|
10968
|
-
primaryCoinInputA.targetCoin,
|
|
10969
|
-
primaryCoinInputB.targetCoin,
|
|
10970
|
-
tx.pure.u64(params.amountIn),
|
|
10971
|
-
tx.pure.u64(params.minAmountOut),
|
|
10972
|
-
tx.pure.bool(params.swapForY),
|
|
10973
|
-
tx.pure.address(params.to),
|
|
10974
|
-
tx.object(CLOCK_ADDRESS)
|
|
10975
|
-
];
|
|
10976
|
-
tx.moveCall({
|
|
10977
|
-
target: `${integrate.published_at}::${DlmmScript}::swap`,
|
|
10978
|
-
typeArguments,
|
|
10979
|
-
arguments: args
|
|
10980
|
-
});
|
|
10981
|
-
return tx;
|
|
10982
|
-
}
|
|
10983
|
-
async fetchBins(params) {
|
|
10984
|
-
const tx = new import_transactions12.Transaction();
|
|
10985
|
-
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10986
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10987
|
-
const args = [tx.object(params.pair), tx.pure.u64(params.offset), tx.pure.u64(params.limit)];
|
|
10988
|
-
tx.moveCall({
|
|
10989
|
-
target: `${integrate.published_at}::${DlmmScript}::fetch_bins`,
|
|
10990
|
-
arguments: args,
|
|
10991
|
-
typeArguments
|
|
10992
|
-
});
|
|
10993
|
-
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10994
|
-
transactionBlock: tx,
|
|
10995
|
-
sender: simulationAccount.address
|
|
10996
|
-
});
|
|
10997
|
-
if (simulateRes.error != null) {
|
|
10998
|
-
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10999
|
-
}
|
|
11000
|
-
let res = [];
|
|
11001
|
-
simulateRes.events?.forEach((item) => {
|
|
11002
|
-
if (extractStructTagFromType(item.type).name === `EventFetchBins`) {
|
|
11003
|
-
const { bins } = item.parsedJson;
|
|
11004
|
-
res = bins;
|
|
11005
|
-
}
|
|
11006
|
-
});
|
|
11007
|
-
return res;
|
|
11008
|
-
}
|
|
11009
|
-
/**
|
|
11010
|
-
* Gets a list of positions for the given account address.
|
|
11011
|
-
* @param accountAddress The account address to get positions for.
|
|
11012
|
-
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
11013
|
-
* @returns array of Position objects.
|
|
11014
|
-
*/
|
|
11015
|
-
async getUserPositionById(positionId, showDisplay = true) {
|
|
11016
|
-
let position;
|
|
11017
|
-
const ownerRes = await this._sdk.fullClient.getObject({
|
|
11018
|
-
id: positionId,
|
|
11019
|
-
options: { showContent: true, showType: true, showDisplay, showOwner: true }
|
|
11020
|
-
});
|
|
11021
|
-
const type = extractStructTagFromType(ownerRes.data.type);
|
|
11022
|
-
if (type.full_address === this.buildPositionType()) {
|
|
11023
|
-
position = this.buildPosition(ownerRes);
|
|
11024
|
-
} else {
|
|
11025
|
-
throw new ClmmpoolsError(`Dlmm Position not exists. Get Position error:${ownerRes.error}`, "InvalidPositionObject" /* InvalidPositionObject */);
|
|
11026
|
-
}
|
|
11027
|
-
const poolMap = /* @__PURE__ */ new Set();
|
|
11028
|
-
poolMap.add(position.pool);
|
|
11029
|
-
const pool = (await this.getPoolInfo(Array.from(poolMap)))[0];
|
|
11030
|
-
const _params = [];
|
|
11031
|
-
_params.push({
|
|
11032
|
-
pool_id: pool.pool_id,
|
|
11033
|
-
coin_a: pool.coin_a,
|
|
11034
|
-
coin_b: pool.coin_b
|
|
11035
|
-
});
|
|
11036
|
-
const pool_reward_coins = await this.getPairRewarders(_params);
|
|
11037
|
-
const positionLiquidity = await this.getPositionLiquidity({
|
|
11038
|
-
pair: position.pool,
|
|
11039
|
-
positionId: position.pos_object_id,
|
|
11040
|
-
coinTypeA: pool.coin_a,
|
|
11041
|
-
coinTypeB: pool.coin_b
|
|
11042
|
-
});
|
|
11043
|
-
const rewards_token = pool_reward_coins.get(position.pool) || [];
|
|
11044
|
-
let positionRewards = { position_id: position.pos_object_id, reward: [], amount: [] };
|
|
11045
|
-
if (rewards_token.length > 0) {
|
|
11046
|
-
positionRewards = await this.getEarnedRewards({
|
|
11047
|
-
pool_id: position.pool,
|
|
11048
|
-
position_id: position.pos_object_id,
|
|
11049
|
-
coin_a: pool.coin_a,
|
|
11050
|
-
coin_b: pool.coin_b,
|
|
11051
|
-
rewards_token: pool_reward_coins.get(position.pool) || []
|
|
11052
|
-
});
|
|
11053
|
-
}
|
|
11054
|
-
const positionFees = await this.getEarnedFees({
|
|
11055
|
-
pool_id: position.pool,
|
|
11056
|
-
position_id: position.pos_object_id,
|
|
11057
|
-
coin_a: pool.coin_a,
|
|
11058
|
-
coin_b: pool.coin_b
|
|
11059
|
-
});
|
|
11060
|
-
return {
|
|
11061
|
-
position,
|
|
11062
|
-
liquidity: positionLiquidity,
|
|
11063
|
-
rewards: positionRewards,
|
|
11064
|
-
fees: positionFees,
|
|
11065
|
-
contractPool: pool
|
|
11066
|
-
};
|
|
11067
|
-
}
|
|
11068
|
-
/**
|
|
11069
|
-
* Gets a list of positions for the given account address.
|
|
11070
|
-
* @param accountAddress The account address to get positions for.
|
|
11071
|
-
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
11072
|
-
* @returns array of Position objects.
|
|
11073
|
-
*/
|
|
11074
|
-
async getUserPositions(accountAddress, assignPoolIds = [], showDisplay = true) {
|
|
11075
|
-
const allPosition = [];
|
|
11076
|
-
const ownerRes = await this._sdk.fullClient.getOwnedObjectsByPage(accountAddress, {
|
|
11077
|
-
options: { showType: true, showContent: true, showDisplay, showOwner: true },
|
|
11078
|
-
filter: { Package: this._sdk.sdkOptions.dlmm_pool.package_id }
|
|
11079
|
-
});
|
|
11080
|
-
const hasAssignPoolIds = assignPoolIds.length > 0;
|
|
11081
|
-
for (const item of ownerRes.data) {
|
|
11082
|
-
const type = extractStructTagFromType(item.data.type);
|
|
11083
|
-
if (type.full_address === this.buildPositionType()) {
|
|
11084
|
-
const position = this.buildPosition(item);
|
|
11085
|
-
const cacheKey = `${position.pos_object_id}_getPositionList`;
|
|
11086
|
-
this.updateCache(cacheKey, position, cacheTime24h);
|
|
11087
|
-
if (hasAssignPoolIds) {
|
|
11088
|
-
if (assignPoolIds.includes(position.pool)) {
|
|
11089
|
-
allPosition.push(position);
|
|
11090
|
-
}
|
|
11091
|
-
} else {
|
|
11092
|
-
allPosition.push(position);
|
|
11093
|
-
}
|
|
11094
|
-
}
|
|
11095
|
-
}
|
|
11096
|
-
const poolMap = /* @__PURE__ */ new Set();
|
|
11097
|
-
for (const item of allPosition) {
|
|
11098
|
-
poolMap.add(item.pool);
|
|
11099
|
-
}
|
|
11100
|
-
const poolList = await this.getPoolInfo(Array.from(poolMap));
|
|
11101
|
-
this.updateCache(`${DlmmScript}_positionList_poolList`, poolList, cacheTime24h);
|
|
11102
|
-
const _params = [];
|
|
11103
|
-
for (const pool of poolList) {
|
|
11104
|
-
_params.push({
|
|
11105
|
-
pool_id: pool.pool_id,
|
|
11106
|
-
coin_a: pool.coin_a,
|
|
11107
|
-
coin_b: pool.coin_b
|
|
11108
|
-
});
|
|
11109
|
-
}
|
|
11110
|
-
const pool_reward_coins = await this.getPairRewarders(_params);
|
|
11111
|
-
const out = [];
|
|
11112
|
-
for (const item of allPosition) {
|
|
11113
|
-
const pool = poolList.find((pool2) => pool2.pool_id === item.pool);
|
|
11114
|
-
const positionLiquidity = await this.getPositionLiquidity({
|
|
11115
|
-
pair: item.pool,
|
|
11116
|
-
positionId: item.pos_object_id,
|
|
11117
|
-
coinTypeA: pool.coin_a,
|
|
11118
|
-
coinTypeB: pool.coin_b
|
|
11119
|
-
});
|
|
11120
|
-
const rewards_token = pool_reward_coins.get(item.pool) || [];
|
|
11121
|
-
let positionRewards = { position_id: item.pos_object_id, reward: [], amount: [] };
|
|
11122
|
-
if (rewards_token.length > 0) {
|
|
11123
|
-
positionRewards = await this.getEarnedRewards({
|
|
11124
|
-
pool_id: item.pool,
|
|
11125
|
-
position_id: item.pos_object_id,
|
|
11126
|
-
coin_a: pool.coin_a,
|
|
11127
|
-
coin_b: pool.coin_b,
|
|
11128
|
-
rewards_token: pool_reward_coins.get(item.pool) || []
|
|
11129
|
-
});
|
|
11130
|
-
}
|
|
11131
|
-
const positionFees = await this.getEarnedFees({
|
|
11132
|
-
pool_id: item.pool,
|
|
11133
|
-
position_id: item.pos_object_id,
|
|
11134
|
-
coin_a: pool.coin_a,
|
|
11135
|
-
coin_b: pool.coin_b
|
|
11136
|
-
});
|
|
11137
|
-
out.push({
|
|
11138
|
-
position: item,
|
|
11139
|
-
liquidity: positionLiquidity,
|
|
11140
|
-
rewards: positionRewards,
|
|
11141
|
-
fees: positionFees,
|
|
11142
|
-
contractPool: pool
|
|
11143
|
-
});
|
|
11144
|
-
}
|
|
11145
|
-
return out;
|
|
11146
|
-
}
|
|
11147
|
-
buildPosition(object) {
|
|
11148
|
-
if (object.error != null || object.data?.content?.dataType !== "moveObject") {
|
|
11149
|
-
throw new ClmmpoolsError(`Dlmm Position not exists. Get Position error:${object.error}`, "InvalidPositionObject" /* InvalidPositionObject */);
|
|
11150
|
-
}
|
|
11151
|
-
const fields = getObjectFields(object);
|
|
11152
|
-
const ownerWarp = getObjectOwner(object);
|
|
11153
|
-
return {
|
|
11154
|
-
pos_object_id: fields.id.id,
|
|
11155
|
-
owner: ownerWarp.AddressOwner,
|
|
11156
|
-
pool: fields.pair_id,
|
|
11157
|
-
bin_real_ids: fields.bin_ids.map((id) => (0, import_calc_dlmm3.get_real_id)(id)),
|
|
11158
|
-
type: ""
|
|
11159
|
-
};
|
|
11160
|
-
}
|
|
11161
|
-
// return [coin_a, coin_b]
|
|
11162
|
-
async getPoolCoins(pools) {
|
|
11163
|
-
const res = await this._sdk.fullClient.multiGetObjects({ ids: pools, options: { showContent: true } });
|
|
11164
|
-
const poolCoins = /* @__PURE__ */ new Map();
|
|
11165
|
-
res.forEach((item) => {
|
|
11166
|
-
if (item.error != null || item.data?.content?.dataType !== "moveObject") {
|
|
11167
|
-
throw new Error(`Failed to get poolCoins with err: ${item.error}`);
|
|
11168
|
-
}
|
|
11169
|
-
const type = getObjectType(item);
|
|
11170
|
-
const poolTypeFields = extractStructTagFromType(type);
|
|
11171
|
-
poolCoins.set(item.data.objectId, poolTypeFields.type_arguments);
|
|
11172
|
-
});
|
|
11173
|
-
return poolCoins;
|
|
11174
|
-
}
|
|
11175
|
-
buildPositionType() {
|
|
11176
|
-
return `${this._sdk.sdkOptions.dlmm_pool.package_id}::dlmm_position::Position`;
|
|
11177
|
-
}
|
|
11178
|
-
async getPositionLiquidity(params) {
|
|
11179
|
-
const tx = new import_transactions12.Transaction();
|
|
11180
|
-
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11181
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
11182
|
-
const args = [tx.object(params.pair), tx.object(params.positionId)];
|
|
11183
|
-
tx.moveCall({
|
|
11184
|
-
target: `${integrate.published_at}::${DlmmScript}::position_liquidity`,
|
|
11185
|
-
arguments: args,
|
|
11186
|
-
typeArguments
|
|
11187
|
-
});
|
|
11188
|
-
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11189
|
-
transactionBlock: tx,
|
|
11190
|
-
sender: simulationAccount.address
|
|
11191
|
-
});
|
|
11192
|
-
if (simulateRes.error != null) {
|
|
11193
|
-
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11194
|
-
}
|
|
11195
|
-
const out = {
|
|
11196
|
-
shares: 0,
|
|
11197
|
-
liquidity: 0,
|
|
11198
|
-
x_equivalent: 0,
|
|
11199
|
-
y_equivalent: 0,
|
|
11200
|
-
bin_real_ids: [],
|
|
11201
|
-
bin_x_eq: [],
|
|
11202
|
-
bin_y_eq: [],
|
|
11203
|
-
bin_liquidity: []
|
|
11204
|
-
};
|
|
11205
|
-
simulateRes.events?.forEach((item) => {
|
|
11206
|
-
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
11207
|
-
out.shares = item.parsedJson.shares;
|
|
11208
|
-
out.liquidity = item.parsedJson.liquidity;
|
|
11209
|
-
out.x_equivalent = item.parsedJson.x_equivalent;
|
|
11210
|
-
out.y_equivalent = item.parsedJson.y_equivalent;
|
|
11211
|
-
out.bin_real_ids = item.parsedJson.bin_ids.map((id) => (0, import_calc_dlmm3.get_real_id)(id));
|
|
11212
|
-
out.bin_x_eq = item.parsedJson.bin_x_eq;
|
|
11213
|
-
out.bin_y_eq = item.parsedJson.bin_y_eq;
|
|
11214
|
-
out.bin_liquidity = item.parsedJson.bin_liquidity;
|
|
11215
|
-
}
|
|
11216
|
-
});
|
|
11217
|
-
return out;
|
|
11218
|
-
}
|
|
11219
|
-
async getPairLiquidity(params) {
|
|
11220
|
-
const tx = new import_transactions12.Transaction();
|
|
11221
|
-
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11222
|
-
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
11223
|
-
const args = [tx.object(params.pair)];
|
|
11224
|
-
tx.moveCall({
|
|
11225
|
-
target: `${integrate.published_at}::${DlmmScript}::pair_liquidity`,
|
|
11226
|
-
arguments: args,
|
|
11227
|
-
typeArguments
|
|
11228
|
-
});
|
|
11229
|
-
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11230
|
-
transactionBlock: tx,
|
|
11231
|
-
sender: simulationAccount.address
|
|
11232
|
-
});
|
|
11233
|
-
if (simulateRes.error != null) {
|
|
11234
|
-
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11235
|
-
}
|
|
11236
|
-
const out = {
|
|
11237
|
-
shares: 0,
|
|
11238
|
-
liquidity: 0,
|
|
11239
|
-
x: 0,
|
|
11240
|
-
y: 0,
|
|
11241
|
-
bin_ids: [],
|
|
11242
|
-
bin_x: [],
|
|
11243
|
-
bin_y: []
|
|
11244
|
-
};
|
|
11245
|
-
simulateRes.events?.forEach((item) => {
|
|
11246
|
-
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
11247
|
-
out.shares = item.parsedJson.shares;
|
|
11248
|
-
out.liquidity = item.parsedJson.liquidity;
|
|
11249
|
-
out.x = item.parsedJson.x;
|
|
11250
|
-
out.y = item.parsedJson.y;
|
|
11251
|
-
out.bin_ids = item.bin_ids;
|
|
11252
|
-
out.bin_x = item.bin_x;
|
|
11253
|
-
out.bin_y = item.bin_y;
|
|
11254
|
-
}
|
|
11255
|
-
});
|
|
11256
|
-
return out;
|
|
11257
|
-
}
|
|
11258
|
-
async getEarnedFees(params) {
|
|
11259
|
-
const tx = new import_transactions12.Transaction();
|
|
11260
|
-
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11261
|
-
const typeArguments = [params.coin_a, params.coin_b];
|
|
11262
|
-
const args = [tx.object(params.pool_id), tx.object(params.position_id)];
|
|
11263
|
-
tx.moveCall({
|
|
11264
|
-
target: `${integrate.published_at}::${DlmmScript}::earned_fees`,
|
|
11265
|
-
arguments: args,
|
|
11266
|
-
typeArguments
|
|
11267
|
-
});
|
|
11268
|
-
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11269
|
-
transactionBlock: tx,
|
|
11270
|
-
sender: simulationAccount.address
|
|
11271
|
-
});
|
|
11272
|
-
const out = {
|
|
11273
|
-
position_id: "",
|
|
11274
|
-
x: "",
|
|
11275
|
-
y: "",
|
|
11276
|
-
fee_x: 0,
|
|
11277
|
-
fee_y: 0
|
|
11278
|
-
};
|
|
11279
|
-
if (simulateRes.error != null) {
|
|
11280
|
-
throw new Error(`fetchPairRewards error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11281
|
-
}
|
|
11282
|
-
simulateRes.events?.forEach((item) => {
|
|
11283
|
-
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
11284
|
-
out.position_id = item.parsedJson.position_id;
|
|
11285
|
-
out.x = item.parsedJson.x;
|
|
11286
|
-
out.y = item.parsedJson.y;
|
|
11287
|
-
out.fee_x = item.parsedJson.fee_x;
|
|
11288
|
-
out.fee_y = item.parsedJson.fee_y;
|
|
11289
|
-
}
|
|
11290
|
-
});
|
|
11291
|
-
return out;
|
|
11292
|
-
}
|
|
11293
|
-
async getEarnedRewards(params) {
|
|
11294
|
-
const tx = new import_transactions12.Transaction();
|
|
11295
|
-
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11296
|
-
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
11297
|
-
const args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
11298
|
-
let target = `${integrate.published_at}::${DlmmScript}::earned_rewards`;
|
|
11299
|
-
if (params.rewards_token.length > 1) {
|
|
11300
|
-
target = `${integrate.published_at}::${DlmmScript}::earned_rewards${params.rewards_token.length}`;
|
|
11301
|
-
}
|
|
11302
|
-
tx.moveCall({
|
|
11303
|
-
target,
|
|
11304
|
-
arguments: args,
|
|
11305
|
-
typeArguments
|
|
11306
|
-
});
|
|
11307
|
-
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11308
|
-
transactionBlock: tx,
|
|
11309
|
-
sender: simulationAccount.address
|
|
11310
|
-
});
|
|
11311
|
-
const out = {
|
|
11312
|
-
position_id: "",
|
|
11313
|
-
reward: [],
|
|
11314
|
-
amount: []
|
|
11315
|
-
};
|
|
11316
|
-
if (simulateRes.error != null) {
|
|
11317
|
-
throw new Error(`getEarnedRewards error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11318
|
-
}
|
|
11319
|
-
simulateRes.events?.forEach((item) => {
|
|
11320
|
-
if (extractStructTagFromType(item.type).name === `DlmmEventEarnedRewards`) {
|
|
11321
|
-
out.position_id = item.parsedJson.position_id;
|
|
11322
|
-
out.reward = [item.parsedJson.reward];
|
|
11323
|
-
out.amount = [item.parsedJson.amount];
|
|
11324
|
-
} else if (extractStructTagFromType(item.type).name === `DlmmEventEarnedRewards2`) {
|
|
11325
|
-
out.position_id = item.parsedJson.position_id;
|
|
11326
|
-
out.reward = [item.parsedJson.reward1, item.parsedJson.reward2];
|
|
11327
|
-
out.amount = [item.parsedJson.amount1, item.parsedJson.amount2];
|
|
11328
|
-
} else if (extractStructTagFromType(item.type).name === `EventEarnedRewards3`) {
|
|
11329
|
-
out.position_id = item.parsedJson.position_id;
|
|
11330
|
-
out.reward = [item.parsedJson.reward1, item.parsedJson.reward2, item.parsedJson.reward3];
|
|
11331
|
-
out.amount = [item.parsedJson.amount1, item.parsedJson.amount2, item.parsedJson.amount3];
|
|
11332
|
-
}
|
|
11333
|
-
});
|
|
11334
|
-
return out;
|
|
11335
|
-
}
|
|
11336
|
-
// return pool_id => reward_tokens
|
|
11337
|
-
async getPairRewarders(params) {
|
|
11338
|
-
let tx = new import_transactions12.Transaction();
|
|
11339
|
-
for (const param of params) {
|
|
11340
|
-
tx = await this._getPairRewarders(param, tx);
|
|
11341
|
-
}
|
|
11342
|
-
return this._parsePairRewarders(tx);
|
|
11343
|
-
}
|
|
11344
|
-
async _getPairRewarders(params, tx) {
|
|
11345
|
-
tx = tx || new import_transactions12.Transaction();
|
|
11346
|
-
const { integrate } = this.sdk.sdkOptions;
|
|
11347
|
-
const typeArguments = [params.coin_a, params.coin_b];
|
|
11348
|
-
const args = [tx.object(params.pool_id)];
|
|
11349
|
-
tx.moveCall({
|
|
11350
|
-
target: `${integrate.published_at}::${DlmmScript}::get_pair_rewarders`,
|
|
11351
|
-
arguments: args,
|
|
11352
|
-
typeArguments
|
|
11353
|
-
});
|
|
11354
|
-
return tx;
|
|
11355
|
-
}
|
|
11356
|
-
async _parsePairRewarders(tx) {
|
|
11357
|
-
const { simulationAccount } = this.sdk.sdkOptions;
|
|
11358
|
-
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11359
|
-
transactionBlock: tx,
|
|
11360
|
-
sender: simulationAccount.address
|
|
11361
|
-
});
|
|
11362
|
-
const out = /* @__PURE__ */ new Map();
|
|
11363
|
-
if (simulateRes.error != null) {
|
|
11364
|
-
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11365
|
-
}
|
|
11366
|
-
simulateRes.events?.forEach((item) => {
|
|
11367
|
-
if (extractStructTagFromType(item.type).name === `EventPairRewardTypes`) {
|
|
11368
|
-
const pairRewards = {
|
|
11369
|
-
pair_id: "",
|
|
11370
|
-
tokens: []
|
|
11371
|
-
};
|
|
11372
|
-
pairRewards.pair_id = item.parsedJson.pair_id;
|
|
11373
|
-
item.parsedJson.tokens.forEach((token) => {
|
|
11374
|
-
pairRewards.tokens.push(token.name);
|
|
11375
|
-
});
|
|
11376
|
-
out.set(pairRewards.pair_id, pairRewards.tokens);
|
|
11377
|
-
}
|
|
11378
|
-
});
|
|
11379
|
-
return out;
|
|
11380
|
-
}
|
|
11381
|
-
/**
|
|
11382
|
-
* Updates the cache for the given key.
|
|
11383
|
-
*
|
|
11384
|
-
* @param key The key of the cache entry to update.
|
|
11385
|
-
* @param data The data to store in the cache.
|
|
11386
|
-
* @param time The time in minutes after which the cache entry should expire.
|
|
11387
|
-
*/
|
|
11388
|
-
updateCache(key, data, time = cacheTime5min) {
|
|
11389
|
-
let cacheData = this._cache[key];
|
|
11390
|
-
if (cacheData) {
|
|
11391
|
-
cacheData.overdueTime = getFutureTime(time);
|
|
11392
|
-
cacheData.value = data;
|
|
11393
|
-
} else {
|
|
11394
|
-
cacheData = new CachedContent(data, getFutureTime(time));
|
|
11395
|
-
}
|
|
11396
|
-
this._cache[key] = cacheData;
|
|
11397
|
-
}
|
|
11398
|
-
/**
|
|
11399
|
-
* Gets the cache entry for the given key.
|
|
11400
|
-
*
|
|
11401
|
-
* @param key The key of the cache entry to get.
|
|
11402
|
-
* @param forceRefresh Whether to force a refresh of the cache entry.
|
|
11403
|
-
* @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
|
|
11404
|
-
*/
|
|
11405
|
-
getCache(key, forceRefresh = false) {
|
|
11406
|
-
const cacheData = this._cache[key];
|
|
11407
|
-
const isValid = cacheData?.isValid();
|
|
11408
|
-
if (!forceRefresh && isValid) {
|
|
11409
|
-
return cacheData.value;
|
|
11410
|
-
}
|
|
11411
|
-
if (!isValid) {
|
|
11412
|
-
delete this._cache[key];
|
|
11413
|
-
}
|
|
11414
|
-
return void 0;
|
|
11415
|
-
}
|
|
11416
|
-
};
|
|
11417
|
-
|
|
11418
|
-
// src/sdk.ts
|
|
11419
|
-
var MagmaClmmSDK = class {
|
|
10007
|
+
// src/sdk.ts
|
|
10008
|
+
var MagmaClmmSDK = class {
|
|
11420
10009
|
_cache = {};
|
|
11421
10010
|
/**
|
|
11422
10011
|
* RPC provider on the SUI chain
|
|
@@ -11439,7 +10028,6 @@ var MagmaClmmSDK = class {
|
|
|
11439
10028
|
*/
|
|
11440
10029
|
_lock;
|
|
11441
10030
|
_gauge;
|
|
11442
|
-
_dlmm;
|
|
11443
10031
|
/**
|
|
11444
10032
|
* Provide interact with a position rewarder interface.
|
|
11445
10033
|
*/
|
|
@@ -11477,7 +10065,6 @@ var MagmaClmmSDK = class {
|
|
|
11477
10065
|
this._swap = new SwapModule(this);
|
|
11478
10066
|
this._lock = new LockModule(this);
|
|
11479
10067
|
this._gauge = new GaugeModule(this);
|
|
11480
|
-
this._dlmm = new DlmmModule(this);
|
|
11481
10068
|
this._pool = new PoolModule(this);
|
|
11482
10069
|
this._position = new PositionModule(this);
|
|
11483
10070
|
this._rewarder = new RewarderModule(this);
|
|
@@ -11515,9 +10102,6 @@ var MagmaClmmSDK = class {
|
|
|
11515
10102
|
get Gauge() {
|
|
11516
10103
|
return this._gauge;
|
|
11517
10104
|
}
|
|
11518
|
-
get Dlmm() {
|
|
11519
|
-
return this._dlmm;
|
|
11520
|
-
}
|
|
11521
10105
|
/**
|
|
11522
10106
|
* Getter for the fullClient property.
|
|
11523
10107
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -11691,7 +10275,6 @@ var main_default = MagmaClmmSDK;
|
|
|
11691
10275
|
var SDKConfig = {
|
|
11692
10276
|
clmmConfig: {
|
|
11693
10277
|
pools_id: "0xfa145b9de10fe858be81edd1c6cdffcf27be9d016de02a1345eb1009a68ba8b2",
|
|
11694
|
-
// clmm and dlmm both use this global_config
|
|
11695
10278
|
global_config_id: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
11696
10279
|
global_vault_id: "0xa7e1102f222b6eb81ccc8a126e7feb2353342be9df6f6646a77c4519da29c071",
|
|
11697
10280
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
@@ -11711,11 +10294,7 @@ var SDKConfig = {
|
|
|
11711
10294
|
distribution_cfg: "0xaff8d151ac29317201151f97d28c546b3c5923d8cfc5499f40dea61c4022c949",
|
|
11712
10295
|
magma_token: "0x7161c6c6bb65f852797c8f7f5c4f8d57adaf796e1b840921f9e23fabeadfd54e::magma::MAGMA",
|
|
11713
10296
|
minter_id: "0x4fa5766cd83b33b215b139fec27ac344040f3bbd84fcbee7b61fc671aadc51fa"
|
|
11714
|
-
}
|
|
11715
|
-
dlmmConfig: {
|
|
11716
|
-
factory: ""
|
|
11717
|
-
},
|
|
11718
|
-
gaugeConfig: {}
|
|
10297
|
+
}
|
|
11719
10298
|
};
|
|
11720
10299
|
var clmmMainnet = {
|
|
11721
10300
|
fullRpcUrl: (0, import_client2.getFullnodeUrl)("mainnet"),
|
|
@@ -11732,11 +10311,6 @@ var clmmMainnet = {
|
|
|
11732
10311
|
published_at: "0x4a35d3dfef55ed3631b7158544c6322a23bc434fe4fca1234cb680ce0505f82d",
|
|
11733
10312
|
config: SDKConfig.clmmConfig
|
|
11734
10313
|
},
|
|
11735
|
-
dlmm_pool: {
|
|
11736
|
-
package_id: "",
|
|
11737
|
-
published_at: "",
|
|
11738
|
-
config: SDKConfig.dlmmConfig
|
|
11739
|
-
},
|
|
11740
10314
|
distribution: {
|
|
11741
10315
|
package_id: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b",
|
|
11742
10316
|
published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
|
|
@@ -11790,9 +10364,6 @@ var SDKConfig2 = {
|
|
|
11790
10364
|
distribution_cfg: "0x94e23846c975e2faf89a61bfc2b10ad64decab9069eb1f9fc39752b010868c74",
|
|
11791
10365
|
magma_token: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1::magma_token::MAGMA_TOKEN",
|
|
11792
10366
|
minter_id: "0x89435d6b2a510ba50ca23303f10e91ec058f138a88f69a43fe03cd22edb214c5"
|
|
11793
|
-
},
|
|
11794
|
-
dlmmConfig: {
|
|
11795
|
-
factory: ""
|
|
11796
10367
|
}
|
|
11797
10368
|
};
|
|
11798
10369
|
var clmmTestnet = {
|
|
@@ -11807,11 +10378,6 @@ var clmmTestnet = {
|
|
|
11807
10378
|
published_at: "0x23e0b5ab4aa63d0e6fd98fa5e247bcf9b36ad716b479d39e56b2ba9ff631e09d",
|
|
11808
10379
|
config: SDKConfig2.clmmConfig
|
|
11809
10380
|
},
|
|
11810
|
-
dlmm_pool: {
|
|
11811
|
-
package_id: "",
|
|
11812
|
-
published_at: "",
|
|
11813
|
-
config: SDKConfig2.dlmmConfig
|
|
11814
|
-
},
|
|
11815
10381
|
distribution: {
|
|
11816
10382
|
package_id: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1",
|
|
11817
10383
|
published_at: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1"
|
|
@@ -11860,7 +10426,6 @@ var src_default = MagmaClmmSDK;
|
|
|
11860
10426
|
0 && (module.exports = {
|
|
11861
10427
|
AMM_SWAP_MODULE,
|
|
11862
10428
|
AmountSpecified,
|
|
11863
|
-
BinMath,
|
|
11864
10429
|
CLOCK_ADDRESS,
|
|
11865
10430
|
CachedContent,
|
|
11866
10431
|
ClmmExpectSwapModule,
|
|
@@ -11888,7 +10453,6 @@ var src_default = MagmaClmmSDK;
|
|
|
11888
10453
|
DeepbookCustodianV2Moudle,
|
|
11889
10454
|
DeepbookEndpointsV2Moudle,
|
|
11890
10455
|
DeepbookUtils,
|
|
11891
|
-
DlmmScript,
|
|
11892
10456
|
FEE_RATE_DENOMINATOR,
|
|
11893
10457
|
GAS_SYMBOL,
|
|
11894
10458
|
GAS_TYPE_ARG,
|
|
@@ -11916,7 +10480,6 @@ var src_default = MagmaClmmSDK;
|
|
|
11916
10480
|
SUI_SYSTEM_STATE_OBJECT_ID,
|
|
11917
10481
|
SplitSwap,
|
|
11918
10482
|
SplitUnit,
|
|
11919
|
-
StrategyType,
|
|
11920
10483
|
SwapDirection,
|
|
11921
10484
|
SwapModule,
|
|
11922
10485
|
SwapUtils,
|
|
@@ -11938,10 +10501,6 @@ var src_default = MagmaClmmSDK;
|
|
|
11938
10501
|
adjustForSlippage,
|
|
11939
10502
|
asIntN,
|
|
11940
10503
|
asUintN,
|
|
11941
|
-
autoFillXByStrategy,
|
|
11942
|
-
autoFillXByWeight,
|
|
11943
|
-
autoFillYByStrategy,
|
|
11944
|
-
autoFillYByWeight,
|
|
11945
10504
|
bufferToHex,
|
|
11946
10505
|
buildClmmPositionName,
|
|
11947
10506
|
buildNFT,
|
|
@@ -11979,14 +10538,12 @@ var src_default = MagmaClmmSDK;
|
|
|
11979
10538
|
getAmountUnfixedDelta,
|
|
11980
10539
|
getCoinAFromLiquidity,
|
|
11981
10540
|
getCoinBFromLiquidity,
|
|
11982
|
-
getCoinXYForLiquidity,
|
|
11983
10541
|
getDefaultSuiInputType,
|
|
11984
10542
|
getDeltaA,
|
|
11985
10543
|
getDeltaB,
|
|
11986
10544
|
getDeltaDownFromOutput,
|
|
11987
10545
|
getDeltaUpFromInput,
|
|
11988
10546
|
getFutureTime,
|
|
11989
|
-
getLiquidityAndCoinYByCoinX,
|
|
11990
10547
|
getLiquidityFromCoinA,
|
|
11991
10548
|
getLiquidityFromCoinB,
|
|
11992
10549
|
getLowerSqrtPriceFromCoinA,
|
|
@@ -12010,7 +10567,6 @@ var src_default = MagmaClmmSDK;
|
|
|
12010
10567
|
getObjectType,
|
|
12011
10568
|
getObjectVersion,
|
|
12012
10569
|
getPackagerConfigs,
|
|
12013
|
-
getPriceOfBinByBinId,
|
|
12014
10570
|
getRewardInTickRange,
|
|
12015
10571
|
getSuiObjectData,
|
|
12016
10572
|
getTickDataFromUrlData,
|
|
@@ -12034,15 +10590,10 @@ var src_default = MagmaClmmSDK;
|
|
|
12034
10590
|
shortAddress,
|
|
12035
10591
|
shortString,
|
|
12036
10592
|
tickScore,
|
|
12037
|
-
toAmountAskSide,
|
|
12038
|
-
toAmountBidSide,
|
|
12039
|
-
toAmountBothSide,
|
|
12040
|
-
toAmountsBothSideByStrategy,
|
|
12041
10593
|
toBuffer,
|
|
12042
10594
|
toCoinAmount,
|
|
12043
10595
|
toDecimalsAmount,
|
|
12044
10596
|
transClmmpoolDataWithoutTicks,
|
|
12045
|
-
utf8to16
|
|
12046
|
-
withLiquiditySlippage
|
|
10597
|
+
utf8to16
|
|
12047
10598
|
});
|
|
12048
10599
|
//# sourceMappingURL=index.js.map
|