@magmaprotocol/magma-clmm-sdk 0.5.27 → 0.5.29
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 +1 -0
- package/dist/index.js +93 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2968,8 +2968,8 @@ var _TransactionUtil = class {
|
|
|
2968
2968
|
const tx = new Transaction();
|
|
2969
2969
|
tx.setGasBudget(1e8);
|
|
2970
2970
|
tx.setSender(sdk.senderAddress);
|
|
2971
|
-
const oneDay = 24 * 60 * 60
|
|
2972
|
-
const newLockDuration = Math.ceil((params.newLockEndAt - Date.now()) / oneDay);
|
|
2971
|
+
const oneDay = 24 * 60 * 60;
|
|
2972
|
+
const newLockDuration = Math.ceil((params.newLockEndAt - Date.now() / 1e3) / oneDay);
|
|
2973
2973
|
const { integrate } = sdk.sdkOptions;
|
|
2974
2974
|
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2975
2975
|
const typeArguments = [magma_token];
|
|
@@ -7295,6 +7295,41 @@ var LockModule = class {
|
|
|
7295
7295
|
});
|
|
7296
7296
|
return tx;
|
|
7297
7297
|
}
|
|
7298
|
+
async fastLocksOfUser(user) {
|
|
7299
|
+
const locksInfo = { owner: user, lockInfo: [] };
|
|
7300
|
+
const { distribution } = this._sdk.sdkOptions;
|
|
7301
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7302
|
+
const ownerRes = await this._sdk.fullClient.getOwnedObjectsByPage(user, {
|
|
7303
|
+
options: { showType: true, showContent: true, showDisplay: true, showOwner: true },
|
|
7304
|
+
filter: {
|
|
7305
|
+
MatchAll: [{ Package: distribution.package_id }, { StructType: `${distribution.package_id}::voting_escrow::Lock` }]
|
|
7306
|
+
}
|
|
7307
|
+
});
|
|
7308
|
+
for (const item of ownerRes.data) {
|
|
7309
|
+
try {
|
|
7310
|
+
const { fields } = item.data.content;
|
|
7311
|
+
const aLockSummary = await this.aLockSummary(fields.id.id);
|
|
7312
|
+
const lockInfo = {
|
|
7313
|
+
lock_id: fields.id.id,
|
|
7314
|
+
amount: fields.amount,
|
|
7315
|
+
start: fields.start,
|
|
7316
|
+
end: fields.end,
|
|
7317
|
+
permanent: fields.permanent,
|
|
7318
|
+
rebase_amount: {
|
|
7319
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7320
|
+
token_addr: magma_token,
|
|
7321
|
+
amount: aLockSummary.reward_distributor_claimable
|
|
7322
|
+
},
|
|
7323
|
+
voting_power: aLockSummary.voting_power,
|
|
7324
|
+
voting_rewards: /* @__PURE__ */ new Map()
|
|
7325
|
+
};
|
|
7326
|
+
locksInfo.lockInfo.push(lockInfo);
|
|
7327
|
+
} catch (error) {
|
|
7328
|
+
throw Error("fastLocksOfUser error");
|
|
7329
|
+
}
|
|
7330
|
+
}
|
|
7331
|
+
return locksInfo;
|
|
7332
|
+
}
|
|
7298
7333
|
async locksOfUser(user) {
|
|
7299
7334
|
const locksInfo = { owner: user, lockInfo: [] };
|
|
7300
7335
|
const { distribution } = this._sdk.sdkOptions;
|
|
@@ -7306,61 +7341,65 @@ var LockModule = class {
|
|
|
7306
7341
|
}
|
|
7307
7342
|
});
|
|
7308
7343
|
for (const item of ownerRes.data) {
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
votingRewards.
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7344
|
+
try {
|
|
7345
|
+
const { fields } = item.data.content;
|
|
7346
|
+
const aLockSummary = await this.aLockSummary(fields.id.id);
|
|
7347
|
+
const poolIncentiveTokens = await this.getVotingBribeRewardTokens(fields.id.id);
|
|
7348
|
+
const poolFeeTokens = await this.getVotingFeeRewardTokens(fields.id.id);
|
|
7349
|
+
const incentiveTokens = [];
|
|
7350
|
+
poolIncentiveTokens.forEach((value, key) => {
|
|
7351
|
+
incentiveTokens.push(...value);
|
|
7352
|
+
});
|
|
7353
|
+
const feeTokens = [];
|
|
7354
|
+
poolFeeTokens.forEach((value, key) => {
|
|
7355
|
+
feeTokens.push(...value);
|
|
7356
|
+
});
|
|
7357
|
+
const poolIncentiveRewards = await this.getPoolIncentiveRewards(fields.id.id, incentiveTokens);
|
|
7358
|
+
const votingRewards = /* @__PURE__ */ new Map();
|
|
7359
|
+
poolIncentiveRewards.forEach((value, coin) => {
|
|
7360
|
+
value.forEach((amount, pool) => {
|
|
7361
|
+
if (!votingRewards.has(pool)) {
|
|
7362
|
+
votingRewards.set(pool, []);
|
|
7363
|
+
}
|
|
7364
|
+
votingRewards.get(pool)?.push({
|
|
7365
|
+
kind: "incentiveCoin" /* Incentive */,
|
|
7366
|
+
token_addr: coin,
|
|
7367
|
+
amount: amount.toString()
|
|
7368
|
+
});
|
|
7332
7369
|
});
|
|
7333
7370
|
});
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7371
|
+
const poolFeeRewards = await this.getPoolFeeRewards(fields.id.id, feeTokens);
|
|
7372
|
+
poolFeeRewards.forEach((value, coin) => {
|
|
7373
|
+
value.forEach((amount, pool) => {
|
|
7374
|
+
if (!votingRewards.has(pool)) {
|
|
7375
|
+
votingRewards.set(pool, []);
|
|
7376
|
+
}
|
|
7377
|
+
votingRewards.get(pool)?.push({
|
|
7378
|
+
kind: "fee" /* Fee */,
|
|
7379
|
+
token_addr: coin,
|
|
7380
|
+
amount: amount.toString()
|
|
7381
|
+
});
|
|
7345
7382
|
});
|
|
7346
7383
|
});
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7384
|
+
const lockInfo = {
|
|
7385
|
+
lock_id: fields.id.id,
|
|
7386
|
+
amount: fields.amount,
|
|
7387
|
+
start: fields.start,
|
|
7388
|
+
end: fields.end,
|
|
7389
|
+
permanent: fields.permanent,
|
|
7390
|
+
rebase_amount: {
|
|
7391
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7392
|
+
token_addr: magma_token,
|
|
7393
|
+
amount: aLockSummary.reward_distributor_claimable
|
|
7394
|
+
},
|
|
7395
|
+
voting_power: aLockSummary.voting_power,
|
|
7396
|
+
// pool => incentive/fee => amount
|
|
7397
|
+
voting_rewards: votingRewards
|
|
7398
|
+
};
|
|
7399
|
+
locksInfo.lockInfo.push(lockInfo);
|
|
7400
|
+
} catch (error) {
|
|
7401
|
+
throw Error("locksOfUser error");
|
|
7402
|
+
}
|
|
7364
7403
|
}
|
|
7365
7404
|
return locksInfo;
|
|
7366
7405
|
}
|
|
@@ -9164,7 +9203,7 @@ var RpcModule = class extends SuiClient {
|
|
|
9164
9203
|
}
|
|
9165
9204
|
};
|
|
9166
9205
|
|
|
9167
|
-
// src/modules/
|
|
9206
|
+
// src/modules/gaugeModule.ts
|
|
9168
9207
|
import { Transaction as Transaction11 } from "@mysten/sui/transactions";
|
|
9169
9208
|
var GaugeModule = class {
|
|
9170
9209
|
_sdk;
|