@magmaprotocol/magma-clmm-sdk 0.5.33 → 0.5.35
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 +1 -1
- package/dist/index.d.ts +169 -13
- package/dist/index.js +654 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +653 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ __export(src_exports, {
|
|
|
64
64
|
DeepbookCustodianV2Moudle: () => DeepbookCustodianV2Moudle,
|
|
65
65
|
DeepbookEndpointsV2Moudle: () => DeepbookEndpointsV2Moudle,
|
|
66
66
|
DeepbookUtils: () => DeepbookUtils,
|
|
67
|
+
DlmmScript: () => DlmmScript,
|
|
67
68
|
FEE_RATE_DENOMINATOR: () => FEE_RATE_DENOMINATOR,
|
|
68
69
|
GAS_SYMBOL: () => GAS_SYMBOL,
|
|
69
70
|
GAS_TYPE_ARG: () => GAS_TYPE_ARG,
|
|
@@ -508,6 +509,7 @@ var Voter = "voter";
|
|
|
508
509
|
var RewardDistributor = "reward_distributor";
|
|
509
510
|
var Gauge = "gauge";
|
|
510
511
|
var Minter = "minter";
|
|
512
|
+
var DlmmScript = "dlmm_script";
|
|
511
513
|
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
512
514
|
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
513
515
|
var DeepbookCustodianV2Moudle = "custodian_v2";
|
|
@@ -7594,6 +7596,57 @@ var LockModule = class {
|
|
|
7594
7596
|
}
|
|
7595
7597
|
return locksInfo;
|
|
7596
7598
|
}
|
|
7599
|
+
async locksOfUserV2(user) {
|
|
7600
|
+
const locksInfo = { owner: user, lockInfo: [] };
|
|
7601
|
+
const { distribution } = this._sdk.sdkOptions;
|
|
7602
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7603
|
+
const ownerRes = await this._sdk.fullClient.getOwnedObjectsByPage(user, {
|
|
7604
|
+
options: { showType: true, showContent: true, showDisplay: true, showOwner: true },
|
|
7605
|
+
filter: {
|
|
7606
|
+
MatchAll: [{ Package: distribution.package_id }, { StructType: `${distribution.package_id}::voting_escrow::Lock` }]
|
|
7607
|
+
}
|
|
7608
|
+
});
|
|
7609
|
+
const ids = ownerRes.data.map((item) => item.data.content.id.id);
|
|
7610
|
+
const lockSummary = await this.getAllLockSummary(ids);
|
|
7611
|
+
const lockIncentiveTokens = await this.getAllBribeRewardTokensOfLock(ids);
|
|
7612
|
+
const lockFeeTokens = await this.getAllVotingFeeRewardTokens(ids);
|
|
7613
|
+
const poolIncentiveRewards = await this.getAllIncentiveRewards(lockIncentiveTokens);
|
|
7614
|
+
const poolFeeRewards = await this.getAllFeeRewards(lockFeeTokens);
|
|
7615
|
+
for (const item of ownerRes.data) {
|
|
7616
|
+
const { fields } = item.data.content;
|
|
7617
|
+
const lock_id = fields.id.id;
|
|
7618
|
+
const votingRewards = /* @__PURE__ */ new Map();
|
|
7619
|
+
poolIncentiveRewards.get(lock_id)?.forEach((value, pool) => {
|
|
7620
|
+
if (!votingRewards.has(pool)) {
|
|
7621
|
+
votingRewards.set(pool, []);
|
|
7622
|
+
}
|
|
7623
|
+
votingRewards.get(pool)?.push(...value);
|
|
7624
|
+
});
|
|
7625
|
+
poolFeeRewards.get(lock_id)?.forEach((value, pool) => {
|
|
7626
|
+
if (!votingRewards.has(pool)) {
|
|
7627
|
+
votingRewards.set(pool, []);
|
|
7628
|
+
}
|
|
7629
|
+
votingRewards.get(pool)?.push(...value);
|
|
7630
|
+
});
|
|
7631
|
+
const lockInfo = {
|
|
7632
|
+
lock_id,
|
|
7633
|
+
amount: fields.amount,
|
|
7634
|
+
start: fields.start,
|
|
7635
|
+
end: fields.end,
|
|
7636
|
+
permanent: fields.permanent,
|
|
7637
|
+
rebase_amount: {
|
|
7638
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7639
|
+
token_addr: magma_token,
|
|
7640
|
+
amount: lockSummary.get(lock_id)?.reward_distributor_claimable || "0"
|
|
7641
|
+
},
|
|
7642
|
+
voting_power: lockSummary.get(lock_id)?.voting_power || "0",
|
|
7643
|
+
// pool => incentive/fee => amount
|
|
7644
|
+
voting_rewards: votingRewards
|
|
7645
|
+
};
|
|
7646
|
+
locksInfo.lockInfo.push(lockInfo);
|
|
7647
|
+
}
|
|
7648
|
+
return locksInfo;
|
|
7649
|
+
}
|
|
7597
7650
|
async locksOfUser(user) {
|
|
7598
7651
|
const locksInfo = { owner: user, lockInfo: [] };
|
|
7599
7652
|
const { distribution } = this._sdk.sdkOptions;
|
|
@@ -7786,6 +7839,57 @@ var LockModule = class {
|
|
|
7786
7839
|
});
|
|
7787
7840
|
return res;
|
|
7788
7841
|
}
|
|
7842
|
+
// Return: lock_id => ALockSummary
|
|
7843
|
+
async getAllLockSummary(lock_ids) {
|
|
7844
|
+
let tx = new import_transactions9.Transaction();
|
|
7845
|
+
for (const lock_id of lock_ids) {
|
|
7846
|
+
tx = await this._aLockSummary(lock_id, tx);
|
|
7847
|
+
}
|
|
7848
|
+
return this._parseLockSummary(tx);
|
|
7849
|
+
}
|
|
7850
|
+
async _aLockSummary(lock_id, tx) {
|
|
7851
|
+
tx = tx || new import_transactions9.Transaction();
|
|
7852
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7853
|
+
const { voting_escrow_id, magma_token, voter_id, reward_distributor_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7854
|
+
const typeArguments = [magma_token];
|
|
7855
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7856
|
+
throw Error("this config simulationAccount is not set right");
|
|
7857
|
+
}
|
|
7858
|
+
const args = [
|
|
7859
|
+
tx.object(voter_id),
|
|
7860
|
+
tx.object(voting_escrow_id),
|
|
7861
|
+
tx.object(reward_distributor_id),
|
|
7862
|
+
tx.object(lock_id),
|
|
7863
|
+
tx.object(CLOCK_ADDRESS)
|
|
7864
|
+
];
|
|
7865
|
+
tx.moveCall({
|
|
7866
|
+
target: `${integrate.published_at}::${VotingEscrow}::lock_summary`,
|
|
7867
|
+
arguments: args,
|
|
7868
|
+
typeArguments
|
|
7869
|
+
});
|
|
7870
|
+
return tx;
|
|
7871
|
+
}
|
|
7872
|
+
async _parseLockSummary(tx) {
|
|
7873
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
7874
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7875
|
+
transactionBlock: tx,
|
|
7876
|
+
sender: simulationAccount.address
|
|
7877
|
+
});
|
|
7878
|
+
if (simulateRes.error != null) {
|
|
7879
|
+
throw new Error(`lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7880
|
+
}
|
|
7881
|
+
const res = /* @__PURE__ */ new Map();
|
|
7882
|
+
simulateRes.events?.forEach((item) => {
|
|
7883
|
+
if (extractStructTagFromType(item.type).name === `LockSummary`) {
|
|
7884
|
+
res.set(item.parsedJson.lock_id, {
|
|
7885
|
+
fee_incentive_total: item.parsedJson.fee_incentive_total,
|
|
7886
|
+
reward_distributor_claimable: item.parsedJson.reward_distributor_claimable,
|
|
7887
|
+
voting_power: item.parsedJson.voting_power
|
|
7888
|
+
});
|
|
7889
|
+
}
|
|
7890
|
+
});
|
|
7891
|
+
return res;
|
|
7892
|
+
}
|
|
7789
7893
|
async allLockSummary() {
|
|
7790
7894
|
const tx = new import_transactions9.Transaction();
|
|
7791
7895
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -7866,6 +7970,54 @@ var LockModule = class {
|
|
|
7866
7970
|
});
|
|
7867
7971
|
return poolWeights;
|
|
7868
7972
|
}
|
|
7973
|
+
async getAllVotingFeeRewardTokens(lock_ids) {
|
|
7974
|
+
let tx = new import_transactions9.Transaction();
|
|
7975
|
+
for (const lock_id of lock_ids) {
|
|
7976
|
+
tx = await this._getVotingFeeRewardTokens(lock_id, tx);
|
|
7977
|
+
}
|
|
7978
|
+
return this._parseVotingFeeRewardTokens(tx);
|
|
7979
|
+
}
|
|
7980
|
+
async _getVotingFeeRewardTokens(lock_id, tx) {
|
|
7981
|
+
tx = tx || new import_transactions9.Transaction();
|
|
7982
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7983
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7984
|
+
const typeArguments = [magma_token];
|
|
7985
|
+
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
7986
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7987
|
+
throw Error("this config simulationAccount is not set right");
|
|
7988
|
+
}
|
|
7989
|
+
tx.moveCall({
|
|
7990
|
+
target: `${integrate.published_at}::${Voter}::get_voting_fee_reward_tokens`,
|
|
7991
|
+
arguments: args,
|
|
7992
|
+
typeArguments
|
|
7993
|
+
});
|
|
7994
|
+
return tx;
|
|
7995
|
+
}
|
|
7996
|
+
async _parseVotingFeeRewardTokens(tx) {
|
|
7997
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
7998
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7999
|
+
transactionBlock: tx,
|
|
8000
|
+
sender: simulationAccount.address
|
|
8001
|
+
});
|
|
8002
|
+
if (simulateRes.error != null) {
|
|
8003
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
8004
|
+
}
|
|
8005
|
+
const poolFeeRewardTokens = /* @__PURE__ */ new Map();
|
|
8006
|
+
simulateRes.events?.forEach((event) => {
|
|
8007
|
+
if (extractStructTagFromType(event.type).name === `EventFeeRewardTokens`) {
|
|
8008
|
+
const { lock_id } = event.parsedJson;
|
|
8009
|
+
if (!poolFeeRewardTokens.has(lock_id)) {
|
|
8010
|
+
poolFeeRewardTokens.set(lock_id, []);
|
|
8011
|
+
}
|
|
8012
|
+
event.parsedJson.list.contents.forEach((poolTokens) => {
|
|
8013
|
+
poolTokens.value.forEach((token) => {
|
|
8014
|
+
poolFeeRewardTokens.get(lock_id)?.push(token.name);
|
|
8015
|
+
});
|
|
8016
|
+
});
|
|
8017
|
+
}
|
|
8018
|
+
});
|
|
8019
|
+
return poolFeeRewardTokens;
|
|
8020
|
+
}
|
|
7869
8021
|
async getVotingFeeRewardTokens(lock_id) {
|
|
7870
8022
|
const tx = new import_transactions9.Transaction();
|
|
7871
8023
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -7889,7 +8041,7 @@ var LockModule = class {
|
|
|
7889
8041
|
}
|
|
7890
8042
|
const poolRewardTokens = /* @__PURE__ */ new Map();
|
|
7891
8043
|
simulateRes.events?.forEach((item) => {
|
|
7892
|
-
if (extractStructTagFromType(item.type).name === `
|
|
8044
|
+
if (extractStructTagFromType(item.type).name === `EventFeeRewardTokens`) {
|
|
7893
8045
|
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7894
8046
|
if (!poolRewardTokens.has(poolTokens.key)) {
|
|
7895
8047
|
poolRewardTokens.set(poolTokens.key, []);
|
|
@@ -7902,20 +8054,70 @@ var LockModule = class {
|
|
|
7902
8054
|
});
|
|
7903
8055
|
return poolRewardTokens;
|
|
7904
8056
|
}
|
|
7905
|
-
|
|
7906
|
-
|
|
8057
|
+
// tokens
|
|
8058
|
+
async getAllBribeRewardTokensOfLock(lock_ids) {
|
|
8059
|
+
let tx = new import_transactions9.Transaction();
|
|
8060
|
+
for (const lock_id of lock_ids) {
|
|
8061
|
+
tx = await this._getVotingBribeRewardTokens(lock_id, tx);
|
|
8062
|
+
}
|
|
8063
|
+
return this._parseVotingBribeRewardTokens(tx);
|
|
8064
|
+
}
|
|
8065
|
+
async _getVotingBribeRewardTokens(lock_id, tx) {
|
|
8066
|
+
tx = tx || new import_transactions9.Transaction();
|
|
7907
8067
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7908
8068
|
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7909
8069
|
const typeArguments = [magma_token];
|
|
8070
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
8071
|
+
throw Error("this config simulationAccount is not set right");
|
|
8072
|
+
}
|
|
7910
8073
|
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
7911
8074
|
tx.moveCall({
|
|
7912
8075
|
target: `${integrate.published_at}::${Voter}::get_voting_bribe_reward_tokens`,
|
|
7913
8076
|
arguments: args,
|
|
7914
8077
|
typeArguments
|
|
7915
8078
|
});
|
|
8079
|
+
return tx;
|
|
8080
|
+
}
|
|
8081
|
+
async _parseVotingBribeRewardTokens(tx) {
|
|
8082
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
8083
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
8084
|
+
transactionBlock: tx,
|
|
8085
|
+
sender: simulationAccount.address
|
|
8086
|
+
});
|
|
8087
|
+
if (simulateRes.error != null) {
|
|
8088
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
8089
|
+
}
|
|
8090
|
+
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
8091
|
+
simulateRes.events?.forEach((event) => {
|
|
8092
|
+
if (extractStructTagFromType(event.type).name === `EventBribeRewardTokens`) {
|
|
8093
|
+
const { lock_id } = event.parsedJson;
|
|
8094
|
+
if (!poolBirbeRewardTokens.has(lock_id)) {
|
|
8095
|
+
poolBirbeRewardTokens.set(lock_id, []);
|
|
8096
|
+
}
|
|
8097
|
+
event.parsedJson.list.contents.forEach((poolTokens) => {
|
|
8098
|
+
poolTokens.value.forEach((token) => {
|
|
8099
|
+
poolBirbeRewardTokens.get(lock_id)?.push(token.name);
|
|
8100
|
+
});
|
|
8101
|
+
});
|
|
8102
|
+
}
|
|
8103
|
+
});
|
|
8104
|
+
return poolBirbeRewardTokens;
|
|
8105
|
+
}
|
|
8106
|
+
// Return PoolId => tokens
|
|
8107
|
+
async getVotingBribeRewardTokens(lock_id) {
|
|
8108
|
+
const tx = new import_transactions9.Transaction();
|
|
8109
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
8110
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
8111
|
+
const typeArguments = [magma_token];
|
|
7916
8112
|
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7917
8113
|
throw Error("this config simulationAccount is not set right");
|
|
7918
8114
|
}
|
|
8115
|
+
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
8116
|
+
tx.moveCall({
|
|
8117
|
+
target: `${integrate.published_at}::${Voter}::get_voting_bribe_reward_tokens`,
|
|
8118
|
+
arguments: args,
|
|
8119
|
+
typeArguments
|
|
8120
|
+
});
|
|
7919
8121
|
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7920
8122
|
transactionBlock: tx,
|
|
7921
8123
|
sender: simulationAccount.address
|
|
@@ -7925,7 +8127,7 @@ var LockModule = class {
|
|
|
7925
8127
|
}
|
|
7926
8128
|
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
7927
8129
|
simulateRes.events?.forEach((item) => {
|
|
7928
|
-
if (extractStructTagFromType(item.type).name === `
|
|
8130
|
+
if (extractStructTagFromType(item.type).name === `EventBribeRewardTokens`) {
|
|
7929
8131
|
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7930
8132
|
if (!poolBirbeRewardTokens.has(poolTokens.key)) {
|
|
7931
8133
|
poolBirbeRewardTokens.set(poolTokens.key, []);
|
|
@@ -7938,6 +8140,68 @@ var LockModule = class {
|
|
|
7938
8140
|
});
|
|
7939
8141
|
return poolBirbeRewardTokens;
|
|
7940
8142
|
}
|
|
8143
|
+
async getAllFeeRewards(fee_tokens) {
|
|
8144
|
+
let tx = new import_transactions9.Transaction();
|
|
8145
|
+
fee_tokens.forEach((tokens, lock_id) => {
|
|
8146
|
+
tx = this._getFeeRewards(lock_id, tokens, tx);
|
|
8147
|
+
});
|
|
8148
|
+
return await this._parseFeeRewards(tx);
|
|
8149
|
+
}
|
|
8150
|
+
_getFeeRewards(lock_id, fee_tokens, tx) {
|
|
8151
|
+
if (fee_tokens.length % 2 !== 0) {
|
|
8152
|
+
fee_tokens.push(fee_tokens[0]);
|
|
8153
|
+
}
|
|
8154
|
+
for (let i = 0; i + 1 < fee_tokens.length; i += 2) {
|
|
8155
|
+
tx = this._getFeeRewardsInner(lock_id, fee_tokens[i], fee_tokens[i + 1], tx);
|
|
8156
|
+
}
|
|
8157
|
+
return tx;
|
|
8158
|
+
}
|
|
8159
|
+
_getFeeRewardsInner(lock_id, token_a, token_b, tx) {
|
|
8160
|
+
tx = tx || new import_transactions9.Transaction();
|
|
8161
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
8162
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
8163
|
+
const typeArguments = [magma_token, token_a, token_b];
|
|
8164
|
+
const args = [tx.object(voter_id), tx.object(lock_id), tx.object(CLOCK_ADDRESS)];
|
|
8165
|
+
const targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_fee_rewards`;
|
|
8166
|
+
tx.moveCall({
|
|
8167
|
+
target: targetFunc,
|
|
8168
|
+
arguments: args,
|
|
8169
|
+
typeArguments
|
|
8170
|
+
});
|
|
8171
|
+
return tx;
|
|
8172
|
+
}
|
|
8173
|
+
async _parseFeeRewards(tx) {
|
|
8174
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
8175
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
8176
|
+
transactionBlock: tx,
|
|
8177
|
+
sender: simulationAccount.address
|
|
8178
|
+
});
|
|
8179
|
+
if (simulateRes.error != null) {
|
|
8180
|
+
throw new Error(`getPoolIncentiveRewards error code: ${simulateRes.error ?? "unknown error"}`);
|
|
8181
|
+
}
|
|
8182
|
+
const poolFeeRewardTokens = /* @__PURE__ */ new Map();
|
|
8183
|
+
simulateRes.events?.forEach((event) => {
|
|
8184
|
+
if (extractStructTagFromType(event.type).name === `ClaimableVotingFee`) {
|
|
8185
|
+
const { lock_id } = event.parsedJson;
|
|
8186
|
+
if (!poolFeeRewardTokens.has(lock_id)) {
|
|
8187
|
+
poolFeeRewardTokens.set(lock_id, /* @__PURE__ */ new Map());
|
|
8188
|
+
}
|
|
8189
|
+
event.parsedJson.list.contents.forEach((rewardTokens) => {
|
|
8190
|
+
rewardTokens.value.contents.forEach((token) => {
|
|
8191
|
+
if (!poolFeeRewardTokens.get(lock_id)?.has(rewardTokens.key.name)) {
|
|
8192
|
+
poolFeeRewardTokens.get(lock_id)?.set(rewardTokens.key.name, []);
|
|
8193
|
+
}
|
|
8194
|
+
poolFeeRewardTokens.get(lock_id)?.get(rewardTokens.key.name)?.push({
|
|
8195
|
+
kind: "incentiveCoin" /* Incentive */,
|
|
8196
|
+
token_addr: token.key,
|
|
8197
|
+
amount: token.value
|
|
8198
|
+
});
|
|
8199
|
+
});
|
|
8200
|
+
});
|
|
8201
|
+
}
|
|
8202
|
+
});
|
|
8203
|
+
return poolFeeRewardTokens;
|
|
8204
|
+
}
|
|
7941
8205
|
async getPoolFeeRewards(lock_id, tokens) {
|
|
7942
8206
|
const poolFeeRewardTokens = /* @__PURE__ */ new Map();
|
|
7943
8207
|
if (tokens.length === 0) {
|
|
@@ -7988,6 +8252,78 @@ var LockModule = class {
|
|
|
7988
8252
|
});
|
|
7989
8253
|
return poolFeeRewardTokens;
|
|
7990
8254
|
}
|
|
8255
|
+
// params: lock_id => incentive_tokens
|
|
8256
|
+
// lock_id => Pool => rewardTokens
|
|
8257
|
+
async getAllIncentiveRewards(lock_incentive_tokens) {
|
|
8258
|
+
let tx = new import_transactions9.Transaction();
|
|
8259
|
+
lock_incentive_tokens.forEach((tokens, lock_id) => {
|
|
8260
|
+
tx = this._getIncentiveRewards(lock_id, tokens, tx);
|
|
8261
|
+
});
|
|
8262
|
+
return await this._parseIncentiveRewards(tx);
|
|
8263
|
+
}
|
|
8264
|
+
_getIncentiveRewards(lock_id, incentive_tokens, tx) {
|
|
8265
|
+
let i = 0;
|
|
8266
|
+
for (; i + 3 < incentive_tokens.length; i += 3) {
|
|
8267
|
+
this._getIncentiveRewardsInner(lock_id, incentive_tokens.slice(i, i + 3), tx);
|
|
8268
|
+
}
|
|
8269
|
+
return this._getIncentiveRewardsInner(lock_id, incentive_tokens.slice(i), tx);
|
|
8270
|
+
}
|
|
8271
|
+
_getIncentiveRewardsInner(locksId, incentive_tokens, tx) {
|
|
8272
|
+
tx = tx || new import_transactions9.Transaction();
|
|
8273
|
+
if (incentive_tokens.length > 3) {
|
|
8274
|
+
throw Error("Too many tokens");
|
|
8275
|
+
}
|
|
8276
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
8277
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
8278
|
+
const typeArguments = [magma_token, ...incentive_tokens];
|
|
8279
|
+
const args = [tx.object(voter_id), tx.object(locksId), tx.object(CLOCK_ADDRESS)];
|
|
8280
|
+
let targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_bribes_${incentive_tokens.length}`;
|
|
8281
|
+
if (incentive_tokens.length === 1) {
|
|
8282
|
+
targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_bribes`;
|
|
8283
|
+
}
|
|
8284
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
8285
|
+
throw Error("this config simulationAccount is not set right");
|
|
8286
|
+
}
|
|
8287
|
+
tx.moveCall({
|
|
8288
|
+
target: targetFunc,
|
|
8289
|
+
arguments: args,
|
|
8290
|
+
typeArguments
|
|
8291
|
+
});
|
|
8292
|
+
return tx;
|
|
8293
|
+
}
|
|
8294
|
+
async _parseIncentiveRewards(tx) {
|
|
8295
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
8296
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
8297
|
+
transactionBlock: tx,
|
|
8298
|
+
sender: simulationAccount.address
|
|
8299
|
+
});
|
|
8300
|
+
if (simulateRes.error != null) {
|
|
8301
|
+
throw new Error(`getPoolIncentiveRewards error code: ${simulateRes.error ?? "unknown error"}`);
|
|
8302
|
+
}
|
|
8303
|
+
const poolBribeRewardTokens = /* @__PURE__ */ new Map();
|
|
8304
|
+
simulateRes.events?.forEach((event) => {
|
|
8305
|
+
if (extractStructTagFromType(event.type).name === `ClaimableVotingBribes`) {
|
|
8306
|
+
const { lock_id } = event.parsedJson;
|
|
8307
|
+
if (!poolBribeRewardTokens.has(lock_id)) {
|
|
8308
|
+
poolBribeRewardTokens.set(lock_id, /* @__PURE__ */ new Map());
|
|
8309
|
+
}
|
|
8310
|
+
event.parsedJson.list.contents.forEach((rewardTokens) => {
|
|
8311
|
+
rewardTokens.value.contents.forEach((token) => {
|
|
8312
|
+
if (!poolBribeRewardTokens.get(lock_id)?.has(rewardTokens.key.name)) {
|
|
8313
|
+
poolBribeRewardTokens.get(lock_id)?.set(rewardTokens.key.name, []);
|
|
8314
|
+
}
|
|
8315
|
+
poolBribeRewardTokens.get(lock_id)?.get(rewardTokens.key.name)?.push({
|
|
8316
|
+
kind: "incentiveCoin" /* Incentive */,
|
|
8317
|
+
token_addr: token.key,
|
|
8318
|
+
amount: token.value
|
|
8319
|
+
});
|
|
8320
|
+
});
|
|
8321
|
+
});
|
|
8322
|
+
}
|
|
8323
|
+
});
|
|
8324
|
+
return poolBribeRewardTokens;
|
|
8325
|
+
}
|
|
8326
|
+
// coin => pool => amount
|
|
7991
8327
|
async getPoolIncentiveRewards(lock_id, incentive_tokens) {
|
|
7992
8328
|
const poolBribeRewardTokens = /* @__PURE__ */ new Map();
|
|
7993
8329
|
if (incentive_tokens.length === 0) {
|
|
@@ -8014,14 +8350,14 @@ var LockModule = class {
|
|
|
8014
8350
|
if (incentive_tokens.length === 1) {
|
|
8015
8351
|
targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_bribes`;
|
|
8016
8352
|
}
|
|
8353
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
8354
|
+
throw Error("this config simulationAccount is not set right");
|
|
8355
|
+
}
|
|
8017
8356
|
tx.moveCall({
|
|
8018
8357
|
target: targetFunc,
|
|
8019
8358
|
arguments: args,
|
|
8020
8359
|
typeArguments
|
|
8021
8360
|
});
|
|
8022
|
-
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
8023
|
-
throw Error("this config simulationAccount is not set right");
|
|
8024
|
-
}
|
|
8025
8361
|
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
8026
8362
|
transactionBlock: tx,
|
|
8027
8363
|
sender: simulationAccount.address
|
|
@@ -9668,6 +10004,21 @@ var GaugeModule = class {
|
|
|
9668
10004
|
});
|
|
9669
10005
|
return tx;
|
|
9670
10006
|
}
|
|
10007
|
+
async getAllRewardByPositions(paramsList) {
|
|
10008
|
+
const tx = new import_transactions11.Transaction();
|
|
10009
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
10010
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
10011
|
+
paramsList.forEach((params) => {
|
|
10012
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB, magma_token];
|
|
10013
|
+
const args = [tx.object(params.gaugeId), tx.object(params.poolId), tx.object(params.positionId), tx.object(CLOCK_ADDRESS)];
|
|
10014
|
+
tx.moveCall({
|
|
10015
|
+
target: `${integrate.published_at}::${Gauge}::get_reward_by_position`,
|
|
10016
|
+
arguments: args,
|
|
10017
|
+
typeArguments
|
|
10018
|
+
});
|
|
10019
|
+
});
|
|
10020
|
+
return tx;
|
|
10021
|
+
}
|
|
9671
10022
|
async getEpochRewardByPool(pool, incentive_tokens) {
|
|
9672
10023
|
const tx = new import_transactions11.Transaction();
|
|
9673
10024
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -9700,6 +10051,277 @@ var GaugeModule = class {
|
|
|
9700
10051
|
}
|
|
9701
10052
|
};
|
|
9702
10053
|
|
|
10054
|
+
// src/modules/dlmm.ts
|
|
10055
|
+
var import_transactions12 = require("@mysten/sui/transactions");
|
|
10056
|
+
var import_decimal10 = __toESM(require("decimal.js"));
|
|
10057
|
+
var import_calc_dlmm = require("@magmaprotocol/calc_dlmm");
|
|
10058
|
+
var DlmmModule = class {
|
|
10059
|
+
_sdk;
|
|
10060
|
+
constructor(sdk) {
|
|
10061
|
+
this._sdk = sdk;
|
|
10062
|
+
}
|
|
10063
|
+
get sdk() {
|
|
10064
|
+
return this._sdk;
|
|
10065
|
+
}
|
|
10066
|
+
// eg: fetch pool active_index
|
|
10067
|
+
async fetchPairParams(params) {
|
|
10068
|
+
const tx = new import_transactions12.Transaction();
|
|
10069
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10070
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10071
|
+
const args = [tx.object(params.pair)];
|
|
10072
|
+
tx.moveCall({
|
|
10073
|
+
target: `${integrate.published_at}::${DlmmScript}::fetch_pair_params`,
|
|
10074
|
+
arguments: args,
|
|
10075
|
+
typeArguments
|
|
10076
|
+
});
|
|
10077
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10078
|
+
transactionBlock: tx,
|
|
10079
|
+
sender: simulationAccount.address
|
|
10080
|
+
});
|
|
10081
|
+
if (simulateRes.error != null) {
|
|
10082
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10083
|
+
}
|
|
10084
|
+
let res = {
|
|
10085
|
+
base_factor: 0,
|
|
10086
|
+
filter_period: 0,
|
|
10087
|
+
decay_period: 0,
|
|
10088
|
+
reduction_factor: 0,
|
|
10089
|
+
variable_fee_control: 0,
|
|
10090
|
+
protocol_share: 0,
|
|
10091
|
+
max_volatility_accumulator: 0,
|
|
10092
|
+
volatility_accumulator: 0,
|
|
10093
|
+
volatility_reference: 0,
|
|
10094
|
+
index_reference: 0,
|
|
10095
|
+
time_of_last_update: 0,
|
|
10096
|
+
oracle_index: 0,
|
|
10097
|
+
active_index: 0
|
|
10098
|
+
};
|
|
10099
|
+
simulateRes.events?.forEach((item) => {
|
|
10100
|
+
console.log(extractStructTagFromType(item.type).name);
|
|
10101
|
+
if (extractStructTagFromType(item.type).name === `EventPairParams`) {
|
|
10102
|
+
res = item.parsedJson.params;
|
|
10103
|
+
}
|
|
10104
|
+
});
|
|
10105
|
+
return res;
|
|
10106
|
+
}
|
|
10107
|
+
// params price: input (b/(10^b_decimal))/(a/(10^a_decimal))
|
|
10108
|
+
price_to_storage_id(price, bin_step, tokenADecimal, tokenBDecimal) {
|
|
10109
|
+
const priceDec = new import_decimal10.default(price);
|
|
10110
|
+
const tenDec = new import_decimal10.default(10);
|
|
10111
|
+
const twoDec = new import_decimal10.default(2);
|
|
10112
|
+
const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
|
|
10113
|
+
const active_id = (0, import_calc_dlmm.get_real_id_from_price)(price_x128.toFixed(0).toString(), bin_step);
|
|
10114
|
+
return (0, import_calc_dlmm.get_storage_id_from_real_id)(active_id);
|
|
10115
|
+
}
|
|
10116
|
+
// NOTE: x, y should be sorted
|
|
10117
|
+
async createPairPayload(params) {
|
|
10118
|
+
const storage_id = this.price_to_storage_id(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal);
|
|
10119
|
+
const tx = new import_transactions12.Transaction();
|
|
10120
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10121
|
+
const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10122
|
+
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10123
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10124
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10125
|
+
const args = [tx.object(dlmmConfig.factory), tx.object(global_config_id), tx.pure.u16(params.bin_step), tx.pure.u32(storage_id)];
|
|
10126
|
+
tx.moveCall({
|
|
10127
|
+
target: `${integrate.published_at}::${DlmmScript}::create_pair`,
|
|
10128
|
+
typeArguments,
|
|
10129
|
+
arguments: args
|
|
10130
|
+
});
|
|
10131
|
+
return tx;
|
|
10132
|
+
}
|
|
10133
|
+
async createAddLiquidityPayload() {
|
|
10134
|
+
const tx = new import_transactions12.Transaction();
|
|
10135
|
+
return tx;
|
|
10136
|
+
}
|
|
10137
|
+
// Create a position by percent
|
|
10138
|
+
async mintPercent(params) {
|
|
10139
|
+
const tx = new import_transactions12.Transaction();
|
|
10140
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10141
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10142
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10143
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10144
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10145
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10146
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10147
|
+
const args = [
|
|
10148
|
+
tx.object(params.pair),
|
|
10149
|
+
tx.object(dlmmConfig.factory),
|
|
10150
|
+
primaryCoinAInputs.targetCoin,
|
|
10151
|
+
primaryCoinBInputs.targetCoin,
|
|
10152
|
+
tx.pure.u64(params.amountATotal),
|
|
10153
|
+
tx.pure.u64(params.amountBTotal),
|
|
10154
|
+
tx.pure.vector("u32", params.storageIds),
|
|
10155
|
+
tx.pure.vector("u64", params.binsAPercent),
|
|
10156
|
+
tx.pure.vector("u64", params.binsBPercent),
|
|
10157
|
+
tx.pure.address(params.to),
|
|
10158
|
+
tx.object(CLOCK_ADDRESS)
|
|
10159
|
+
];
|
|
10160
|
+
tx.moveCall({
|
|
10161
|
+
target: `${integrate.published_at}::${DlmmScript}::mint_percent`,
|
|
10162
|
+
typeArguments,
|
|
10163
|
+
arguments: args
|
|
10164
|
+
});
|
|
10165
|
+
return tx;
|
|
10166
|
+
}
|
|
10167
|
+
// Create a position by amount
|
|
10168
|
+
async createPositionByAmount(params) {
|
|
10169
|
+
const tx = new import_transactions12.Transaction();
|
|
10170
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10171
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10172
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10173
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10174
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10175
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10176
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10177
|
+
const args = [
|
|
10178
|
+
tx.object(params.pair),
|
|
10179
|
+
tx.object(dlmmConfig.factory),
|
|
10180
|
+
primaryCoinAInputs.targetCoin,
|
|
10181
|
+
primaryCoinBInputs.targetCoin,
|
|
10182
|
+
tx.pure.vector("u32", params.storageIds),
|
|
10183
|
+
tx.pure.vector("u64", params.amountsA),
|
|
10184
|
+
tx.pure.vector("u64", params.amountsB),
|
|
10185
|
+
tx.pure.address(params.to),
|
|
10186
|
+
tx.object(CLOCK_ADDRESS)
|
|
10187
|
+
];
|
|
10188
|
+
tx.moveCall({
|
|
10189
|
+
target: `${integrate.published_at}::${DlmmScript}::mint_amounts`,
|
|
10190
|
+
typeArguments,
|
|
10191
|
+
arguments: args
|
|
10192
|
+
});
|
|
10193
|
+
return tx;
|
|
10194
|
+
}
|
|
10195
|
+
async swap(params) {
|
|
10196
|
+
const tx = new import_transactions12.Transaction();
|
|
10197
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10198
|
+
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10199
|
+
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10200
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10201
|
+
const args = [
|
|
10202
|
+
tx.object(params.pair),
|
|
10203
|
+
tx.object(global_config_id),
|
|
10204
|
+
tx.object(params.coinTypeA),
|
|
10205
|
+
tx.object(params.coinTypeB),
|
|
10206
|
+
tx.pure.u64(params.amountIn),
|
|
10207
|
+
tx.pure.u64(params.minAmountOut),
|
|
10208
|
+
tx.pure.bool(params.swapForY),
|
|
10209
|
+
tx.pure.address(params.to),
|
|
10210
|
+
tx.object(CLOCK_ADDRESS)
|
|
10211
|
+
];
|
|
10212
|
+
tx.moveCall({
|
|
10213
|
+
target: `${integrate.published_at}::${DlmmScript}::swap`,
|
|
10214
|
+
typeArguments,
|
|
10215
|
+
arguments: args
|
|
10216
|
+
});
|
|
10217
|
+
return tx;
|
|
10218
|
+
}
|
|
10219
|
+
async fetchBins(params) {
|
|
10220
|
+
const tx = new import_transactions12.Transaction();
|
|
10221
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10222
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10223
|
+
const args = [tx.object(params.pair), tx.pure.u64(params.offset), tx.pure.u64(params.limit)];
|
|
10224
|
+
tx.moveCall({
|
|
10225
|
+
target: `${integrate.published_at}::${DlmmScript}::fetch_bins`,
|
|
10226
|
+
arguments: args,
|
|
10227
|
+
typeArguments
|
|
10228
|
+
});
|
|
10229
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10230
|
+
transactionBlock: tx,
|
|
10231
|
+
sender: simulationAccount.address
|
|
10232
|
+
});
|
|
10233
|
+
if (simulateRes.error != null) {
|
|
10234
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10235
|
+
}
|
|
10236
|
+
const res = [];
|
|
10237
|
+
simulateRes.events?.forEach((item) => {
|
|
10238
|
+
if (extractStructTagFromType(item.type).name === `EventFetchBins`) {
|
|
10239
|
+
}
|
|
10240
|
+
});
|
|
10241
|
+
return res;
|
|
10242
|
+
}
|
|
10243
|
+
async getPositionLiquidity(params) {
|
|
10244
|
+
const tx = new import_transactions12.Transaction();
|
|
10245
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10246
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10247
|
+
const args = [tx.object(params.pair), tx.object(params.positionId)];
|
|
10248
|
+
tx.moveCall({
|
|
10249
|
+
target: `${integrate.published_at}::${DlmmScript}::position_liquidity`,
|
|
10250
|
+
arguments: args,
|
|
10251
|
+
typeArguments
|
|
10252
|
+
});
|
|
10253
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10254
|
+
transactionBlock: tx,
|
|
10255
|
+
sender: simulationAccount.address
|
|
10256
|
+
});
|
|
10257
|
+
if (simulateRes.error != null) {
|
|
10258
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10259
|
+
}
|
|
10260
|
+
const out = {
|
|
10261
|
+
shares: 0,
|
|
10262
|
+
liquidity: 0,
|
|
10263
|
+
x_equivalent: 0,
|
|
10264
|
+
y_equivalent: 0,
|
|
10265
|
+
bin_ids: [],
|
|
10266
|
+
bin_x_eq: [],
|
|
10267
|
+
bin_y_eq: [],
|
|
10268
|
+
bin_liquidity: []
|
|
10269
|
+
};
|
|
10270
|
+
simulateRes.events?.forEach((item) => {
|
|
10271
|
+
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
10272
|
+
out.shares = item.parsedJson.shares;
|
|
10273
|
+
out.liquidity = item.parsedJson.liquidity;
|
|
10274
|
+
out.x_equivalent = item.parsedJson.x_equivalent;
|
|
10275
|
+
out.y_equivalent = item.parsedJson.y_equivalent;
|
|
10276
|
+
out.bin_ids = item.parsedJson.bin_id;
|
|
10277
|
+
out.bin_x_eq = item.parsedJson.bin_x_eq;
|
|
10278
|
+
out.bin_y_eq = item.parsedJson.bin_y_eq;
|
|
10279
|
+
out.bin_liquidity = item.parsedJson.bin_liquidity;
|
|
10280
|
+
}
|
|
10281
|
+
});
|
|
10282
|
+
return out;
|
|
10283
|
+
}
|
|
10284
|
+
async getPairLiquidity(params) {
|
|
10285
|
+
const tx = new import_transactions12.Transaction();
|
|
10286
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10287
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10288
|
+
const args = [tx.object(params.pair)];
|
|
10289
|
+
tx.moveCall({
|
|
10290
|
+
target: `${integrate.published_at}::${DlmmScript}::pair_liquidity`,
|
|
10291
|
+
arguments: args,
|
|
10292
|
+
typeArguments
|
|
10293
|
+
});
|
|
10294
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10295
|
+
transactionBlock: tx,
|
|
10296
|
+
sender: simulationAccount.address
|
|
10297
|
+
});
|
|
10298
|
+
if (simulateRes.error != null) {
|
|
10299
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10300
|
+
}
|
|
10301
|
+
const out = {
|
|
10302
|
+
shares: 0,
|
|
10303
|
+
liquidity: 0,
|
|
10304
|
+
x: 0,
|
|
10305
|
+
y: 0,
|
|
10306
|
+
bin_ids: [],
|
|
10307
|
+
bin_x: [],
|
|
10308
|
+
bin_y: []
|
|
10309
|
+
};
|
|
10310
|
+
simulateRes.events?.forEach((item) => {
|
|
10311
|
+
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
10312
|
+
out.shares = item.parsedJson.shares;
|
|
10313
|
+
out.liquidity = item.parsedJson.liquidity;
|
|
10314
|
+
out.x = item.parsedJson.x;
|
|
10315
|
+
out.y = item.parsedJson.y;
|
|
10316
|
+
out.bin_ids = item.bin_ids;
|
|
10317
|
+
out.bin_x = item.bin_x;
|
|
10318
|
+
out.bin_y = item.bin_y;
|
|
10319
|
+
}
|
|
10320
|
+
});
|
|
10321
|
+
return out;
|
|
10322
|
+
}
|
|
10323
|
+
};
|
|
10324
|
+
|
|
9703
10325
|
// src/sdk.ts
|
|
9704
10326
|
var MagmaClmmSDK = class {
|
|
9705
10327
|
_cache = {};
|
|
@@ -9724,6 +10346,7 @@ var MagmaClmmSDK = class {
|
|
|
9724
10346
|
*/
|
|
9725
10347
|
_lock;
|
|
9726
10348
|
_gauge;
|
|
10349
|
+
_dlmm;
|
|
9727
10350
|
/**
|
|
9728
10351
|
* Provide interact with a position rewarder interface.
|
|
9729
10352
|
*/
|
|
@@ -9761,6 +10384,7 @@ var MagmaClmmSDK = class {
|
|
|
9761
10384
|
this._swap = new SwapModule(this);
|
|
9762
10385
|
this._lock = new LockModule(this);
|
|
9763
10386
|
this._gauge = new GaugeModule(this);
|
|
10387
|
+
this._dlmm = new DlmmModule(this);
|
|
9764
10388
|
this._pool = new PoolModule(this);
|
|
9765
10389
|
this._position = new PositionModule(this);
|
|
9766
10390
|
this._rewarder = new RewarderModule(this);
|
|
@@ -9798,6 +10422,9 @@ var MagmaClmmSDK = class {
|
|
|
9798
10422
|
get Gauge() {
|
|
9799
10423
|
return this._gauge;
|
|
9800
10424
|
}
|
|
10425
|
+
get Dlmm() {
|
|
10426
|
+
return this._dlmm;
|
|
10427
|
+
}
|
|
9801
10428
|
/**
|
|
9802
10429
|
* Getter for the fullClient property.
|
|
9803
10430
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -9971,6 +10598,7 @@ var main_default = MagmaClmmSDK;
|
|
|
9971
10598
|
var SDKConfig = {
|
|
9972
10599
|
clmmConfig: {
|
|
9973
10600
|
pools_id: "0xfa145b9de10fe858be81edd1c6cdffcf27be9d016de02a1345eb1009a68ba8b2",
|
|
10601
|
+
// clmm and dlmm both use this global_config
|
|
9974
10602
|
global_config_id: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
9975
10603
|
global_vault_id: "0xa7e1102f222b6eb81ccc8a126e7feb2353342be9df6f6646a77c4519da29c071",
|
|
9976
10604
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
@@ -9990,7 +10618,11 @@ var SDKConfig = {
|
|
|
9990
10618
|
distribution_cfg: "0xaff8d151ac29317201151f97d28c546b3c5923d8cfc5499f40dea61c4022c949",
|
|
9991
10619
|
magma_token: "0x7161c6c6bb65f852797c8f7f5c4f8d57adaf796e1b840921f9e23fabeadfd54e::magma::MAGMA",
|
|
9992
10620
|
minter_id: "0x4fa5766cd83b33b215b139fec27ac344040f3bbd84fcbee7b61fc671aadc51fa"
|
|
9993
|
-
}
|
|
10621
|
+
},
|
|
10622
|
+
dlmmConfig: {
|
|
10623
|
+
factory: ""
|
|
10624
|
+
},
|
|
10625
|
+
gaugeConfig: {}
|
|
9994
10626
|
};
|
|
9995
10627
|
var clmmMainnet = {
|
|
9996
10628
|
fullRpcUrl: (0, import_client2.getFullnodeUrl)("mainnet"),
|
|
@@ -10007,6 +10639,11 @@ var clmmMainnet = {
|
|
|
10007
10639
|
published_at: "0x4a35d3dfef55ed3631b7158544c6322a23bc434fe4fca1234cb680ce0505f82d",
|
|
10008
10640
|
config: SDKConfig.clmmConfig
|
|
10009
10641
|
},
|
|
10642
|
+
dlmm_pool: {
|
|
10643
|
+
package_id: "",
|
|
10644
|
+
published_at: "",
|
|
10645
|
+
config: SDKConfig.dlmmConfig
|
|
10646
|
+
},
|
|
10010
10647
|
distribution: {
|
|
10011
10648
|
package_id: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b",
|
|
10012
10649
|
published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
|
|
@@ -10060,6 +10697,9 @@ var SDKConfig2 = {
|
|
|
10060
10697
|
distribution_cfg: "0x94e23846c975e2faf89a61bfc2b10ad64decab9069eb1f9fc39752b010868c74",
|
|
10061
10698
|
magma_token: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1::magma_token::MAGMA_TOKEN",
|
|
10062
10699
|
minter_id: "0x89435d6b2a510ba50ca23303f10e91ec058f138a88f69a43fe03cd22edb214c5"
|
|
10700
|
+
},
|
|
10701
|
+
dlmmConfig: {
|
|
10702
|
+
factory: ""
|
|
10063
10703
|
}
|
|
10064
10704
|
};
|
|
10065
10705
|
var clmmTestnet = {
|
|
@@ -10074,6 +10714,11 @@ var clmmTestnet = {
|
|
|
10074
10714
|
published_at: "0x23e0b5ab4aa63d0e6fd98fa5e247bcf9b36ad716b479d39e56b2ba9ff631e09d",
|
|
10075
10715
|
config: SDKConfig2.clmmConfig
|
|
10076
10716
|
},
|
|
10717
|
+
dlmm_pool: {
|
|
10718
|
+
package_id: "",
|
|
10719
|
+
published_at: "",
|
|
10720
|
+
config: SDKConfig2.dlmmConfig
|
|
10721
|
+
},
|
|
10077
10722
|
distribution: {
|
|
10078
10723
|
package_id: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1",
|
|
10079
10724
|
published_at: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1"
|
|
@@ -10149,6 +10794,7 @@ var src_default = MagmaClmmSDK;
|
|
|
10149
10794
|
DeepbookCustodianV2Moudle,
|
|
10150
10795
|
DeepbookEndpointsV2Moudle,
|
|
10151
10796
|
DeepbookUtils,
|
|
10797
|
+
DlmmScript,
|
|
10152
10798
|
FEE_RATE_DENOMINATOR,
|
|
10153
10799
|
GAS_SYMBOL,
|
|
10154
10800
|
GAS_TYPE_ARG,
|