@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.d.ts
CHANGED
|
@@ -3098,6 +3098,7 @@ declare class LockModule implements IModule {
|
|
|
3098
3098
|
addBribeReward(params: AddBribeReward): Promise<Transaction>;
|
|
3099
3099
|
claimVotingBribe(locks: string[], incentive_tokens: string[]): Promise<Transaction>;
|
|
3100
3100
|
claimVotingFeeAndBribeForPool(lockId: string, poolId: string, feeTokens: string[], incentiveTokens: string[]): Promise<Transaction>;
|
|
3101
|
+
fastLocksOfUser(user: string): Promise<LocksInfo>;
|
|
3101
3102
|
locksOfUser(user: string): Promise<LocksInfo>;
|
|
3102
3103
|
aLockInfo(lockId: string): Promise<LockInfo>;
|
|
3103
3104
|
aLockSummary(lock_id: string): Promise<ALockSummary>;
|
package/dist/index.js
CHANGED
|
@@ -3173,8 +3173,8 @@ var _TransactionUtil = class {
|
|
|
3173
3173
|
const tx = new import_transactions.Transaction();
|
|
3174
3174
|
tx.setGasBudget(1e8);
|
|
3175
3175
|
tx.setSender(sdk.senderAddress);
|
|
3176
|
-
const oneDay = 24 * 60 * 60
|
|
3177
|
-
const newLockDuration = Math.ceil((params.newLockEndAt - Date.now()) / oneDay);
|
|
3176
|
+
const oneDay = 24 * 60 * 60;
|
|
3177
|
+
const newLockDuration = Math.ceil((params.newLockEndAt - Date.now() / 1e3) / oneDay);
|
|
3178
3178
|
const { integrate } = sdk.sdkOptions;
|
|
3179
3179
|
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3180
3180
|
const typeArguments = [magma_token];
|
|
@@ -7500,6 +7500,41 @@ var LockModule = class {
|
|
|
7500
7500
|
});
|
|
7501
7501
|
return tx;
|
|
7502
7502
|
}
|
|
7503
|
+
async fastLocksOfUser(user) {
|
|
7504
|
+
const locksInfo = { owner: user, lockInfo: [] };
|
|
7505
|
+
const { distribution } = this._sdk.sdkOptions;
|
|
7506
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7507
|
+
const ownerRes = await this._sdk.fullClient.getOwnedObjectsByPage(user, {
|
|
7508
|
+
options: { showType: true, showContent: true, showDisplay: true, showOwner: true },
|
|
7509
|
+
filter: {
|
|
7510
|
+
MatchAll: [{ Package: distribution.package_id }, { StructType: `${distribution.package_id}::voting_escrow::Lock` }]
|
|
7511
|
+
}
|
|
7512
|
+
});
|
|
7513
|
+
for (const item of ownerRes.data) {
|
|
7514
|
+
try {
|
|
7515
|
+
const { fields } = item.data.content;
|
|
7516
|
+
const aLockSummary = await this.aLockSummary(fields.id.id);
|
|
7517
|
+
const lockInfo = {
|
|
7518
|
+
lock_id: fields.id.id,
|
|
7519
|
+
amount: fields.amount,
|
|
7520
|
+
start: fields.start,
|
|
7521
|
+
end: fields.end,
|
|
7522
|
+
permanent: fields.permanent,
|
|
7523
|
+
rebase_amount: {
|
|
7524
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7525
|
+
token_addr: magma_token,
|
|
7526
|
+
amount: aLockSummary.reward_distributor_claimable
|
|
7527
|
+
},
|
|
7528
|
+
voting_power: aLockSummary.voting_power,
|
|
7529
|
+
voting_rewards: /* @__PURE__ */ new Map()
|
|
7530
|
+
};
|
|
7531
|
+
locksInfo.lockInfo.push(lockInfo);
|
|
7532
|
+
} catch (error) {
|
|
7533
|
+
throw Error("fastLocksOfUser error");
|
|
7534
|
+
}
|
|
7535
|
+
}
|
|
7536
|
+
return locksInfo;
|
|
7537
|
+
}
|
|
7503
7538
|
async locksOfUser(user) {
|
|
7504
7539
|
const locksInfo = { owner: user, lockInfo: [] };
|
|
7505
7540
|
const { distribution } = this._sdk.sdkOptions;
|
|
@@ -7511,61 +7546,65 @@ var LockModule = class {
|
|
|
7511
7546
|
}
|
|
7512
7547
|
});
|
|
7513
7548
|
for (const item of ownerRes.data) {
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
votingRewards.
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7549
|
+
try {
|
|
7550
|
+
const { fields } = item.data.content;
|
|
7551
|
+
const aLockSummary = await this.aLockSummary(fields.id.id);
|
|
7552
|
+
const poolIncentiveTokens = await this.getVotingBribeRewardTokens(fields.id.id);
|
|
7553
|
+
const poolFeeTokens = await this.getVotingFeeRewardTokens(fields.id.id);
|
|
7554
|
+
const incentiveTokens = [];
|
|
7555
|
+
poolIncentiveTokens.forEach((value, key) => {
|
|
7556
|
+
incentiveTokens.push(...value);
|
|
7557
|
+
});
|
|
7558
|
+
const feeTokens = [];
|
|
7559
|
+
poolFeeTokens.forEach((value, key) => {
|
|
7560
|
+
feeTokens.push(...value);
|
|
7561
|
+
});
|
|
7562
|
+
const poolIncentiveRewards = await this.getPoolIncentiveRewards(fields.id.id, incentiveTokens);
|
|
7563
|
+
const votingRewards = /* @__PURE__ */ new Map();
|
|
7564
|
+
poolIncentiveRewards.forEach((value, coin) => {
|
|
7565
|
+
value.forEach((amount, pool) => {
|
|
7566
|
+
if (!votingRewards.has(pool)) {
|
|
7567
|
+
votingRewards.set(pool, []);
|
|
7568
|
+
}
|
|
7569
|
+
votingRewards.get(pool)?.push({
|
|
7570
|
+
kind: "incentiveCoin" /* Incentive */,
|
|
7571
|
+
token_addr: coin,
|
|
7572
|
+
amount: amount.toString()
|
|
7573
|
+
});
|
|
7537
7574
|
});
|
|
7538
7575
|
});
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7576
|
+
const poolFeeRewards = await this.getPoolFeeRewards(fields.id.id, feeTokens);
|
|
7577
|
+
poolFeeRewards.forEach((value, coin) => {
|
|
7578
|
+
value.forEach((amount, pool) => {
|
|
7579
|
+
if (!votingRewards.has(pool)) {
|
|
7580
|
+
votingRewards.set(pool, []);
|
|
7581
|
+
}
|
|
7582
|
+
votingRewards.get(pool)?.push({
|
|
7583
|
+
kind: "fee" /* Fee */,
|
|
7584
|
+
token_addr: coin,
|
|
7585
|
+
amount: amount.toString()
|
|
7586
|
+
});
|
|
7550
7587
|
});
|
|
7551
7588
|
});
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7589
|
+
const lockInfo = {
|
|
7590
|
+
lock_id: fields.id.id,
|
|
7591
|
+
amount: fields.amount,
|
|
7592
|
+
start: fields.start,
|
|
7593
|
+
end: fields.end,
|
|
7594
|
+
permanent: fields.permanent,
|
|
7595
|
+
rebase_amount: {
|
|
7596
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7597
|
+
token_addr: magma_token,
|
|
7598
|
+
amount: aLockSummary.reward_distributor_claimable
|
|
7599
|
+
},
|
|
7600
|
+
voting_power: aLockSummary.voting_power,
|
|
7601
|
+
// pool => incentive/fee => amount
|
|
7602
|
+
voting_rewards: votingRewards
|
|
7603
|
+
};
|
|
7604
|
+
locksInfo.lockInfo.push(lockInfo);
|
|
7605
|
+
} catch (error) {
|
|
7606
|
+
throw Error("locksOfUser error");
|
|
7607
|
+
}
|
|
7569
7608
|
}
|
|
7570
7609
|
return locksInfo;
|
|
7571
7610
|
}
|
|
@@ -9367,7 +9406,7 @@ var RpcModule = class extends import_client.SuiClient {
|
|
|
9367
9406
|
}
|
|
9368
9407
|
};
|
|
9369
9408
|
|
|
9370
|
-
// src/modules/
|
|
9409
|
+
// src/modules/gaugeModule.ts
|
|
9371
9410
|
var import_transactions11 = require("@mysten/sui/transactions");
|
|
9372
9411
|
var GaugeModule = class {
|
|
9373
9412
|
_sdk;
|