@magmaprotocol/magma-clmm-sdk 0.5.115 → 0.5.116
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/dist/index.d.ts +33 -13
- package/dist/index.js +71 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1598,7 +1598,7 @@ import BN10 from "bn.js";
|
|
|
1598
1598
|
// src/math/almmWeightToAmounts.ts
|
|
1599
1599
|
import BN9 from "bn.js";
|
|
1600
1600
|
import Decimal3 from "decimal.js";
|
|
1601
|
-
import { get_price_x128_from_real_id } from "@magmaprotocol/
|
|
1601
|
+
import { get_price_x128_from_real_id } from "@magmaprotocol/calc_almm";
|
|
1602
1602
|
function getPriceOfBinByBinId(binId, binStep) {
|
|
1603
1603
|
const twoDec = new Decimal3(2);
|
|
1604
1604
|
const price = new Decimal3(get_price_x128_from_real_id(binId, binStep));
|
|
@@ -2537,7 +2537,7 @@ var SplitSwap = class {
|
|
|
2537
2537
|
|
|
2538
2538
|
// src/math/bin.ts
|
|
2539
2539
|
import Decimal6 from "decimal.js";
|
|
2540
|
-
import { get_price_x128_from_real_id as get_price_x128_from_real_id2, get_real_id_from_price_x128 } from "@magmaprotocol/
|
|
2540
|
+
import { get_price_x128_from_real_id as get_price_x128_from_real_id2, get_real_id_from_price_x128 } from "@magmaprotocol/calc_almm";
|
|
2541
2541
|
var BinMath = class {
|
|
2542
2542
|
static getPriceOfBinByBinId(binId, binStep, decimalsA, decimalsB) {
|
|
2543
2543
|
const twoDec = new Decimal6(2);
|
|
@@ -2547,7 +2547,10 @@ var BinMath = class {
|
|
|
2547
2547
|
static getBinIdFromPrice(price, binStep, decimalsA, decimalsB) {
|
|
2548
2548
|
const twoDec = new Decimal6(2);
|
|
2549
2549
|
const tenDec = new Decimal6(10);
|
|
2550
|
-
const realid = get_real_id_from_price_x128(
|
|
2550
|
+
const realid = get_real_id_from_price_x128(
|
|
2551
|
+
new Decimal6(price).mul(tenDec.pow(decimalsB - decimalsA)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(),
|
|
2552
|
+
binStep
|
|
2553
|
+
);
|
|
2551
2554
|
return realid;
|
|
2552
2555
|
}
|
|
2553
2556
|
};
|
|
@@ -5178,6 +5181,7 @@ var PoolModule = class {
|
|
|
5178
5181
|
}
|
|
5179
5182
|
return dataPage;
|
|
5180
5183
|
}
|
|
5184
|
+
// TODO: 实现这个方法为almm
|
|
5181
5185
|
/**
|
|
5182
5186
|
* Gets a list of pools.
|
|
5183
5187
|
* @param {string[]} assignPools An array of pool IDs to get.
|
|
@@ -10422,7 +10426,7 @@ import {
|
|
|
10422
10426
|
get_real_id,
|
|
10423
10427
|
get_real_id_from_price_x128 as get_real_id_from_price_x1282,
|
|
10424
10428
|
get_storage_id_from_real_id
|
|
10425
|
-
} from "@magmaprotocol/
|
|
10429
|
+
} from "@magmaprotocol/calc_almm";
|
|
10426
10430
|
import Decimal10 from "decimal.js";
|
|
10427
10431
|
import BN22 from "bn.js";
|
|
10428
10432
|
var AlmmModule = class {
|
|
@@ -10434,6 +10438,37 @@ var AlmmModule = class {
|
|
|
10434
10438
|
get sdk() {
|
|
10435
10439
|
return this._sdk;
|
|
10436
10440
|
}
|
|
10441
|
+
async getPools(paginationArgs = "all", forceRefresh = false) {
|
|
10442
|
+
const { package_id } = this._sdk.sdkOptions.almm_pool;
|
|
10443
|
+
const allPools = [];
|
|
10444
|
+
const cacheKey = `${package_id}_getInitCreatePairEvent`;
|
|
10445
|
+
const cacheData = this.getCache(cacheKey, forceRefresh);
|
|
10446
|
+
if (cacheData !== void 0) {
|
|
10447
|
+
allPools.push(...cacheData);
|
|
10448
|
+
}
|
|
10449
|
+
if (allPools.length === 0) {
|
|
10450
|
+
try {
|
|
10451
|
+
const moveEventType = `${package_id}::almm_pair::EventCreatePair`;
|
|
10452
|
+
const objects = await this._sdk.fullClient.queryEventsByPage({ MoveEventType: moveEventType }, paginationArgs);
|
|
10453
|
+
const dataPage = {
|
|
10454
|
+
data: [],
|
|
10455
|
+
hasNextPage: false
|
|
10456
|
+
};
|
|
10457
|
+
dataPage.hasNextPage = objects.hasNextPage;
|
|
10458
|
+
dataPage.nextCursor = objects.nextCursor;
|
|
10459
|
+
objects.data.forEach((object) => {
|
|
10460
|
+
const fields = object.parsedJson;
|
|
10461
|
+
if (fields) {
|
|
10462
|
+
allPools.push(fields);
|
|
10463
|
+
}
|
|
10464
|
+
});
|
|
10465
|
+
this.updateCache(cacheKey, allPools, cacheTime24h);
|
|
10466
|
+
} catch (error) {
|
|
10467
|
+
console.log("getCreatePairEvents", error);
|
|
10468
|
+
}
|
|
10469
|
+
}
|
|
10470
|
+
return allPools;
|
|
10471
|
+
}
|
|
10437
10472
|
async getPoolInfo(pools) {
|
|
10438
10473
|
const cachePoolList = [];
|
|
10439
10474
|
pools = pools.filter((poolID) => {
|
|
@@ -10475,7 +10510,8 @@ var AlmmModule = class {
|
|
|
10475
10510
|
coinAmountA: fields.reserve_x,
|
|
10476
10511
|
coinAmountB: fields.reserve_y,
|
|
10477
10512
|
liquidity: fields.liquidity,
|
|
10478
|
-
rewarder_infos: rewarders
|
|
10513
|
+
rewarder_infos: rewarders,
|
|
10514
|
+
params: fields.params.fields
|
|
10479
10515
|
};
|
|
10480
10516
|
poolList.push(poolInfo);
|
|
10481
10517
|
this.updateCache(`${fields.id.id}_getPoolObject`, poolInfo, cacheTime24h);
|
|
@@ -10513,7 +10549,8 @@ var AlmmModule = class {
|
|
|
10513
10549
|
index_reference: 0,
|
|
10514
10550
|
time_of_last_update: 0,
|
|
10515
10551
|
oracle_index: 0,
|
|
10516
|
-
active_index: 0
|
|
10552
|
+
active_index: 0,
|
|
10553
|
+
protocol_variable_share: 0
|
|
10517
10554
|
};
|
|
10518
10555
|
simulateRes.events?.forEach((item) => {
|
|
10519
10556
|
console.log(extractStructTagFromType(item.type).name);
|
|
@@ -11090,7 +11127,7 @@ var AlmmModule = class {
|
|
|
11090
11127
|
* @returns array of Position objects.
|
|
11091
11128
|
*/
|
|
11092
11129
|
async getUserPositionById(positionId, showDisplay = true) {
|
|
11093
|
-
|
|
11130
|
+
const allPosition = [];
|
|
11094
11131
|
const ownerRes = await this._sdk.fullClient.getObject({
|
|
11095
11132
|
id: positionId,
|
|
11096
11133
|
options: { showContent: true, showType: true, showDisplay, showOwner: true }
|
|
@@ -11111,6 +11148,7 @@ var AlmmModule = class {
|
|
|
11111
11148
|
* Gets a list of positions for the given account address.
|
|
11112
11149
|
* @param accountAddress The account address to get positions for.
|
|
11113
11150
|
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
11151
|
+
* @param showDisplay When some testnet rpc nodes can't return object's display data, you can set this option to false, avoid returning errors. Default set true.
|
|
11114
11152
|
* @returns array of Position objects.
|
|
11115
11153
|
*/
|
|
11116
11154
|
async getUserPositions(accountAddress, assignPoolIds = [], showDisplay = true) {
|
|
@@ -11863,7 +11901,7 @@ var main_default = MagmaClmmSDK;
|
|
|
11863
11901
|
var SDKConfig = {
|
|
11864
11902
|
clmmConfig: {
|
|
11865
11903
|
pools_id: "0xfa145b9de10fe858be81edd1c6cdffcf27be9d016de02a1345eb1009a68ba8b2",
|
|
11866
|
-
// clmm and
|
|
11904
|
+
// clmm and almm both use this global_config
|
|
11867
11905
|
global_config_id: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
11868
11906
|
global_vault_id: "0xa7e1102f222b6eb81ccc8a126e7feb2353342be9df6f6646a77c4519da29c071",
|
|
11869
11907
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
@@ -11912,8 +11950,8 @@ var clmmMainnet = {
|
|
|
11912
11950
|
config: SDKConfig.clmmConfig
|
|
11913
11951
|
},
|
|
11914
11952
|
almm_pool: {
|
|
11915
|
-
package_id: "",
|
|
11916
|
-
published_at: "",
|
|
11953
|
+
package_id: "0x17ec44d20706af7f4ca563be7424bfa07c190f7f47bec157fa1eedaeec0bae3d",
|
|
11954
|
+
published_at: "0x17ec44d20706af7f4ca563be7424bfa07c190f7f47bec157fa1eedaeec0bae3d",
|
|
11917
11955
|
config: SDKConfig.almmConfig
|
|
11918
11956
|
},
|
|
11919
11957
|
distribution: {
|
|
@@ -11921,8 +11959,8 @@ var clmmMainnet = {
|
|
|
11921
11959
|
published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
|
|
11922
11960
|
},
|
|
11923
11961
|
integrate: {
|
|
11924
|
-
package_id: "
|
|
11925
|
-
published_at: "
|
|
11962
|
+
package_id: "0x7701ae515703598d6f2451f4bfec857d3cba994fd3e1968b11110d674e3126c4",
|
|
11963
|
+
published_at: "0x7701ae515703598d6f2451f4bfec857d3cba994fd3e1968b11110d674e3126c4"
|
|
11926
11964
|
},
|
|
11927
11965
|
deepbook: {
|
|
11928
11966
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|