@magmaprotocol/magma-clmm-sdk 0.3.1 → 0.4.0
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 +27 -21
- package/dist/index.d.ts +178 -1
- package/dist/index.js +745 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +735 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -298,6 +298,9 @@ var ClmmIntegrateRouterWithPartnerModule = "router_with_partner";
|
|
|
298
298
|
var ClmmFetcherModule = "fetcher_script";
|
|
299
299
|
var ClmmExpectSwapModule = "expect_swap";
|
|
300
300
|
var ClmmIntegrateUtilsModule = "utils";
|
|
301
|
+
var VotingEscrow = "voting_escrow";
|
|
302
|
+
var Voter = "voter";
|
|
303
|
+
var RewardDistributor = "reward_distributor";
|
|
301
304
|
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
302
305
|
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
303
306
|
var DeepbookCustodianV2Moudle = "custodian_v2";
|
|
@@ -2754,6 +2757,246 @@ var _TransactionUtil = class {
|
|
|
2754
2757
|
tx = _TransactionUtil.buildSwapTransactionArgs(tx, params, sdk.sdkOptions, primaryCoinInputA, primaryCoinInputB);
|
|
2755
2758
|
return tx;
|
|
2756
2759
|
}
|
|
2760
|
+
static buildCreateLockTransaction(sdk, params, allCoinAsset) {
|
|
2761
|
+
let tx = new Transaction();
|
|
2762
|
+
tx.setSender(sdk.senderAddress);
|
|
2763
|
+
const { magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2764
|
+
const lockCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(params.amount), magma_token, false, true);
|
|
2765
|
+
tx = _TransactionUtil.buildCreateTransactionArgs(tx, params, sdk.sdkOptions, lockCoinInput);
|
|
2766
|
+
return tx;
|
|
2767
|
+
}
|
|
2768
|
+
static buildCreateTransactionArgs(tx, params, sdkOptions, lockCoinInput) {
|
|
2769
|
+
const { integrate } = sdkOptions;
|
|
2770
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdkOptions.magma_config);
|
|
2771
|
+
const typeArguments = [magma_token];
|
|
2772
|
+
const functionName = "create_lock";
|
|
2773
|
+
const coins = tx.makeMoveVec({ elements: [lockCoinInput.targetCoin] });
|
|
2774
|
+
const args = [
|
|
2775
|
+
tx.object(voting_escrow_id),
|
|
2776
|
+
coins,
|
|
2777
|
+
tx.pure.u64(params.lockDurationDays),
|
|
2778
|
+
tx.pure.bool(params.permanent),
|
|
2779
|
+
tx.object(CLOCK_ADDRESS)
|
|
2780
|
+
];
|
|
2781
|
+
tx.moveCall({
|
|
2782
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2783
|
+
typeArguments,
|
|
2784
|
+
arguments: args
|
|
2785
|
+
});
|
|
2786
|
+
return tx;
|
|
2787
|
+
}
|
|
2788
|
+
static buildIncreaseLockAmountTransaction(sdk, params, allCoinAsset) {
|
|
2789
|
+
const { magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2790
|
+
let tx = new Transaction();
|
|
2791
|
+
tx.setSender(sdk.senderAddress);
|
|
2792
|
+
const lockCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(params.amount), magma_token, false, true);
|
|
2793
|
+
tx = _TransactionUtil.buildIncreaseLockAmountTransactionArgs(tx, params, sdk.sdkOptions, lockCoinInput);
|
|
2794
|
+
return tx;
|
|
2795
|
+
}
|
|
2796
|
+
static buildIncreaseLockAmountTransactionArgs(tx, params, sdkOptions, increaseCoinInput) {
|
|
2797
|
+
const { integrate } = sdkOptions;
|
|
2798
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdkOptions.magma_config);
|
|
2799
|
+
const typeArguments = [magma_token];
|
|
2800
|
+
const functionName = "increase_amount_single_coin";
|
|
2801
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), increaseCoinInput.targetCoin, tx.object(CLOCK_ADDRESS)];
|
|
2802
|
+
tx.moveCall({
|
|
2803
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2804
|
+
typeArguments,
|
|
2805
|
+
arguments: args
|
|
2806
|
+
});
|
|
2807
|
+
return tx;
|
|
2808
|
+
}
|
|
2809
|
+
// public fun merge<T>(self: &mut VotingEscrow<T>, from_lock: Lock, to_lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
2810
|
+
static buildMergeLockTransaction(sdk, params) {
|
|
2811
|
+
const tx = new Transaction();
|
|
2812
|
+
tx.setSender(sdk.senderAddress);
|
|
2813
|
+
const { integrate } = sdk.sdkOptions;
|
|
2814
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2815
|
+
const typeArguments = [magma_token];
|
|
2816
|
+
const functionName = "merge_locks";
|
|
2817
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.fromLockId), tx.object(params.toLockId), tx.object(CLOCK_ADDRESS)];
|
|
2818
|
+
tx.moveCall({
|
|
2819
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2820
|
+
typeArguments,
|
|
2821
|
+
arguments: args
|
|
2822
|
+
});
|
|
2823
|
+
return tx;
|
|
2824
|
+
}
|
|
2825
|
+
// public fun transfer<T>(lock: Lock, ve: &mut VotingEscrow<T>, to: address, clock: &Clock, ctx: &mut TxContext) {
|
|
2826
|
+
static buildTransferLockTransaction(sdk, params) {
|
|
2827
|
+
const tx = new Transaction();
|
|
2828
|
+
tx.setSender(sdk.senderAddress);
|
|
2829
|
+
const { integrate } = sdk.sdkOptions;
|
|
2830
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2831
|
+
const typeArguments = [magma_token];
|
|
2832
|
+
const functionName = "transfer";
|
|
2833
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(params.to), tx.object(CLOCK_ADDRESS)];
|
|
2834
|
+
tx.moveCall({
|
|
2835
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2836
|
+
typeArguments,
|
|
2837
|
+
arguments: args
|
|
2838
|
+
});
|
|
2839
|
+
return tx;
|
|
2840
|
+
}
|
|
2841
|
+
// public fun increase_unlock_time<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, lock_duration: u64, clock: &Clock, ctx: &mut TxContext) {
|
|
2842
|
+
static buildIncreaseUnlockTimeTransaction(sdk, params) {
|
|
2843
|
+
const tx = new Transaction();
|
|
2844
|
+
tx.setGasBudget(1e8);
|
|
2845
|
+
tx.setSender(sdk.senderAddress);
|
|
2846
|
+
const oneDay = 24 * 60 * 60;
|
|
2847
|
+
const newLockDuration = Math.ceil((params.newLockEndAt - Date.now()) / oneDay);
|
|
2848
|
+
const { integrate } = sdk.sdkOptions;
|
|
2849
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2850
|
+
const typeArguments = [magma_token];
|
|
2851
|
+
const functionName = "increase_unlock_time";
|
|
2852
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.pure.u64(newLockDuration), tx.object(CLOCK_ADDRESS)];
|
|
2853
|
+
tx.moveCall({
|
|
2854
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2855
|
+
typeArguments,
|
|
2856
|
+
arguments: args
|
|
2857
|
+
});
|
|
2858
|
+
return tx;
|
|
2859
|
+
}
|
|
2860
|
+
// public fun lock_permanent<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
2861
|
+
static buildLockPermanentTransaction(sdk, params) {
|
|
2862
|
+
const tx = new Transaction();
|
|
2863
|
+
tx.setSender(sdk.senderAddress);
|
|
2864
|
+
const { integrate } = sdk.sdkOptions;
|
|
2865
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2866
|
+
const typeArguments = [magma_token];
|
|
2867
|
+
const functionName = "lock_permanent";
|
|
2868
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
2869
|
+
tx.moveCall({
|
|
2870
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2871
|
+
typeArguments,
|
|
2872
|
+
arguments: args
|
|
2873
|
+
});
|
|
2874
|
+
return tx;
|
|
2875
|
+
}
|
|
2876
|
+
static buildUnlockPermanentTransaction(sdk, params) {
|
|
2877
|
+
const tx = new Transaction();
|
|
2878
|
+
tx.setSender(sdk.senderAddress);
|
|
2879
|
+
const { integrate } = sdk.sdkOptions;
|
|
2880
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2881
|
+
const typeArguments = [magma_token];
|
|
2882
|
+
const functionName = "unlock_permanent";
|
|
2883
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
2884
|
+
tx.moveCall({
|
|
2885
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2886
|
+
typeArguments,
|
|
2887
|
+
arguments: args
|
|
2888
|
+
});
|
|
2889
|
+
return tx;
|
|
2890
|
+
}
|
|
2891
|
+
static buildVoteTransaction(sdk, params) {
|
|
2892
|
+
const tx = new Transaction();
|
|
2893
|
+
tx.setSender(sdk.senderAddress);
|
|
2894
|
+
tx.setGasBudget(1e8);
|
|
2895
|
+
const { integrate } = sdk.sdkOptions;
|
|
2896
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2897
|
+
const typeArguments = [magma_token];
|
|
2898
|
+
const functionName = "vote";
|
|
2899
|
+
const pools = tx.pure.vector("id", params.pools);
|
|
2900
|
+
const weights = tx.makeMoveVec({
|
|
2901
|
+
elements: params.weights.map((weight) => tx.pure.u64(weight)),
|
|
2902
|
+
type: "u64"
|
|
2903
|
+
});
|
|
2904
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(params.lockId), pools, weights, tx.object(CLOCK_ADDRESS)];
|
|
2905
|
+
tx.moveCall({
|
|
2906
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
2907
|
+
typeArguments,
|
|
2908
|
+
arguments: args
|
|
2909
|
+
});
|
|
2910
|
+
return tx;
|
|
2911
|
+
}
|
|
2912
|
+
static buildClaimVotingRewardsTransaction(sdk, params) {
|
|
2913
|
+
const tx = new Transaction();
|
|
2914
|
+
tx.setSender(sdk.senderAddress);
|
|
2915
|
+
const { integrate } = sdk.sdkOptions;
|
|
2916
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2917
|
+
const typeArguments = [magma_token, params.coinAType, params.coinBType];
|
|
2918
|
+
const functionName = "claim_voting_fee_rewards_single";
|
|
2919
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(params.locks), tx.object(CLOCK_ADDRESS)];
|
|
2920
|
+
tx.moveCall({
|
|
2921
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
2922
|
+
typeArguments,
|
|
2923
|
+
arguments: args
|
|
2924
|
+
});
|
|
2925
|
+
return tx;
|
|
2926
|
+
}
|
|
2927
|
+
static buildClaimVotingRewardsPoolsTransaction(sdk, params) {
|
|
2928
|
+
const tx = new Transaction();
|
|
2929
|
+
tx.setSender(sdk.senderAddress);
|
|
2930
|
+
const { integrate, distribution } = sdk.sdkOptions;
|
|
2931
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2932
|
+
const typeArguments = [magma_token, params.coinAType, params.coinBType];
|
|
2933
|
+
const functionName = "claim_voting_fee_rewards";
|
|
2934
|
+
const locks = tx.makeMoveVec({
|
|
2935
|
+
elements: params.locks.map((lock) => tx.object(lock)),
|
|
2936
|
+
type: `${distribution.package_id}::voting_escrow::Lock`
|
|
2937
|
+
});
|
|
2938
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), locks, tx.object(CLOCK_ADDRESS)];
|
|
2939
|
+
tx.moveCall({
|
|
2940
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
2941
|
+
typeArguments,
|
|
2942
|
+
arguments: args
|
|
2943
|
+
});
|
|
2944
|
+
return tx;
|
|
2945
|
+
}
|
|
2946
|
+
static buildClaimAndLockRebases(sdk, params) {
|
|
2947
|
+
const tx = new Transaction();
|
|
2948
|
+
tx.setSender(sdk.senderAddress);
|
|
2949
|
+
tx.setGasBudget(5e8);
|
|
2950
|
+
const { integrate } = sdk.sdkOptions;
|
|
2951
|
+
const { voting_escrow_id, magma_token, reward_distributor_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2952
|
+
const typeArguments = [magma_token];
|
|
2953
|
+
const functionName = "claim_and_lock";
|
|
2954
|
+
const args = [tx.object(reward_distributor_id), tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
2955
|
+
tx.moveCall({
|
|
2956
|
+
target: `${integrate.published_at}::${RewardDistributor}::${functionName}`,
|
|
2957
|
+
typeArguments,
|
|
2958
|
+
arguments: args
|
|
2959
|
+
});
|
|
2960
|
+
return tx;
|
|
2961
|
+
}
|
|
2962
|
+
static buildPoke(sdk, params) {
|
|
2963
|
+
const tx = new Transaction();
|
|
2964
|
+
tx.setSender(sdk.senderAddress);
|
|
2965
|
+
const { integrate } = sdk.sdkOptions;
|
|
2966
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2967
|
+
const typeArguments = [magma_token];
|
|
2968
|
+
const functionName = "poke";
|
|
2969
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
2970
|
+
tx.moveCall({
|
|
2971
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
2972
|
+
typeArguments,
|
|
2973
|
+
arguments: args
|
|
2974
|
+
});
|
|
2975
|
+
return tx;
|
|
2976
|
+
}
|
|
2977
|
+
static buildClaimVotingBribe(sdk, locks, incentive_tokens) {
|
|
2978
|
+
const tx = new Transaction();
|
|
2979
|
+
tx.setGasBudget(5e8);
|
|
2980
|
+
tx.setSender(sdk.senderAddress);
|
|
2981
|
+
const { integrate, distribution } = sdk.sdkOptions;
|
|
2982
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2983
|
+
const typeArguments = [magma_token, ...incentive_tokens];
|
|
2984
|
+
let targetFunc = `${integrate.published_at}::${Voter}::claim_voting_bribes_${incentive_tokens.length}`;
|
|
2985
|
+
if (incentive_tokens.length === 1) {
|
|
2986
|
+
targetFunc = `${integrate.published_at}::${Voter}::claim_voting_bribes`;
|
|
2987
|
+
}
|
|
2988
|
+
const locksParams = tx.makeMoveVec({
|
|
2989
|
+
elements: locks.map((lock) => tx.object(lock)),
|
|
2990
|
+
type: `${distribution.package_id}::voting_escrow::Lock`
|
|
2991
|
+
});
|
|
2992
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), locksParams, tx.object(CLOCK_ADDRESS)];
|
|
2993
|
+
tx.moveCall({
|
|
2994
|
+
target: targetFunc,
|
|
2995
|
+
typeArguments,
|
|
2996
|
+
arguments: args
|
|
2997
|
+
});
|
|
2998
|
+
return tx;
|
|
2999
|
+
}
|
|
2757
3000
|
/**
|
|
2758
3001
|
* build swap transaction
|
|
2759
3002
|
* @param params
|
|
@@ -6544,9 +6787,16 @@ var SwapModule = class {
|
|
|
6544
6787
|
*/
|
|
6545
6788
|
async preswap(params) {
|
|
6546
6789
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
6790
|
+
const { global_config_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
6547
6791
|
const tx = new Transaction8();
|
|
6548
6792
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
6549
|
-
const args = [
|
|
6793
|
+
const args = [
|
|
6794
|
+
tx.object(global_config_id),
|
|
6795
|
+
tx.object(params.pool.poolAddress),
|
|
6796
|
+
tx.pure.bool(params.a2b),
|
|
6797
|
+
tx.pure.bool(params.byAmountIn),
|
|
6798
|
+
tx.pure.u64(params.amount)
|
|
6799
|
+
];
|
|
6550
6800
|
tx.moveCall({
|
|
6551
6801
|
target: `${integrate.published_at}::${ClmmFetcherModule}::calculate_swap_result`,
|
|
6552
6802
|
arguments: args,
|
|
@@ -6704,9 +6954,433 @@ var SwapModule = class {
|
|
|
6704
6954
|
}
|
|
6705
6955
|
};
|
|
6706
6956
|
|
|
6957
|
+
// src/modules/lockModule.ts
|
|
6958
|
+
import { Transaction as Transaction9 } from "@mysten/sui/transactions";
|
|
6959
|
+
var LockModule = class {
|
|
6960
|
+
_sdk;
|
|
6961
|
+
constructor(sdk) {
|
|
6962
|
+
this._sdk = sdk;
|
|
6963
|
+
}
|
|
6964
|
+
get sdk() {
|
|
6965
|
+
return this._sdk;
|
|
6966
|
+
}
|
|
6967
|
+
async createLockTransactionPayload(params) {
|
|
6968
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
6969
|
+
throw Error("this config sdk senderAddress is empty");
|
|
6970
|
+
}
|
|
6971
|
+
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
6972
|
+
return TransactionUtil.buildCreateLockTransaction(this.sdk, params, allCoinAsset);
|
|
6973
|
+
}
|
|
6974
|
+
async increaseLockAmountTransactionPayload(params) {
|
|
6975
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
6976
|
+
throw Error("this config sdk senderAddress is empty");
|
|
6977
|
+
}
|
|
6978
|
+
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
6979
|
+
return TransactionUtil.buildIncreaseLockAmountTransaction(this.sdk, params, allCoinAsset);
|
|
6980
|
+
}
|
|
6981
|
+
async mergeLockTransactionPayload(params) {
|
|
6982
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
6983
|
+
throw Error("this config sdk senderAddress is empty");
|
|
6984
|
+
}
|
|
6985
|
+
return TransactionUtil.buildMergeLockTransaction(this.sdk, params);
|
|
6986
|
+
}
|
|
6987
|
+
// public fun transfer<T>(lock: Lock, ve: &mut VotingEscrow<T>, to: address, clock: &Clock, ctx: &mut TxContext) {
|
|
6988
|
+
async transferLockTransactionPayload(params) {
|
|
6989
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
6990
|
+
throw Error("this config sdk senderAddress is empty");
|
|
6991
|
+
}
|
|
6992
|
+
return TransactionUtil.buildTransferLockTransaction(this.sdk, params);
|
|
6993
|
+
}
|
|
6994
|
+
async increaseUnlockTimePayload(params) {
|
|
6995
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
6996
|
+
throw Error("this config sdk senderAddress is empty");
|
|
6997
|
+
}
|
|
6998
|
+
return TransactionUtil.buildIncreaseUnlockTimeTransaction(this.sdk, params);
|
|
6999
|
+
}
|
|
7000
|
+
// public fun lock_permanent<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
7001
|
+
async lockPermanentPayload(params) {
|
|
7002
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7003
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7004
|
+
}
|
|
7005
|
+
return TransactionUtil.buildLockPermanentTransaction(this.sdk, params);
|
|
7006
|
+
}
|
|
7007
|
+
async unlockPermanentPayload(params) {
|
|
7008
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7009
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7010
|
+
}
|
|
7011
|
+
return TransactionUtil.buildUnlockPermanentTransaction(this.sdk, params);
|
|
7012
|
+
}
|
|
7013
|
+
async votePayload(params) {
|
|
7014
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7015
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7016
|
+
}
|
|
7017
|
+
return TransactionUtil.buildVoteTransaction(this.sdk, params);
|
|
7018
|
+
}
|
|
7019
|
+
// public fun claim_fees<T, B>(self: &mut Voter<T>, ve: &mut VotingEscrow<T>, mut locks: vector<Lock>, clock: &Clock, ctx: &mut TxContext) {
|
|
7020
|
+
async claimVotingRewardsPayload(params) {
|
|
7021
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7022
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7023
|
+
}
|
|
7024
|
+
return TransactionUtil.buildClaimVotingRewardsTransaction(this.sdk, params);
|
|
7025
|
+
}
|
|
7026
|
+
// public fun claim_fees<T, B>(self: &mut Voter<T>, ve: &mut VotingEscrow<T>, mut locks: vector<Lock>, clock: &Clock, ctx: &mut TxContext) {
|
|
7027
|
+
async claimVotingRewardsPoolsPayload(params) {
|
|
7028
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7029
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7030
|
+
}
|
|
7031
|
+
return TransactionUtil.buildClaimVotingRewardsPoolsTransaction(this.sdk, params);
|
|
7032
|
+
}
|
|
7033
|
+
async claimAndLockRebasesPayload(params) {
|
|
7034
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7035
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7036
|
+
}
|
|
7037
|
+
return TransactionUtil.buildClaimAndLockRebases(this.sdk, params);
|
|
7038
|
+
}
|
|
7039
|
+
async pokePayload(params) {
|
|
7040
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7041
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7042
|
+
}
|
|
7043
|
+
return TransactionUtil.buildPoke(this.sdk, params);
|
|
7044
|
+
}
|
|
7045
|
+
async claimVotingBribe(locks, incentive_tokens) {
|
|
7046
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7047
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7048
|
+
}
|
|
7049
|
+
return TransactionUtil.buildClaimVotingBribe(this.sdk, locks, incentive_tokens);
|
|
7050
|
+
}
|
|
7051
|
+
async locksOfUser(user) {
|
|
7052
|
+
const locksInfo = { owner: user, lockInfo: [] };
|
|
7053
|
+
const { distribution } = this._sdk.sdkOptions;
|
|
7054
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7055
|
+
const ownerRes = await this._sdk.fullClient.getOwnedObjectsByPage(user, {
|
|
7056
|
+
options: { showType: true, showContent: true, showDisplay: true, showOwner: true },
|
|
7057
|
+
filter: {
|
|
7058
|
+
MatchAll: [{ Package: distribution.package_id }, { StructType: `${distribution.package_id}::voting_escrow::Lock` }]
|
|
7059
|
+
}
|
|
7060
|
+
});
|
|
7061
|
+
for (const item of ownerRes.data) {
|
|
7062
|
+
const { fields } = item.data.content;
|
|
7063
|
+
const aLockSummary = await this.aLockSummary(fields.id.id);
|
|
7064
|
+
const poolIncentiveTokens = await this.getVotingBribeRewardTokens(fields.id.id);
|
|
7065
|
+
const incentiveTokens = [];
|
|
7066
|
+
poolIncentiveTokens.forEach((value, key) => {
|
|
7067
|
+
incentiveTokens.push(...value);
|
|
7068
|
+
});
|
|
7069
|
+
const poolIncentiveRewards = await this.getPoolIncentiveRewrads(incentiveTokens, fields.id.id);
|
|
7070
|
+
const votingRewards = /* @__PURE__ */ new Map();
|
|
7071
|
+
poolIncentiveRewards.forEach((value, coin) => {
|
|
7072
|
+
value.forEach((amount, pool) => {
|
|
7073
|
+
if (!votingRewards.has(pool)) {
|
|
7074
|
+
votingRewards.set(pool, []);
|
|
7075
|
+
}
|
|
7076
|
+
votingRewards.get(pool)?.push({
|
|
7077
|
+
kind: "incentiveCoin" /* Incentive */,
|
|
7078
|
+
token_addr: coin,
|
|
7079
|
+
amount: amount.toString()
|
|
7080
|
+
});
|
|
7081
|
+
});
|
|
7082
|
+
});
|
|
7083
|
+
const lockInfo = {
|
|
7084
|
+
lock_id: fields.id.id,
|
|
7085
|
+
amount: fields.amount,
|
|
7086
|
+
start: fields.start,
|
|
7087
|
+
end: fields.end,
|
|
7088
|
+
permanent: fields.permanent,
|
|
7089
|
+
rebase_amount: {
|
|
7090
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7091
|
+
token_addr: magma_token,
|
|
7092
|
+
amount: aLockSummary.reward_distributor_claimable
|
|
7093
|
+
},
|
|
7094
|
+
voting_power: aLockSummary.voting_power,
|
|
7095
|
+
// pool => incentive => amount
|
|
7096
|
+
voting_rewards: votingRewards
|
|
7097
|
+
};
|
|
7098
|
+
locksInfo.lockInfo.push(lockInfo);
|
|
7099
|
+
}
|
|
7100
|
+
return locksInfo;
|
|
7101
|
+
}
|
|
7102
|
+
async aLockSummary(lock_id) {
|
|
7103
|
+
const tx = new Transaction9();
|
|
7104
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7105
|
+
const { voting_escrow_id, magma_token, voter_id, reward_distributor_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7106
|
+
const typeArguments = [magma_token];
|
|
7107
|
+
const args = [
|
|
7108
|
+
tx.object(voter_id),
|
|
7109
|
+
tx.object(voting_escrow_id),
|
|
7110
|
+
tx.object(reward_distributor_id),
|
|
7111
|
+
tx.object(lock_id),
|
|
7112
|
+
tx.object(CLOCK_ADDRESS)
|
|
7113
|
+
];
|
|
7114
|
+
tx.moveCall({
|
|
7115
|
+
target: `${integrate.published_at}::${VotingEscrow}::lock_summary`,
|
|
7116
|
+
arguments: args,
|
|
7117
|
+
typeArguments
|
|
7118
|
+
});
|
|
7119
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7120
|
+
throw Error("this config simulationAccount is not set right");
|
|
7121
|
+
}
|
|
7122
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7123
|
+
transactionBlock: tx,
|
|
7124
|
+
sender: simulationAccount.address
|
|
7125
|
+
});
|
|
7126
|
+
if (simulateRes.error != null) {
|
|
7127
|
+
throw new Error(`lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7128
|
+
}
|
|
7129
|
+
let res = {
|
|
7130
|
+
// reward_distributor_claimable + incentive magma
|
|
7131
|
+
fee_incentive_total: "",
|
|
7132
|
+
// How much Magma can be claimed
|
|
7133
|
+
reward_distributor_claimable: "",
|
|
7134
|
+
voting_power: ""
|
|
7135
|
+
};
|
|
7136
|
+
simulateRes.events?.forEach((item) => {
|
|
7137
|
+
if (extractStructTagFromType(item.type).name === `LockSummary`) {
|
|
7138
|
+
res = {
|
|
7139
|
+
fee_incentive_total: item.parsedJson.fee_incentive_total,
|
|
7140
|
+
reward_distributor_claimable: item.parsedJson.reward_distributor_claimable,
|
|
7141
|
+
voting_power: item.parsedJson.voting_power
|
|
7142
|
+
};
|
|
7143
|
+
}
|
|
7144
|
+
});
|
|
7145
|
+
return res;
|
|
7146
|
+
}
|
|
7147
|
+
async allLockSummary() {
|
|
7148
|
+
const tx = new Transaction9();
|
|
7149
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7150
|
+
const { voting_escrow_id, magma_token, voter_id, minter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7151
|
+
const typeArguments = [magma_token];
|
|
7152
|
+
const args = [tx.object(minter_id), tx.object(voter_id), tx.object(voting_escrow_id), tx.object(CLOCK_ADDRESS)];
|
|
7153
|
+
tx.moveCall({
|
|
7154
|
+
target: `${integrate.published_at}::${VotingEscrow}::summary`,
|
|
7155
|
+
arguments: args,
|
|
7156
|
+
typeArguments
|
|
7157
|
+
});
|
|
7158
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7159
|
+
throw Error("this config simulationAccount is not set right");
|
|
7160
|
+
}
|
|
7161
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7162
|
+
transactionBlock: tx,
|
|
7163
|
+
sender: simulationAccount.address
|
|
7164
|
+
});
|
|
7165
|
+
if (simulateRes.error != null) {
|
|
7166
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7167
|
+
}
|
|
7168
|
+
let summary = {
|
|
7169
|
+
current_epoch_end: 0,
|
|
7170
|
+
current_epoch_vote_end: 0,
|
|
7171
|
+
rebase_apr: 0,
|
|
7172
|
+
team_emission_rate: 0,
|
|
7173
|
+
total_locked: 0,
|
|
7174
|
+
total_voted_power: 0,
|
|
7175
|
+
total_voting_power: 0
|
|
7176
|
+
};
|
|
7177
|
+
simulateRes.events?.forEach((item) => {
|
|
7178
|
+
if (extractStructTagFromType(item.type).name === `Summary`) {
|
|
7179
|
+
summary = {
|
|
7180
|
+
current_epoch_end: Number(item.parsedJson.current_epoch_end),
|
|
7181
|
+
current_epoch_vote_end: Number(item.parsedJson.current_epoch_vote_end),
|
|
7182
|
+
rebase_apr: Number(item.parsedJson.rebase_apr),
|
|
7183
|
+
team_emission_rate: Number(item.parsedJson.team_emission_rate),
|
|
7184
|
+
total_locked: Number(item.parsedJson.total_locked),
|
|
7185
|
+
total_voted_power: Number(item.parsedJson.total_voted_power),
|
|
7186
|
+
total_voting_power: Number(item.parsedJson.total_voting_power)
|
|
7187
|
+
};
|
|
7188
|
+
}
|
|
7189
|
+
});
|
|
7190
|
+
return summary;
|
|
7191
|
+
}
|
|
7192
|
+
async poolWeights(pools) {
|
|
7193
|
+
const tx = new Transaction9();
|
|
7194
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7195
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7196
|
+
const typeArguments = [magma_token];
|
|
7197
|
+
const poolsParams = tx.pure.vector("id", pools);
|
|
7198
|
+
const args = [tx.object(voter_id), poolsParams];
|
|
7199
|
+
tx.moveCall({
|
|
7200
|
+
target: `${integrate.published_at}::${Voter}::pools_tally`,
|
|
7201
|
+
arguments: args,
|
|
7202
|
+
typeArguments
|
|
7203
|
+
});
|
|
7204
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7205
|
+
throw Error("this config simulationAccount is not set right");
|
|
7206
|
+
}
|
|
7207
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7208
|
+
transactionBlock: tx,
|
|
7209
|
+
sender: simulationAccount.address
|
|
7210
|
+
});
|
|
7211
|
+
if (simulateRes.error != null) {
|
|
7212
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7213
|
+
}
|
|
7214
|
+
const poolWeights = [];
|
|
7215
|
+
simulateRes.events?.forEach((item) => {
|
|
7216
|
+
if (extractStructTagFromType(item.type).name === `PoolsTally`) {
|
|
7217
|
+
item.parsedJson.list.forEach((item2) => {
|
|
7218
|
+
poolWeights.push({
|
|
7219
|
+
poolId: item2.id,
|
|
7220
|
+
weight: item2.weight
|
|
7221
|
+
});
|
|
7222
|
+
});
|
|
7223
|
+
}
|
|
7224
|
+
});
|
|
7225
|
+
return poolWeights;
|
|
7226
|
+
}
|
|
7227
|
+
async getVotingFeeRewardTokens(lock_id) {
|
|
7228
|
+
const tx = new Transaction9();
|
|
7229
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7230
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7231
|
+
const typeArguments = [magma_token];
|
|
7232
|
+
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
7233
|
+
tx.moveCall({
|
|
7234
|
+
target: `${integrate.published_at}::${Voter}::get_voting_fee_reward_tokens`,
|
|
7235
|
+
arguments: args,
|
|
7236
|
+
typeArguments
|
|
7237
|
+
});
|
|
7238
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7239
|
+
throw Error("this config simulationAccount is not set right");
|
|
7240
|
+
}
|
|
7241
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7242
|
+
transactionBlock: tx,
|
|
7243
|
+
sender: simulationAccount.address
|
|
7244
|
+
});
|
|
7245
|
+
if (simulateRes.error != null) {
|
|
7246
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7247
|
+
}
|
|
7248
|
+
const poolRewardTokens = /* @__PURE__ */ new Map();
|
|
7249
|
+
simulateRes.events?.forEach((item) => {
|
|
7250
|
+
if (extractStructTagFromType(item.type).name === `EventRewardTokens`) {
|
|
7251
|
+
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7252
|
+
if (!poolRewardTokens.has(poolTokens.key)) {
|
|
7253
|
+
poolRewardTokens.set(poolTokens.key, []);
|
|
7254
|
+
}
|
|
7255
|
+
poolTokens.value.forEach((token) => {
|
|
7256
|
+
poolRewardTokens.get(poolTokens.key)?.push(token.name);
|
|
7257
|
+
});
|
|
7258
|
+
});
|
|
7259
|
+
}
|
|
7260
|
+
});
|
|
7261
|
+
return poolRewardTokens;
|
|
7262
|
+
}
|
|
7263
|
+
async getVotingBribeRewardTokens(lock_id) {
|
|
7264
|
+
const tx = new Transaction9();
|
|
7265
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7266
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7267
|
+
const typeArguments = [magma_token];
|
|
7268
|
+
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
7269
|
+
tx.moveCall({
|
|
7270
|
+
target: `${integrate.published_at}::${Voter}::get_voting_bribe_reward_tokens`,
|
|
7271
|
+
arguments: args,
|
|
7272
|
+
typeArguments
|
|
7273
|
+
});
|
|
7274
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7275
|
+
throw Error("this config simulationAccount is not set right");
|
|
7276
|
+
}
|
|
7277
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7278
|
+
transactionBlock: tx,
|
|
7279
|
+
sender: simulationAccount.address
|
|
7280
|
+
});
|
|
7281
|
+
if (simulateRes.error != null) {
|
|
7282
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7283
|
+
}
|
|
7284
|
+
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
7285
|
+
simulateRes.events?.forEach((item) => {
|
|
7286
|
+
if (extractStructTagFromType(item.type).name === `EventRewardTokens`) {
|
|
7287
|
+
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7288
|
+
if (!poolBirbeRewardTokens.has(poolTokens.key)) {
|
|
7289
|
+
poolBirbeRewardTokens.set(poolTokens.key, []);
|
|
7290
|
+
}
|
|
7291
|
+
poolTokens.value.forEach((token) => {
|
|
7292
|
+
poolBirbeRewardTokens.get(poolTokens.key)?.push(token.name);
|
|
7293
|
+
});
|
|
7294
|
+
});
|
|
7295
|
+
}
|
|
7296
|
+
});
|
|
7297
|
+
return poolBirbeRewardTokens;
|
|
7298
|
+
}
|
|
7299
|
+
// tokenId => pool => incentive_tokens
|
|
7300
|
+
async getPoolIncentiveRewrads(incentive_tokens, locksId) {
|
|
7301
|
+
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
7302
|
+
if (incentive_tokens.length === 0) {
|
|
7303
|
+
return poolBirbeRewardTokens;
|
|
7304
|
+
}
|
|
7305
|
+
const tx = new Transaction9();
|
|
7306
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7307
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7308
|
+
const typeArguments = [magma_token, ...incentive_tokens];
|
|
7309
|
+
const args = [tx.object(voter_id), tx.object(locksId), tx.object(CLOCK_ADDRESS)];
|
|
7310
|
+
let targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_bribes_${incentive_tokens.length}`;
|
|
7311
|
+
if (incentive_tokens.length === 1) {
|
|
7312
|
+
targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_bribes`;
|
|
7313
|
+
}
|
|
7314
|
+
tx.moveCall({
|
|
7315
|
+
target: targetFunc,
|
|
7316
|
+
arguments: args,
|
|
7317
|
+
typeArguments
|
|
7318
|
+
});
|
|
7319
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7320
|
+
throw Error("this config simulationAccount is not set right");
|
|
7321
|
+
}
|
|
7322
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7323
|
+
transactionBlock: tx,
|
|
7324
|
+
sender: simulationAccount.address
|
|
7325
|
+
});
|
|
7326
|
+
if (simulateRes.error != null) {
|
|
7327
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7328
|
+
}
|
|
7329
|
+
simulateRes.events?.forEach((item) => {
|
|
7330
|
+
if (extractStructTagFromType(item.type).name === `ClaimableVotingBribes`) {
|
|
7331
|
+
item.parsedJson.data.contents.forEach((rewardTokens) => {
|
|
7332
|
+
if (!poolBirbeRewardTokens.has(rewardTokens.key.name)) {
|
|
7333
|
+
poolBirbeRewardTokens.set(rewardTokens.key.name, /* @__PURE__ */ new Map());
|
|
7334
|
+
}
|
|
7335
|
+
rewardTokens.value.contents.forEach((token) => {
|
|
7336
|
+
poolBirbeRewardTokens.get(rewardTokens.key.name)?.set(token.key, token.value);
|
|
7337
|
+
});
|
|
7338
|
+
});
|
|
7339
|
+
}
|
|
7340
|
+
});
|
|
7341
|
+
return poolBirbeRewardTokens;
|
|
7342
|
+
}
|
|
7343
|
+
async getPoolBribeRewardTokens(pool_id) {
|
|
7344
|
+
const tx = new Transaction9();
|
|
7345
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7346
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7347
|
+
const typeArguments = [magma_token];
|
|
7348
|
+
const args = [tx.object(voter_id), tx.object(pool_id)];
|
|
7349
|
+
tx.moveCall({
|
|
7350
|
+
target: `${integrate.published_at}::${Voter}::get_voting_bribe_reward_tokens_by_pool`,
|
|
7351
|
+
arguments: args,
|
|
7352
|
+
typeArguments
|
|
7353
|
+
});
|
|
7354
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7355
|
+
throw Error("this config simulationAccount is not set right");
|
|
7356
|
+
}
|
|
7357
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7358
|
+
transactionBlock: tx,
|
|
7359
|
+
sender: simulationAccount.address
|
|
7360
|
+
});
|
|
7361
|
+
if (simulateRes.error != null) {
|
|
7362
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7363
|
+
}
|
|
7364
|
+
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
7365
|
+
simulateRes.events?.forEach((item) => {
|
|
7366
|
+
if (extractStructTagFromType(item.type).name === `EventRewardTokens`) {
|
|
7367
|
+
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7368
|
+
if (!poolBirbeRewardTokens.has(poolTokens.key)) {
|
|
7369
|
+
poolBirbeRewardTokens.set(poolTokens.key, []);
|
|
7370
|
+
}
|
|
7371
|
+
poolTokens.value.forEach((token) => {
|
|
7372
|
+
poolBirbeRewardTokens.get(poolTokens.key)?.push(token.name);
|
|
7373
|
+
});
|
|
7374
|
+
});
|
|
7375
|
+
}
|
|
7376
|
+
});
|
|
7377
|
+
return poolBirbeRewardTokens;
|
|
7378
|
+
}
|
|
7379
|
+
};
|
|
7380
|
+
|
|
6707
7381
|
// src/modules/tokenModule.ts
|
|
6708
7382
|
import { Base64 } from "js-base64";
|
|
6709
|
-
import { Transaction as
|
|
7383
|
+
import { Transaction as Transaction10 } from "@mysten/sui/transactions";
|
|
6710
7384
|
import { normalizeSuiObjectId as normalizeSuiObjectId2 } from "@mysten/sui/utils";
|
|
6711
7385
|
var TokenModule = class {
|
|
6712
7386
|
_sdk;
|
|
@@ -6842,7 +7516,7 @@ var TokenModule = class {
|
|
|
6842
7516
|
}
|
|
6843
7517
|
const tokenConfig = getPackagerConfigs(token);
|
|
6844
7518
|
while (true) {
|
|
6845
|
-
const tx = new
|
|
7519
|
+
const tx = new Transaction10();
|
|
6846
7520
|
tx.moveCall({
|
|
6847
7521
|
target: `${token.published_at}::coin_list::${isOwnerRequest ? "fetch_full_list_with_limit" : "fetch_all_registered_coin_info_with_limit"}`,
|
|
6848
7522
|
arguments: isOwnerRequest ? [tx.pure.address(tokenConfig.coin_registry_id), tx.pure.address(listOwnerAddr), tx.pure.u64(index), tx.pure.u64(limit)] : [tx.pure.address(tokenConfig.coin_registry_id), tx.pure.u64(index), tx.pure.u64(limit)]
|
|
@@ -6885,7 +7559,7 @@ var TokenModule = class {
|
|
|
6885
7559
|
}
|
|
6886
7560
|
const tokenConfig = getPackagerConfigs(token);
|
|
6887
7561
|
while (true) {
|
|
6888
|
-
const tx = new
|
|
7562
|
+
const tx = new Transaction10();
|
|
6889
7563
|
tx.moveCall({
|
|
6890
7564
|
target: `${token.published_at}::lp_list::${isOwnerRequest ? "fetch_full_list_with_limit" : "fetch_all_registered_coin_info_with_limit"}`,
|
|
6891
7565
|
arguments: isOwnerRequest ? [tx.pure.address(tokenConfig.pool_registry_id), tx.pure.address(listOwnerAddr), tx.pure.u64(index), tx.pure.u64(limit)] : [tx.pure.address(tokenConfig.pool_registry_id), tx.pure.u64(index), tx.pure.u64(limit)]
|
|
@@ -7771,7 +8445,12 @@ var ConfigModule = class {
|
|
|
7771
8445
|
global_config_id: "",
|
|
7772
8446
|
coin_list_handle: "",
|
|
7773
8447
|
launchpad_pools_handle: "",
|
|
7774
|
-
clmm_pools_handle: ""
|
|
8448
|
+
clmm_pools_handle: "",
|
|
8449
|
+
voter_id: "",
|
|
8450
|
+
minter_id: "",
|
|
8451
|
+
reward_distributor_id: "",
|
|
8452
|
+
magma_token: "",
|
|
8453
|
+
voting_escrow_id: ""
|
|
7775
8454
|
};
|
|
7776
8455
|
if (objects.data.length > 0) {
|
|
7777
8456
|
for (const item of objects.data) {
|
|
@@ -8063,6 +8742,10 @@ var MagmaClmmSDK = class {
|
|
|
8063
8742
|
* Provide interact with a pool swap router interface.
|
|
8064
8743
|
*/
|
|
8065
8744
|
_swap;
|
|
8745
|
+
/**
|
|
8746
|
+
* Provide interact with a lock interface.
|
|
8747
|
+
*/
|
|
8748
|
+
_lock;
|
|
8066
8749
|
/**
|
|
8067
8750
|
* Provide interact with a position rewarder interface.
|
|
8068
8751
|
*/
|
|
@@ -8098,6 +8781,7 @@ var MagmaClmmSDK = class {
|
|
|
8098
8781
|
url: options.fullRpcUrl
|
|
8099
8782
|
});
|
|
8100
8783
|
this._swap = new SwapModule(this);
|
|
8784
|
+
this._lock = new LockModule(this);
|
|
8101
8785
|
this._pool = new PoolModule(this);
|
|
8102
8786
|
this._position = new PositionModule(this);
|
|
8103
8787
|
this._rewarder = new RewarderModule(this);
|
|
@@ -8128,6 +8812,10 @@ var MagmaClmmSDK = class {
|
|
|
8128
8812
|
get Swap() {
|
|
8129
8813
|
return this._swap;
|
|
8130
8814
|
}
|
|
8815
|
+
/* */
|
|
8816
|
+
get Lock() {
|
|
8817
|
+
return this._lock;
|
|
8818
|
+
}
|
|
8131
8819
|
/**
|
|
8132
8820
|
* Getter for the fullClient property.
|
|
8133
8821
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -8301,7 +8989,7 @@ var main_default = MagmaClmmSDK;
|
|
|
8301
8989
|
var SDKConfig = {
|
|
8302
8990
|
clmmConfig: {
|
|
8303
8991
|
pools_id: "0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0",
|
|
8304
|
-
global_config_id: "
|
|
8992
|
+
global_config_id: "0x4f32c00706e7bdbce532acdcfc0afd91b14defd5ffc9e2723a0ce7ed84f5d380",
|
|
8305
8993
|
global_vault_id: "0xce7bceef26d3ad1f6d9b6f13a953f053e6ed3ca77907516481ce99ae8e588f2b",
|
|
8306
8994
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
8307
8995
|
},
|
|
@@ -8310,10 +8998,15 @@ var SDKConfig = {
|
|
|
8310
8998
|
launchpad_pools_id: "0x1098fac992eab3a0ab7acf15bb654fc1cf29b5a6142c4ef1058e6c408dd15115",
|
|
8311
8999
|
clmm_pools_id: "0x15b6a27dd9ae03eb455aba03b39e29aad74abd3757b8e18c0755651b2ae5b71e",
|
|
8312
9000
|
admin_cap_id: "0x39d78781750e193ce35c45ff32c6c0c3f2941fa3ddaf8595c90c555589ddb113",
|
|
8313
|
-
global_config_id: "0x0408fa4e4a4c03cc0de8f23d0c2bbfe8913d178713c9a271ed4080973fe42d8f",
|
|
8314
9001
|
coin_list_handle: "0x49136005e90e28c4695419ed4194cc240603f1ea8eb84e62275eaff088a71063",
|
|
8315
9002
|
launchpad_pools_handle: "0x5e194a8efcf653830daf85a85b52e3ae8f65dc39481d54b2382acda25068375c",
|
|
8316
|
-
clmm_pools_handle: "0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb"
|
|
9003
|
+
clmm_pools_handle: "0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb",
|
|
9004
|
+
global_config_id: "0x4f32c00706e7bdbce532acdcfc0afd91b14defd5ffc9e2723a0ce7ed84f5d380",
|
|
9005
|
+
voter_id: "0x2e2fae39d85e991e1adad756f6723bb1aebc33140b8b16897a41171640389f88",
|
|
9006
|
+
voting_escrow_id: "0x8c300ccc0cb221feb76d0ed0820ff0873477ab1ada266129d594d539c5cd2f11",
|
|
9007
|
+
reward_distributor_id: "0x289c10f62e998a2ee58a982262732af7e329b7b689f4c81b0e16de7c6589669c",
|
|
9008
|
+
magma_token: "0x4201f44d506036666a1d9166f7a3450a80c73c551a582684cf39f2dbb3d56461::magma_token::MAGMA_TOKEN",
|
|
9009
|
+
minter_id: "0xfaf1c9b59192a3f910f28d46325dbfb3ffcc92df43d11663f3820fec8faf540b"
|
|
8317
9010
|
}
|
|
8318
9011
|
};
|
|
8319
9012
|
var clmmMainnet = {
|
|
@@ -8327,13 +9020,17 @@ var clmmMainnet = {
|
|
|
8327
9020
|
config: SDKConfig.magmaConfig
|
|
8328
9021
|
},
|
|
8329
9022
|
clmm_pool: {
|
|
8330
|
-
package_id: "
|
|
8331
|
-
published_at: "
|
|
9023
|
+
package_id: "0x0a9b94307de472ebe7c1a24ea862eb013d954c9c003a0484e045861d05b31435",
|
|
9024
|
+
published_at: "0x0a9b94307de472ebe7c1a24ea862eb013d954c9c003a0484e045861d05b31435",
|
|
8332
9025
|
config: SDKConfig.clmmConfig
|
|
8333
9026
|
},
|
|
9027
|
+
distribution: {
|
|
9028
|
+
package_id: "0x4201f44d506036666a1d9166f7a3450a80c73c551a582684cf39f2dbb3d56461",
|
|
9029
|
+
published_at: "0x5c008a2e0aee9a034b19e32bbc119cf6e7b1a0ce1316b2199cde1704d9f64f3c"
|
|
9030
|
+
},
|
|
8334
9031
|
integrate: {
|
|
8335
|
-
package_id: "
|
|
8336
|
-
published_at: "
|
|
9032
|
+
package_id: "0x01268a2afbaf91538f0b9041269fe2780273eb83b642abd4fcacad7b660a3711",
|
|
9033
|
+
published_at: "0x01268a2afbaf91538f0b9041269fe2780273eb83b642abd4fcacad7b660a3711"
|
|
8337
9034
|
},
|
|
8338
9035
|
deepbook: {
|
|
8339
9036
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
@@ -8370,34 +9067,43 @@ var SDKConfig2 = {
|
|
|
8370
9067
|
launchpad_pools_id: "0xdc3a7bd66a6dcff73c77c866e87d73826e446e9171f34e1c1b656377314f94da",
|
|
8371
9068
|
clmm_pools_id: "0x26c85500f5dd2983bf35123918a144de24e18936d0b234ef2b49fbb2d3d6307d",
|
|
8372
9069
|
admin_cap_id: "0x1a496f6c67668eb2c27c99e07e1d61754715c1acf86dac45020c886ac601edb8",
|
|
8373
|
-
global_config_id: "0xe1f3db327e75f7ec30585fa52241edf66f7e359ef550b533f89aa1528dd1be52",
|
|
8374
9070
|
coin_list_handle: "0x3204350fc603609c91675e07b8f9ac0999b9607d83845086321fca7f469de235",
|
|
8375
9071
|
launchpad_pools_handle: "0xae67ff87c34aceea4d28107f9c6c62e297a111e9f8e70b9abbc2f4c9f5ec20fd",
|
|
8376
|
-
clmm_pools_handle: "0xd28736923703342b4752f5ed8c2f2a5c0cb2336c30e1fed42b387234ce8408ec"
|
|
9072
|
+
clmm_pools_handle: "0xd28736923703342b4752f5ed8c2f2a5c0cb2336c30e1fed42b387234ce8408ec",
|
|
9073
|
+
global_config_id: "0xbbe54f3c2bd06c5ab7f93950025bff6710c9a83836d7145636fea383b315774d",
|
|
9074
|
+
voter_id: "0x59571991a5c7041c4376d980061af5c7a6d8345006d6b5167bd1f00fc17b8ddb",
|
|
9075
|
+
voting_escrow_id: "0x9081c8044719135da4ff2d52907fcd40c19e2a40750cbba4c1d6a59610ae1446",
|
|
9076
|
+
reward_distributor_id: "0xdf213d8e0ca49c8f4a508e7d3b3a6983c4aafd639f7c99479fc75fb4451d752e",
|
|
9077
|
+
magma_token: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1::magma_token::MAGMA_TOKEN",
|
|
9078
|
+
minter_id: "0x89435d6b2a510ba50ca23303f10e91ec058f138a88f69a43fe03cd22edb214c5"
|
|
8377
9079
|
}
|
|
8378
9080
|
};
|
|
8379
9081
|
var clmmTestnet = {
|
|
8380
9082
|
fullRpcUrl: getFullnodeUrl2("testnet"),
|
|
8381
|
-
simulationAccount: {
|
|
8382
|
-
address: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
8383
|
-
},
|
|
8384
|
-
faucet: {
|
|
8385
|
-
package_id: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc",
|
|
8386
|
-
published_at: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc"
|
|
8387
|
-
},
|
|
8388
9083
|
magma_config: {
|
|
8389
9084
|
package_id: "0xf5ff7d5ba73b581bca6b4b9fa0049cd320360abd154b809f8700a8fd3cfaf7ca",
|
|
8390
9085
|
published_at: "0xf5ff7d5ba73b581bca6b4b9fa0049cd320360abd154b809f8700a8fd3cfaf7ca",
|
|
8391
9086
|
config: SDKConfig2.magmaConfig
|
|
8392
9087
|
},
|
|
8393
9088
|
clmm_pool: {
|
|
8394
|
-
package_id: "
|
|
8395
|
-
published_at: "
|
|
9089
|
+
package_id: "0x23e0b5ab4aa63d0e6fd98fa5e247bcf9b36ad716b479d39e56b2ba9ff631e09d",
|
|
9090
|
+
published_at: "0x23e0b5ab4aa63d0e6fd98fa5e247bcf9b36ad716b479d39e56b2ba9ff631e09d",
|
|
8396
9091
|
config: SDKConfig2.clmmConfig
|
|
8397
9092
|
},
|
|
9093
|
+
distribution: {
|
|
9094
|
+
package_id: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1",
|
|
9095
|
+
published_at: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1"
|
|
9096
|
+
},
|
|
8398
9097
|
integrate: {
|
|
8399
|
-
package_id: "
|
|
8400
|
-
published_at: "
|
|
9098
|
+
package_id: "0x6d225cd7b90ca74b13e7de114c6eba2f844a1e5e1a4d7459048386bfff0d45df",
|
|
9099
|
+
published_at: "0x6d225cd7b90ca74b13e7de114c6eba2f844a1e5e1a4d7459048386bfff0d45df"
|
|
9100
|
+
},
|
|
9101
|
+
simulationAccount: {
|
|
9102
|
+
address: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
9103
|
+
},
|
|
9104
|
+
faucet: {
|
|
9105
|
+
package_id: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc",
|
|
9106
|
+
published_at: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc"
|
|
8401
9107
|
},
|
|
8402
9108
|
deepbook: {
|
|
8403
9109
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
@@ -8462,6 +9168,7 @@ export {
|
|
|
8462
9168
|
GAS_SYMBOL,
|
|
8463
9169
|
GAS_TYPE_ARG,
|
|
8464
9170
|
GAS_TYPE_ARG_LONG,
|
|
9171
|
+
LockModule,
|
|
8465
9172
|
MAX_SQRT_PRICE,
|
|
8466
9173
|
MAX_TICK_INDEX,
|
|
8467
9174
|
MIN_SQRT_PRICE,
|
|
@@ -8475,6 +9182,7 @@ export {
|
|
|
8475
9182
|
PositionModule,
|
|
8476
9183
|
PositionStatus,
|
|
8477
9184
|
PositionUtil,
|
|
9185
|
+
RewardDistributor,
|
|
8478
9186
|
RouterModule,
|
|
8479
9187
|
RouterModuleV2,
|
|
8480
9188
|
RpcModule,
|
|
@@ -8494,6 +9202,8 @@ export {
|
|
|
8494
9202
|
U128,
|
|
8495
9203
|
U128_MAX,
|
|
8496
9204
|
U64_MAX,
|
|
9205
|
+
Voter,
|
|
9206
|
+
VotingEscrow,
|
|
8497
9207
|
ZERO,
|
|
8498
9208
|
addHexPrefix,
|
|
8499
9209
|
adjustForCoinSlippage,
|