@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.js
CHANGED
|
@@ -68,6 +68,7 @@ __export(src_exports, {
|
|
|
68
68
|
GAS_SYMBOL: () => GAS_SYMBOL,
|
|
69
69
|
GAS_TYPE_ARG: () => GAS_TYPE_ARG,
|
|
70
70
|
GAS_TYPE_ARG_LONG: () => GAS_TYPE_ARG_LONG,
|
|
71
|
+
LockModule: () => LockModule,
|
|
71
72
|
MAX_SQRT_PRICE: () => MAX_SQRT_PRICE,
|
|
72
73
|
MAX_TICK_INDEX: () => MAX_TICK_INDEX,
|
|
73
74
|
MIN_SQRT_PRICE: () => MIN_SQRT_PRICE,
|
|
@@ -81,6 +82,7 @@ __export(src_exports, {
|
|
|
81
82
|
PositionModule: () => PositionModule,
|
|
82
83
|
PositionStatus: () => PositionStatus,
|
|
83
84
|
PositionUtil: () => PositionUtil,
|
|
85
|
+
RewardDistributor: () => RewardDistributor,
|
|
84
86
|
RouterModule: () => RouterModule,
|
|
85
87
|
RouterModuleV2: () => RouterModuleV2,
|
|
86
88
|
RpcModule: () => RpcModule,
|
|
@@ -100,6 +102,8 @@ __export(src_exports, {
|
|
|
100
102
|
U128: () => U128,
|
|
101
103
|
U128_MAX: () => U128_MAX,
|
|
102
104
|
U64_MAX: () => U64_MAX,
|
|
105
|
+
Voter: () => Voter,
|
|
106
|
+
VotingEscrow: () => VotingEscrow,
|
|
103
107
|
ZERO: () => ZERO,
|
|
104
108
|
addHexPrefix: () => addHexPrefix,
|
|
105
109
|
adjustForCoinSlippage: () => adjustForCoinSlippage,
|
|
@@ -497,6 +501,9 @@ var ClmmIntegrateRouterWithPartnerModule = "router_with_partner";
|
|
|
497
501
|
var ClmmFetcherModule = "fetcher_script";
|
|
498
502
|
var ClmmExpectSwapModule = "expect_swap";
|
|
499
503
|
var ClmmIntegrateUtilsModule = "utils";
|
|
504
|
+
var VotingEscrow = "voting_escrow";
|
|
505
|
+
var Voter = "voter";
|
|
506
|
+
var RewardDistributor = "reward_distributor";
|
|
500
507
|
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
501
508
|
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
502
509
|
var DeepbookCustodianV2Moudle = "custodian_v2";
|
|
@@ -2953,6 +2960,246 @@ var _TransactionUtil = class {
|
|
|
2953
2960
|
tx = _TransactionUtil.buildSwapTransactionArgs(tx, params, sdk.sdkOptions, primaryCoinInputA, primaryCoinInputB);
|
|
2954
2961
|
return tx;
|
|
2955
2962
|
}
|
|
2963
|
+
static buildCreateLockTransaction(sdk, params, allCoinAsset) {
|
|
2964
|
+
let tx = new import_transactions.Transaction();
|
|
2965
|
+
tx.setSender(sdk.senderAddress);
|
|
2966
|
+
const { magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2967
|
+
const lockCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(params.amount), magma_token, false, true);
|
|
2968
|
+
tx = _TransactionUtil.buildCreateTransactionArgs(tx, params, sdk.sdkOptions, lockCoinInput);
|
|
2969
|
+
return tx;
|
|
2970
|
+
}
|
|
2971
|
+
static buildCreateTransactionArgs(tx, params, sdkOptions, lockCoinInput) {
|
|
2972
|
+
const { integrate } = sdkOptions;
|
|
2973
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdkOptions.magma_config);
|
|
2974
|
+
const typeArguments = [magma_token];
|
|
2975
|
+
const functionName = "create_lock";
|
|
2976
|
+
const coins = tx.makeMoveVec({ elements: [lockCoinInput.targetCoin] });
|
|
2977
|
+
const args = [
|
|
2978
|
+
tx.object(voting_escrow_id),
|
|
2979
|
+
coins,
|
|
2980
|
+
tx.pure.u64(params.lockDurationDays),
|
|
2981
|
+
tx.pure.bool(params.permanent),
|
|
2982
|
+
tx.object(CLOCK_ADDRESS)
|
|
2983
|
+
];
|
|
2984
|
+
tx.moveCall({
|
|
2985
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
2986
|
+
typeArguments,
|
|
2987
|
+
arguments: args
|
|
2988
|
+
});
|
|
2989
|
+
return tx;
|
|
2990
|
+
}
|
|
2991
|
+
static buildIncreaseLockAmountTransaction(sdk, params, allCoinAsset) {
|
|
2992
|
+
const { magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
2993
|
+
let tx = new import_transactions.Transaction();
|
|
2994
|
+
tx.setSender(sdk.senderAddress);
|
|
2995
|
+
const lockCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(params.amount), magma_token, false, true);
|
|
2996
|
+
tx = _TransactionUtil.buildIncreaseLockAmountTransactionArgs(tx, params, sdk.sdkOptions, lockCoinInput);
|
|
2997
|
+
return tx;
|
|
2998
|
+
}
|
|
2999
|
+
static buildIncreaseLockAmountTransactionArgs(tx, params, sdkOptions, increaseCoinInput) {
|
|
3000
|
+
const { integrate } = sdkOptions;
|
|
3001
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdkOptions.magma_config);
|
|
3002
|
+
const typeArguments = [magma_token];
|
|
3003
|
+
const functionName = "increase_amount_single_coin";
|
|
3004
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), increaseCoinInput.targetCoin, tx.object(CLOCK_ADDRESS)];
|
|
3005
|
+
tx.moveCall({
|
|
3006
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
3007
|
+
typeArguments,
|
|
3008
|
+
arguments: args
|
|
3009
|
+
});
|
|
3010
|
+
return tx;
|
|
3011
|
+
}
|
|
3012
|
+
// public fun merge<T>(self: &mut VotingEscrow<T>, from_lock: Lock, to_lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
3013
|
+
static buildMergeLockTransaction(sdk, params) {
|
|
3014
|
+
const tx = new import_transactions.Transaction();
|
|
3015
|
+
tx.setSender(sdk.senderAddress);
|
|
3016
|
+
const { integrate } = sdk.sdkOptions;
|
|
3017
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3018
|
+
const typeArguments = [magma_token];
|
|
3019
|
+
const functionName = "merge_locks";
|
|
3020
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.fromLockId), tx.object(params.toLockId), tx.object(CLOCK_ADDRESS)];
|
|
3021
|
+
tx.moveCall({
|
|
3022
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
3023
|
+
typeArguments,
|
|
3024
|
+
arguments: args
|
|
3025
|
+
});
|
|
3026
|
+
return tx;
|
|
3027
|
+
}
|
|
3028
|
+
// public fun transfer<T>(lock: Lock, ve: &mut VotingEscrow<T>, to: address, clock: &Clock, ctx: &mut TxContext) {
|
|
3029
|
+
static buildTransferLockTransaction(sdk, params) {
|
|
3030
|
+
const tx = new import_transactions.Transaction();
|
|
3031
|
+
tx.setSender(sdk.senderAddress);
|
|
3032
|
+
const { integrate } = sdk.sdkOptions;
|
|
3033
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3034
|
+
const typeArguments = [magma_token];
|
|
3035
|
+
const functionName = "transfer";
|
|
3036
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(params.to), tx.object(CLOCK_ADDRESS)];
|
|
3037
|
+
tx.moveCall({
|
|
3038
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
3039
|
+
typeArguments,
|
|
3040
|
+
arguments: args
|
|
3041
|
+
});
|
|
3042
|
+
return tx;
|
|
3043
|
+
}
|
|
3044
|
+
// public fun increase_unlock_time<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, lock_duration: u64, clock: &Clock, ctx: &mut TxContext) {
|
|
3045
|
+
static buildIncreaseUnlockTimeTransaction(sdk, params) {
|
|
3046
|
+
const tx = new import_transactions.Transaction();
|
|
3047
|
+
tx.setGasBudget(1e8);
|
|
3048
|
+
tx.setSender(sdk.senderAddress);
|
|
3049
|
+
const oneDay = 24 * 60 * 60;
|
|
3050
|
+
const newLockDuration = Math.ceil((params.newLockEndAt - Date.now()) / oneDay);
|
|
3051
|
+
const { integrate } = sdk.sdkOptions;
|
|
3052
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3053
|
+
const typeArguments = [magma_token];
|
|
3054
|
+
const functionName = "increase_unlock_time";
|
|
3055
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.pure.u64(newLockDuration), tx.object(CLOCK_ADDRESS)];
|
|
3056
|
+
tx.moveCall({
|
|
3057
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
3058
|
+
typeArguments,
|
|
3059
|
+
arguments: args
|
|
3060
|
+
});
|
|
3061
|
+
return tx;
|
|
3062
|
+
}
|
|
3063
|
+
// public fun lock_permanent<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
3064
|
+
static buildLockPermanentTransaction(sdk, params) {
|
|
3065
|
+
const tx = new import_transactions.Transaction();
|
|
3066
|
+
tx.setSender(sdk.senderAddress);
|
|
3067
|
+
const { integrate } = sdk.sdkOptions;
|
|
3068
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3069
|
+
const typeArguments = [magma_token];
|
|
3070
|
+
const functionName = "lock_permanent";
|
|
3071
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
3072
|
+
tx.moveCall({
|
|
3073
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
3074
|
+
typeArguments,
|
|
3075
|
+
arguments: args
|
|
3076
|
+
});
|
|
3077
|
+
return tx;
|
|
3078
|
+
}
|
|
3079
|
+
static buildUnlockPermanentTransaction(sdk, params) {
|
|
3080
|
+
const tx = new import_transactions.Transaction();
|
|
3081
|
+
tx.setSender(sdk.senderAddress);
|
|
3082
|
+
const { integrate } = sdk.sdkOptions;
|
|
3083
|
+
const { voting_escrow_id, magma_token } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3084
|
+
const typeArguments = [magma_token];
|
|
3085
|
+
const functionName = "unlock_permanent";
|
|
3086
|
+
const args = [tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
3087
|
+
tx.moveCall({
|
|
3088
|
+
target: `${integrate.published_at}::${VotingEscrow}::${functionName}`,
|
|
3089
|
+
typeArguments,
|
|
3090
|
+
arguments: args
|
|
3091
|
+
});
|
|
3092
|
+
return tx;
|
|
3093
|
+
}
|
|
3094
|
+
static buildVoteTransaction(sdk, params) {
|
|
3095
|
+
const tx = new import_transactions.Transaction();
|
|
3096
|
+
tx.setSender(sdk.senderAddress);
|
|
3097
|
+
tx.setGasBudget(1e8);
|
|
3098
|
+
const { integrate } = sdk.sdkOptions;
|
|
3099
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3100
|
+
const typeArguments = [magma_token];
|
|
3101
|
+
const functionName = "vote";
|
|
3102
|
+
const pools = tx.pure.vector("id", params.pools);
|
|
3103
|
+
const weights = tx.makeMoveVec({
|
|
3104
|
+
elements: params.weights.map((weight) => tx.pure.u64(weight)),
|
|
3105
|
+
type: "u64"
|
|
3106
|
+
});
|
|
3107
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(params.lockId), pools, weights, tx.object(CLOCK_ADDRESS)];
|
|
3108
|
+
tx.moveCall({
|
|
3109
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
3110
|
+
typeArguments,
|
|
3111
|
+
arguments: args
|
|
3112
|
+
});
|
|
3113
|
+
return tx;
|
|
3114
|
+
}
|
|
3115
|
+
static buildClaimVotingRewardsTransaction(sdk, params) {
|
|
3116
|
+
const tx = new import_transactions.Transaction();
|
|
3117
|
+
tx.setSender(sdk.senderAddress);
|
|
3118
|
+
const { integrate } = sdk.sdkOptions;
|
|
3119
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3120
|
+
const typeArguments = [magma_token, params.coinAType, params.coinBType];
|
|
3121
|
+
const functionName = "claim_voting_fee_rewards_single";
|
|
3122
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(params.locks), tx.object(CLOCK_ADDRESS)];
|
|
3123
|
+
tx.moveCall({
|
|
3124
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
3125
|
+
typeArguments,
|
|
3126
|
+
arguments: args
|
|
3127
|
+
});
|
|
3128
|
+
return tx;
|
|
3129
|
+
}
|
|
3130
|
+
static buildClaimVotingRewardsPoolsTransaction(sdk, params) {
|
|
3131
|
+
const tx = new import_transactions.Transaction();
|
|
3132
|
+
tx.setSender(sdk.senderAddress);
|
|
3133
|
+
const { integrate, distribution } = sdk.sdkOptions;
|
|
3134
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3135
|
+
const typeArguments = [magma_token, params.coinAType, params.coinBType];
|
|
3136
|
+
const functionName = "claim_voting_fee_rewards";
|
|
3137
|
+
const locks = tx.makeMoveVec({
|
|
3138
|
+
elements: params.locks.map((lock) => tx.object(lock)),
|
|
3139
|
+
type: `${distribution.package_id}::voting_escrow::Lock`
|
|
3140
|
+
});
|
|
3141
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), locks, tx.object(CLOCK_ADDRESS)];
|
|
3142
|
+
tx.moveCall({
|
|
3143
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
3144
|
+
typeArguments,
|
|
3145
|
+
arguments: args
|
|
3146
|
+
});
|
|
3147
|
+
return tx;
|
|
3148
|
+
}
|
|
3149
|
+
static buildClaimAndLockRebases(sdk, params) {
|
|
3150
|
+
const tx = new import_transactions.Transaction();
|
|
3151
|
+
tx.setSender(sdk.senderAddress);
|
|
3152
|
+
tx.setGasBudget(5e8);
|
|
3153
|
+
const { integrate } = sdk.sdkOptions;
|
|
3154
|
+
const { voting_escrow_id, magma_token, reward_distributor_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3155
|
+
const typeArguments = [magma_token];
|
|
3156
|
+
const functionName = "claim_and_lock";
|
|
3157
|
+
const args = [tx.object(reward_distributor_id), tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
3158
|
+
tx.moveCall({
|
|
3159
|
+
target: `${integrate.published_at}::${RewardDistributor}::${functionName}`,
|
|
3160
|
+
typeArguments,
|
|
3161
|
+
arguments: args
|
|
3162
|
+
});
|
|
3163
|
+
return tx;
|
|
3164
|
+
}
|
|
3165
|
+
static buildPoke(sdk, params) {
|
|
3166
|
+
const tx = new import_transactions.Transaction();
|
|
3167
|
+
tx.setSender(sdk.senderAddress);
|
|
3168
|
+
const { integrate } = sdk.sdkOptions;
|
|
3169
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3170
|
+
const typeArguments = [magma_token];
|
|
3171
|
+
const functionName = "poke";
|
|
3172
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(params.lockId), tx.object(CLOCK_ADDRESS)];
|
|
3173
|
+
tx.moveCall({
|
|
3174
|
+
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
3175
|
+
typeArguments,
|
|
3176
|
+
arguments: args
|
|
3177
|
+
});
|
|
3178
|
+
return tx;
|
|
3179
|
+
}
|
|
3180
|
+
static buildClaimVotingBribe(sdk, locks, incentive_tokens) {
|
|
3181
|
+
const tx = new import_transactions.Transaction();
|
|
3182
|
+
tx.setGasBudget(5e8);
|
|
3183
|
+
tx.setSender(sdk.senderAddress);
|
|
3184
|
+
const { integrate, distribution } = sdk.sdkOptions;
|
|
3185
|
+
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3186
|
+
const typeArguments = [magma_token, ...incentive_tokens];
|
|
3187
|
+
let targetFunc = `${integrate.published_at}::${Voter}::claim_voting_bribes_${incentive_tokens.length}`;
|
|
3188
|
+
if (incentive_tokens.length === 1) {
|
|
3189
|
+
targetFunc = `${integrate.published_at}::${Voter}::claim_voting_bribes`;
|
|
3190
|
+
}
|
|
3191
|
+
const locksParams = tx.makeMoveVec({
|
|
3192
|
+
elements: locks.map((lock) => tx.object(lock)),
|
|
3193
|
+
type: `${distribution.package_id}::voting_escrow::Lock`
|
|
3194
|
+
});
|
|
3195
|
+
const args = [tx.object(voter_id), tx.object(voting_escrow_id), locksParams, tx.object(CLOCK_ADDRESS)];
|
|
3196
|
+
tx.moveCall({
|
|
3197
|
+
target: targetFunc,
|
|
3198
|
+
typeArguments,
|
|
3199
|
+
arguments: args
|
|
3200
|
+
});
|
|
3201
|
+
return tx;
|
|
3202
|
+
}
|
|
2956
3203
|
/**
|
|
2957
3204
|
* build swap transaction
|
|
2958
3205
|
* @param params
|
|
@@ -6743,9 +6990,16 @@ var SwapModule = class {
|
|
|
6743
6990
|
*/
|
|
6744
6991
|
async preswap(params) {
|
|
6745
6992
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
6993
|
+
const { global_config_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
6746
6994
|
const tx = new import_transactions8.Transaction();
|
|
6747
6995
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
6748
|
-
const args = [
|
|
6996
|
+
const args = [
|
|
6997
|
+
tx.object(global_config_id),
|
|
6998
|
+
tx.object(params.pool.poolAddress),
|
|
6999
|
+
tx.pure.bool(params.a2b),
|
|
7000
|
+
tx.pure.bool(params.byAmountIn),
|
|
7001
|
+
tx.pure.u64(params.amount)
|
|
7002
|
+
];
|
|
6749
7003
|
tx.moveCall({
|
|
6750
7004
|
target: `${integrate.published_at}::${ClmmFetcherModule}::calculate_swap_result`,
|
|
6751
7005
|
arguments: args,
|
|
@@ -6903,10 +7157,434 @@ var SwapModule = class {
|
|
|
6903
7157
|
}
|
|
6904
7158
|
};
|
|
6905
7159
|
|
|
7160
|
+
// src/modules/lockModule.ts
|
|
7161
|
+
var import_transactions9 = require("@mysten/sui/transactions");
|
|
7162
|
+
var LockModule = class {
|
|
7163
|
+
_sdk;
|
|
7164
|
+
constructor(sdk) {
|
|
7165
|
+
this._sdk = sdk;
|
|
7166
|
+
}
|
|
7167
|
+
get sdk() {
|
|
7168
|
+
return this._sdk;
|
|
7169
|
+
}
|
|
7170
|
+
async createLockTransactionPayload(params) {
|
|
7171
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7172
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7173
|
+
}
|
|
7174
|
+
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
7175
|
+
return TransactionUtil.buildCreateLockTransaction(this.sdk, params, allCoinAsset);
|
|
7176
|
+
}
|
|
7177
|
+
async increaseLockAmountTransactionPayload(params) {
|
|
7178
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7179
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7180
|
+
}
|
|
7181
|
+
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
7182
|
+
return TransactionUtil.buildIncreaseLockAmountTransaction(this.sdk, params, allCoinAsset);
|
|
7183
|
+
}
|
|
7184
|
+
async mergeLockTransactionPayload(params) {
|
|
7185
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7186
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7187
|
+
}
|
|
7188
|
+
return TransactionUtil.buildMergeLockTransaction(this.sdk, params);
|
|
7189
|
+
}
|
|
7190
|
+
// public fun transfer<T>(lock: Lock, ve: &mut VotingEscrow<T>, to: address, clock: &Clock, ctx: &mut TxContext) {
|
|
7191
|
+
async transferLockTransactionPayload(params) {
|
|
7192
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7193
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7194
|
+
}
|
|
7195
|
+
return TransactionUtil.buildTransferLockTransaction(this.sdk, params);
|
|
7196
|
+
}
|
|
7197
|
+
async increaseUnlockTimePayload(params) {
|
|
7198
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7199
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7200
|
+
}
|
|
7201
|
+
return TransactionUtil.buildIncreaseUnlockTimeTransaction(this.sdk, params);
|
|
7202
|
+
}
|
|
7203
|
+
// public fun lock_permanent<T>(self: &mut VotingEscrow<T>, lock: &mut Lock, clock: &Clock, ctx: &mut TxContext) {
|
|
7204
|
+
async lockPermanentPayload(params) {
|
|
7205
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7206
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7207
|
+
}
|
|
7208
|
+
return TransactionUtil.buildLockPermanentTransaction(this.sdk, params);
|
|
7209
|
+
}
|
|
7210
|
+
async unlockPermanentPayload(params) {
|
|
7211
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7212
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7213
|
+
}
|
|
7214
|
+
return TransactionUtil.buildUnlockPermanentTransaction(this.sdk, params);
|
|
7215
|
+
}
|
|
7216
|
+
async votePayload(params) {
|
|
7217
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7218
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7219
|
+
}
|
|
7220
|
+
return TransactionUtil.buildVoteTransaction(this.sdk, params);
|
|
7221
|
+
}
|
|
7222
|
+
// public fun claim_fees<T, B>(self: &mut Voter<T>, ve: &mut VotingEscrow<T>, mut locks: vector<Lock>, clock: &Clock, ctx: &mut TxContext) {
|
|
7223
|
+
async claimVotingRewardsPayload(params) {
|
|
7224
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7225
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7226
|
+
}
|
|
7227
|
+
return TransactionUtil.buildClaimVotingRewardsTransaction(this.sdk, params);
|
|
7228
|
+
}
|
|
7229
|
+
// public fun claim_fees<T, B>(self: &mut Voter<T>, ve: &mut VotingEscrow<T>, mut locks: vector<Lock>, clock: &Clock, ctx: &mut TxContext) {
|
|
7230
|
+
async claimVotingRewardsPoolsPayload(params) {
|
|
7231
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7232
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7233
|
+
}
|
|
7234
|
+
return TransactionUtil.buildClaimVotingRewardsPoolsTransaction(this.sdk, params);
|
|
7235
|
+
}
|
|
7236
|
+
async claimAndLockRebasesPayload(params) {
|
|
7237
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7238
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7239
|
+
}
|
|
7240
|
+
return TransactionUtil.buildClaimAndLockRebases(this.sdk, params);
|
|
7241
|
+
}
|
|
7242
|
+
async pokePayload(params) {
|
|
7243
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7244
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7245
|
+
}
|
|
7246
|
+
return TransactionUtil.buildPoke(this.sdk, params);
|
|
7247
|
+
}
|
|
7248
|
+
async claimVotingBribe(locks, incentive_tokens) {
|
|
7249
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7250
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7251
|
+
}
|
|
7252
|
+
return TransactionUtil.buildClaimVotingBribe(this.sdk, locks, incentive_tokens);
|
|
7253
|
+
}
|
|
7254
|
+
async locksOfUser(user) {
|
|
7255
|
+
const locksInfo = { owner: user, lockInfo: [] };
|
|
7256
|
+
const { distribution } = this._sdk.sdkOptions;
|
|
7257
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7258
|
+
const ownerRes = await this._sdk.fullClient.getOwnedObjectsByPage(user, {
|
|
7259
|
+
options: { showType: true, showContent: true, showDisplay: true, showOwner: true },
|
|
7260
|
+
filter: {
|
|
7261
|
+
MatchAll: [{ Package: distribution.package_id }, { StructType: `${distribution.package_id}::voting_escrow::Lock` }]
|
|
7262
|
+
}
|
|
7263
|
+
});
|
|
7264
|
+
for (const item of ownerRes.data) {
|
|
7265
|
+
const { fields } = item.data.content;
|
|
7266
|
+
const aLockSummary = await this.aLockSummary(fields.id.id);
|
|
7267
|
+
const poolIncentiveTokens = await this.getVotingBribeRewardTokens(fields.id.id);
|
|
7268
|
+
const incentiveTokens = [];
|
|
7269
|
+
poolIncentiveTokens.forEach((value, key) => {
|
|
7270
|
+
incentiveTokens.push(...value);
|
|
7271
|
+
});
|
|
7272
|
+
const poolIncentiveRewards = await this.getPoolIncentiveRewrads(incentiveTokens, fields.id.id);
|
|
7273
|
+
const votingRewards = /* @__PURE__ */ new Map();
|
|
7274
|
+
poolIncentiveRewards.forEach((value, coin) => {
|
|
7275
|
+
value.forEach((amount, pool) => {
|
|
7276
|
+
if (!votingRewards.has(pool)) {
|
|
7277
|
+
votingRewards.set(pool, []);
|
|
7278
|
+
}
|
|
7279
|
+
votingRewards.get(pool)?.push({
|
|
7280
|
+
kind: "incentiveCoin" /* Incentive */,
|
|
7281
|
+
token_addr: coin,
|
|
7282
|
+
amount: amount.toString()
|
|
7283
|
+
});
|
|
7284
|
+
});
|
|
7285
|
+
});
|
|
7286
|
+
const lockInfo = {
|
|
7287
|
+
lock_id: fields.id.id,
|
|
7288
|
+
amount: fields.amount,
|
|
7289
|
+
start: fields.start,
|
|
7290
|
+
end: fields.end,
|
|
7291
|
+
permanent: fields.permanent,
|
|
7292
|
+
rebase_amount: {
|
|
7293
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7294
|
+
token_addr: magma_token,
|
|
7295
|
+
amount: aLockSummary.reward_distributor_claimable
|
|
7296
|
+
},
|
|
7297
|
+
voting_power: aLockSummary.voting_power,
|
|
7298
|
+
// pool => incentive => amount
|
|
7299
|
+
voting_rewards: votingRewards
|
|
7300
|
+
};
|
|
7301
|
+
locksInfo.lockInfo.push(lockInfo);
|
|
7302
|
+
}
|
|
7303
|
+
return locksInfo;
|
|
7304
|
+
}
|
|
7305
|
+
async aLockSummary(lock_id) {
|
|
7306
|
+
const tx = new import_transactions9.Transaction();
|
|
7307
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7308
|
+
const { voting_escrow_id, magma_token, voter_id, reward_distributor_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7309
|
+
const typeArguments = [magma_token];
|
|
7310
|
+
const args = [
|
|
7311
|
+
tx.object(voter_id),
|
|
7312
|
+
tx.object(voting_escrow_id),
|
|
7313
|
+
tx.object(reward_distributor_id),
|
|
7314
|
+
tx.object(lock_id),
|
|
7315
|
+
tx.object(CLOCK_ADDRESS)
|
|
7316
|
+
];
|
|
7317
|
+
tx.moveCall({
|
|
7318
|
+
target: `${integrate.published_at}::${VotingEscrow}::lock_summary`,
|
|
7319
|
+
arguments: args,
|
|
7320
|
+
typeArguments
|
|
7321
|
+
});
|
|
7322
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7323
|
+
throw Error("this config simulationAccount is not set right");
|
|
7324
|
+
}
|
|
7325
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7326
|
+
transactionBlock: tx,
|
|
7327
|
+
sender: simulationAccount.address
|
|
7328
|
+
});
|
|
7329
|
+
if (simulateRes.error != null) {
|
|
7330
|
+
throw new Error(`lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7331
|
+
}
|
|
7332
|
+
let res = {
|
|
7333
|
+
// reward_distributor_claimable + incentive magma
|
|
7334
|
+
fee_incentive_total: "",
|
|
7335
|
+
// How much Magma can be claimed
|
|
7336
|
+
reward_distributor_claimable: "",
|
|
7337
|
+
voting_power: ""
|
|
7338
|
+
};
|
|
7339
|
+
simulateRes.events?.forEach((item) => {
|
|
7340
|
+
if (extractStructTagFromType(item.type).name === `LockSummary`) {
|
|
7341
|
+
res = {
|
|
7342
|
+
fee_incentive_total: item.parsedJson.fee_incentive_total,
|
|
7343
|
+
reward_distributor_claimable: item.parsedJson.reward_distributor_claimable,
|
|
7344
|
+
voting_power: item.parsedJson.voting_power
|
|
7345
|
+
};
|
|
7346
|
+
}
|
|
7347
|
+
});
|
|
7348
|
+
return res;
|
|
7349
|
+
}
|
|
7350
|
+
async allLockSummary() {
|
|
7351
|
+
const tx = new import_transactions9.Transaction();
|
|
7352
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7353
|
+
const { voting_escrow_id, magma_token, voter_id, minter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7354
|
+
const typeArguments = [magma_token];
|
|
7355
|
+
const args = [tx.object(minter_id), tx.object(voter_id), tx.object(voting_escrow_id), tx.object(CLOCK_ADDRESS)];
|
|
7356
|
+
tx.moveCall({
|
|
7357
|
+
target: `${integrate.published_at}::${VotingEscrow}::summary`,
|
|
7358
|
+
arguments: args,
|
|
7359
|
+
typeArguments
|
|
7360
|
+
});
|
|
7361
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7362
|
+
throw Error("this config simulationAccount is not set right");
|
|
7363
|
+
}
|
|
7364
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7365
|
+
transactionBlock: tx,
|
|
7366
|
+
sender: simulationAccount.address
|
|
7367
|
+
});
|
|
7368
|
+
if (simulateRes.error != null) {
|
|
7369
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7370
|
+
}
|
|
7371
|
+
let summary = {
|
|
7372
|
+
current_epoch_end: 0,
|
|
7373
|
+
current_epoch_vote_end: 0,
|
|
7374
|
+
rebase_apr: 0,
|
|
7375
|
+
team_emission_rate: 0,
|
|
7376
|
+
total_locked: 0,
|
|
7377
|
+
total_voted_power: 0,
|
|
7378
|
+
total_voting_power: 0
|
|
7379
|
+
};
|
|
7380
|
+
simulateRes.events?.forEach((item) => {
|
|
7381
|
+
if (extractStructTagFromType(item.type).name === `Summary`) {
|
|
7382
|
+
summary = {
|
|
7383
|
+
current_epoch_end: Number(item.parsedJson.current_epoch_end),
|
|
7384
|
+
current_epoch_vote_end: Number(item.parsedJson.current_epoch_vote_end),
|
|
7385
|
+
rebase_apr: Number(item.parsedJson.rebase_apr),
|
|
7386
|
+
team_emission_rate: Number(item.parsedJson.team_emission_rate),
|
|
7387
|
+
total_locked: Number(item.parsedJson.total_locked),
|
|
7388
|
+
total_voted_power: Number(item.parsedJson.total_voted_power),
|
|
7389
|
+
total_voting_power: Number(item.parsedJson.total_voting_power)
|
|
7390
|
+
};
|
|
7391
|
+
}
|
|
7392
|
+
});
|
|
7393
|
+
return summary;
|
|
7394
|
+
}
|
|
7395
|
+
async poolWeights(pools) {
|
|
7396
|
+
const tx = new import_transactions9.Transaction();
|
|
7397
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7398
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7399
|
+
const typeArguments = [magma_token];
|
|
7400
|
+
const poolsParams = tx.pure.vector("id", pools);
|
|
7401
|
+
const args = [tx.object(voter_id), poolsParams];
|
|
7402
|
+
tx.moveCall({
|
|
7403
|
+
target: `${integrate.published_at}::${Voter}::pools_tally`,
|
|
7404
|
+
arguments: args,
|
|
7405
|
+
typeArguments
|
|
7406
|
+
});
|
|
7407
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7408
|
+
throw Error("this config simulationAccount is not set right");
|
|
7409
|
+
}
|
|
7410
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7411
|
+
transactionBlock: tx,
|
|
7412
|
+
sender: simulationAccount.address
|
|
7413
|
+
});
|
|
7414
|
+
if (simulateRes.error != null) {
|
|
7415
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7416
|
+
}
|
|
7417
|
+
const poolWeights = [];
|
|
7418
|
+
simulateRes.events?.forEach((item) => {
|
|
7419
|
+
if (extractStructTagFromType(item.type).name === `PoolsTally`) {
|
|
7420
|
+
item.parsedJson.list.forEach((item2) => {
|
|
7421
|
+
poolWeights.push({
|
|
7422
|
+
poolId: item2.id,
|
|
7423
|
+
weight: item2.weight
|
|
7424
|
+
});
|
|
7425
|
+
});
|
|
7426
|
+
}
|
|
7427
|
+
});
|
|
7428
|
+
return poolWeights;
|
|
7429
|
+
}
|
|
7430
|
+
async getVotingFeeRewardTokens(lock_id) {
|
|
7431
|
+
const tx = new import_transactions9.Transaction();
|
|
7432
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7433
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7434
|
+
const typeArguments = [magma_token];
|
|
7435
|
+
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
7436
|
+
tx.moveCall({
|
|
7437
|
+
target: `${integrate.published_at}::${Voter}::get_voting_fee_reward_tokens`,
|
|
7438
|
+
arguments: args,
|
|
7439
|
+
typeArguments
|
|
7440
|
+
});
|
|
7441
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7442
|
+
throw Error("this config simulationAccount is not set right");
|
|
7443
|
+
}
|
|
7444
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7445
|
+
transactionBlock: tx,
|
|
7446
|
+
sender: simulationAccount.address
|
|
7447
|
+
});
|
|
7448
|
+
if (simulateRes.error != null) {
|
|
7449
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7450
|
+
}
|
|
7451
|
+
const poolRewardTokens = /* @__PURE__ */ new Map();
|
|
7452
|
+
simulateRes.events?.forEach((item) => {
|
|
7453
|
+
if (extractStructTagFromType(item.type).name === `EventRewardTokens`) {
|
|
7454
|
+
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7455
|
+
if (!poolRewardTokens.has(poolTokens.key)) {
|
|
7456
|
+
poolRewardTokens.set(poolTokens.key, []);
|
|
7457
|
+
}
|
|
7458
|
+
poolTokens.value.forEach((token) => {
|
|
7459
|
+
poolRewardTokens.get(poolTokens.key)?.push(token.name);
|
|
7460
|
+
});
|
|
7461
|
+
});
|
|
7462
|
+
}
|
|
7463
|
+
});
|
|
7464
|
+
return poolRewardTokens;
|
|
7465
|
+
}
|
|
7466
|
+
async getVotingBribeRewardTokens(lock_id) {
|
|
7467
|
+
const tx = new import_transactions9.Transaction();
|
|
7468
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7469
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7470
|
+
const typeArguments = [magma_token];
|
|
7471
|
+
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
7472
|
+
tx.moveCall({
|
|
7473
|
+
target: `${integrate.published_at}::${Voter}::get_voting_bribe_reward_tokens`,
|
|
7474
|
+
arguments: args,
|
|
7475
|
+
typeArguments
|
|
7476
|
+
});
|
|
7477
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7478
|
+
throw Error("this config simulationAccount is not set right");
|
|
7479
|
+
}
|
|
7480
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7481
|
+
transactionBlock: tx,
|
|
7482
|
+
sender: simulationAccount.address
|
|
7483
|
+
});
|
|
7484
|
+
if (simulateRes.error != null) {
|
|
7485
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7486
|
+
}
|
|
7487
|
+
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
7488
|
+
simulateRes.events?.forEach((item) => {
|
|
7489
|
+
if (extractStructTagFromType(item.type).name === `EventRewardTokens`) {
|
|
7490
|
+
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7491
|
+
if (!poolBirbeRewardTokens.has(poolTokens.key)) {
|
|
7492
|
+
poolBirbeRewardTokens.set(poolTokens.key, []);
|
|
7493
|
+
}
|
|
7494
|
+
poolTokens.value.forEach((token) => {
|
|
7495
|
+
poolBirbeRewardTokens.get(poolTokens.key)?.push(token.name);
|
|
7496
|
+
});
|
|
7497
|
+
});
|
|
7498
|
+
}
|
|
7499
|
+
});
|
|
7500
|
+
return poolBirbeRewardTokens;
|
|
7501
|
+
}
|
|
7502
|
+
// tokenId => pool => incentive_tokens
|
|
7503
|
+
async getPoolIncentiveRewrads(incentive_tokens, locksId) {
|
|
7504
|
+
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
7505
|
+
if (incentive_tokens.length === 0) {
|
|
7506
|
+
return poolBirbeRewardTokens;
|
|
7507
|
+
}
|
|
7508
|
+
const tx = new import_transactions9.Transaction();
|
|
7509
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7510
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7511
|
+
const typeArguments = [magma_token, ...incentive_tokens];
|
|
7512
|
+
const args = [tx.object(voter_id), tx.object(locksId), tx.object(CLOCK_ADDRESS)];
|
|
7513
|
+
let targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_bribes_${incentive_tokens.length}`;
|
|
7514
|
+
if (incentive_tokens.length === 1) {
|
|
7515
|
+
targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_bribes`;
|
|
7516
|
+
}
|
|
7517
|
+
tx.moveCall({
|
|
7518
|
+
target: targetFunc,
|
|
7519
|
+
arguments: args,
|
|
7520
|
+
typeArguments
|
|
7521
|
+
});
|
|
7522
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7523
|
+
throw Error("this config simulationAccount is not set right");
|
|
7524
|
+
}
|
|
7525
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7526
|
+
transactionBlock: tx,
|
|
7527
|
+
sender: simulationAccount.address
|
|
7528
|
+
});
|
|
7529
|
+
if (simulateRes.error != null) {
|
|
7530
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7531
|
+
}
|
|
7532
|
+
simulateRes.events?.forEach((item) => {
|
|
7533
|
+
if (extractStructTagFromType(item.type).name === `ClaimableVotingBribes`) {
|
|
7534
|
+
item.parsedJson.data.contents.forEach((rewardTokens) => {
|
|
7535
|
+
if (!poolBirbeRewardTokens.has(rewardTokens.key.name)) {
|
|
7536
|
+
poolBirbeRewardTokens.set(rewardTokens.key.name, /* @__PURE__ */ new Map());
|
|
7537
|
+
}
|
|
7538
|
+
rewardTokens.value.contents.forEach((token) => {
|
|
7539
|
+
poolBirbeRewardTokens.get(rewardTokens.key.name)?.set(token.key, token.value);
|
|
7540
|
+
});
|
|
7541
|
+
});
|
|
7542
|
+
}
|
|
7543
|
+
});
|
|
7544
|
+
return poolBirbeRewardTokens;
|
|
7545
|
+
}
|
|
7546
|
+
async getPoolBribeRewardTokens(pool_id) {
|
|
7547
|
+
const tx = new import_transactions9.Transaction();
|
|
7548
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7549
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7550
|
+
const typeArguments = [magma_token];
|
|
7551
|
+
const args = [tx.object(voter_id), tx.object(pool_id)];
|
|
7552
|
+
tx.moveCall({
|
|
7553
|
+
target: `${integrate.published_at}::${Voter}::get_voting_bribe_reward_tokens_by_pool`,
|
|
7554
|
+
arguments: args,
|
|
7555
|
+
typeArguments
|
|
7556
|
+
});
|
|
7557
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7558
|
+
throw Error("this config simulationAccount is not set right");
|
|
7559
|
+
}
|
|
7560
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7561
|
+
transactionBlock: tx,
|
|
7562
|
+
sender: simulationAccount.address
|
|
7563
|
+
});
|
|
7564
|
+
if (simulateRes.error != null) {
|
|
7565
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7566
|
+
}
|
|
7567
|
+
const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
|
|
7568
|
+
simulateRes.events?.forEach((item) => {
|
|
7569
|
+
if (extractStructTagFromType(item.type).name === `EventRewardTokens`) {
|
|
7570
|
+
item.parsedJson.list.contents.forEach((poolTokens) => {
|
|
7571
|
+
if (!poolBirbeRewardTokens.has(poolTokens.key)) {
|
|
7572
|
+
poolBirbeRewardTokens.set(poolTokens.key, []);
|
|
7573
|
+
}
|
|
7574
|
+
poolTokens.value.forEach((token) => {
|
|
7575
|
+
poolBirbeRewardTokens.get(poolTokens.key)?.push(token.name);
|
|
7576
|
+
});
|
|
7577
|
+
});
|
|
7578
|
+
}
|
|
7579
|
+
});
|
|
7580
|
+
return poolBirbeRewardTokens;
|
|
7581
|
+
}
|
|
7582
|
+
};
|
|
7583
|
+
|
|
6906
7584
|
// src/modules/tokenModule.ts
|
|
6907
7585
|
var import_js_base64 = require("js-base64");
|
|
6908
|
-
var
|
|
6909
|
-
var
|
|
7586
|
+
var import_transactions10 = require("@mysten/sui/transactions");
|
|
7587
|
+
var import_utils22 = require("@mysten/sui/utils");
|
|
6910
7588
|
var TokenModule = class {
|
|
6911
7589
|
_sdk;
|
|
6912
7590
|
_cache = {};
|
|
@@ -7041,7 +7719,7 @@ var TokenModule = class {
|
|
|
7041
7719
|
}
|
|
7042
7720
|
const tokenConfig = getPackagerConfigs(token);
|
|
7043
7721
|
while (true) {
|
|
7044
|
-
const tx = new
|
|
7722
|
+
const tx = new import_transactions10.Transaction();
|
|
7045
7723
|
tx.moveCall({
|
|
7046
7724
|
target: `${token.published_at}::coin_list::${isOwnerRequest ? "fetch_full_list_with_limit" : "fetch_all_registered_coin_info_with_limit"}`,
|
|
7047
7725
|
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)]
|
|
@@ -7084,7 +7762,7 @@ var TokenModule = class {
|
|
|
7084
7762
|
}
|
|
7085
7763
|
const tokenConfig = getPackagerConfigs(token);
|
|
7086
7764
|
while (true) {
|
|
7087
|
-
const tx = new
|
|
7765
|
+
const tx = new import_transactions10.Transaction();
|
|
7088
7766
|
tx.moveCall({
|
|
7089
7767
|
target: `${token.published_at}::lp_list::${isOwnerRequest ? "fetch_full_list_with_limit" : "fetch_all_registered_coin_info_with_limit"}`,
|
|
7090
7768
|
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)]
|
|
@@ -7218,7 +7896,7 @@ var TokenModule = class {
|
|
|
7218
7896
|
}
|
|
7219
7897
|
}
|
|
7220
7898
|
if (key === "pyth_id") {
|
|
7221
|
-
value = (0,
|
|
7899
|
+
value = (0, import_utils22.normalizeSuiObjectId)(value);
|
|
7222
7900
|
}
|
|
7223
7901
|
token[key] = value;
|
|
7224
7902
|
}
|
|
@@ -7619,7 +8297,7 @@ var RouterModuleV2 = class {
|
|
|
7619
8297
|
};
|
|
7620
8298
|
|
|
7621
8299
|
// src/modules/configModule.ts
|
|
7622
|
-
var
|
|
8300
|
+
var import_utils24 = require("@mysten/sui/utils");
|
|
7623
8301
|
var import_js_base642 = require("js-base64");
|
|
7624
8302
|
var ConfigModule = class {
|
|
7625
8303
|
_sdk;
|
|
@@ -7775,7 +8453,7 @@ var ConfigModule = class {
|
|
|
7775
8453
|
coin.id = getObjectId(object);
|
|
7776
8454
|
coin.address = extractStructTagFromType(fields.coin_type.fields.name).full_address;
|
|
7777
8455
|
if (fields.pyth_id) {
|
|
7778
|
-
coin.pyth_id = (0,
|
|
8456
|
+
coin.pyth_id = (0, import_utils24.normalizeSuiObjectId)(fields.pyth_id);
|
|
7779
8457
|
}
|
|
7780
8458
|
this.transformExtensions(coin, fields.extension_fields.fields.contents, transformExtensions);
|
|
7781
8459
|
delete coin.coin_type;
|
|
@@ -7836,7 +8514,7 @@ var ConfigModule = class {
|
|
|
7836
8514
|
fields = fields.value.fields;
|
|
7837
8515
|
const pool = { ...fields };
|
|
7838
8516
|
pool.id = getObjectId(object);
|
|
7839
|
-
pool.pool_address = (0,
|
|
8517
|
+
pool.pool_address = (0, import_utils24.normalizeSuiObjectId)(fields.pool_address);
|
|
7840
8518
|
this.transformExtensions(pool, fields.extension_fields.fields.contents, transformExtensions);
|
|
7841
8519
|
return pool;
|
|
7842
8520
|
}
|
|
@@ -7895,7 +8573,7 @@ var ConfigModule = class {
|
|
|
7895
8573
|
fields = fields.value.fields;
|
|
7896
8574
|
const pool = { ...fields };
|
|
7897
8575
|
pool.id = getObjectId(object);
|
|
7898
|
-
pool.pool_address = (0,
|
|
8576
|
+
pool.pool_address = (0, import_utils24.normalizeSuiObjectId)(fields.pool_address);
|
|
7899
8577
|
this.transformExtensions(pool, fields.extension_fields.fields.contents, transformExtensions);
|
|
7900
8578
|
const social_medias = [];
|
|
7901
8579
|
fields.social_media.fields.contents.forEach((item) => {
|
|
@@ -7970,7 +8648,12 @@ var ConfigModule = class {
|
|
|
7970
8648
|
global_config_id: "",
|
|
7971
8649
|
coin_list_handle: "",
|
|
7972
8650
|
launchpad_pools_handle: "",
|
|
7973
|
-
clmm_pools_handle: ""
|
|
8651
|
+
clmm_pools_handle: "",
|
|
8652
|
+
voter_id: "",
|
|
8653
|
+
minter_id: "",
|
|
8654
|
+
reward_distributor_id: "",
|
|
8655
|
+
magma_token: "",
|
|
8656
|
+
voting_escrow_id: ""
|
|
7974
8657
|
};
|
|
7975
8658
|
if (objects.data.length > 0) {
|
|
7976
8659
|
for (const item of objects.data) {
|
|
@@ -8260,6 +8943,10 @@ var MagmaClmmSDK = class {
|
|
|
8260
8943
|
* Provide interact with a pool swap router interface.
|
|
8261
8944
|
*/
|
|
8262
8945
|
_swap;
|
|
8946
|
+
/**
|
|
8947
|
+
* Provide interact with a lock interface.
|
|
8948
|
+
*/
|
|
8949
|
+
_lock;
|
|
8263
8950
|
/**
|
|
8264
8951
|
* Provide interact with a position rewarder interface.
|
|
8265
8952
|
*/
|
|
@@ -8295,6 +8982,7 @@ var MagmaClmmSDK = class {
|
|
|
8295
8982
|
url: options.fullRpcUrl
|
|
8296
8983
|
});
|
|
8297
8984
|
this._swap = new SwapModule(this);
|
|
8985
|
+
this._lock = new LockModule(this);
|
|
8298
8986
|
this._pool = new PoolModule(this);
|
|
8299
8987
|
this._position = new PositionModule(this);
|
|
8300
8988
|
this._rewarder = new RewarderModule(this);
|
|
@@ -8325,6 +9013,10 @@ var MagmaClmmSDK = class {
|
|
|
8325
9013
|
get Swap() {
|
|
8326
9014
|
return this._swap;
|
|
8327
9015
|
}
|
|
9016
|
+
/* */
|
|
9017
|
+
get Lock() {
|
|
9018
|
+
return this._lock;
|
|
9019
|
+
}
|
|
8328
9020
|
/**
|
|
8329
9021
|
* Getter for the fullClient property.
|
|
8330
9022
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -8498,7 +9190,7 @@ var main_default = MagmaClmmSDK;
|
|
|
8498
9190
|
var SDKConfig = {
|
|
8499
9191
|
clmmConfig: {
|
|
8500
9192
|
pools_id: "0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0",
|
|
8501
|
-
global_config_id: "
|
|
9193
|
+
global_config_id: "0x4f32c00706e7bdbce532acdcfc0afd91b14defd5ffc9e2723a0ce7ed84f5d380",
|
|
8502
9194
|
global_vault_id: "0xce7bceef26d3ad1f6d9b6f13a953f053e6ed3ca77907516481ce99ae8e588f2b",
|
|
8503
9195
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
8504
9196
|
},
|
|
@@ -8507,10 +9199,15 @@ var SDKConfig = {
|
|
|
8507
9199
|
launchpad_pools_id: "0x1098fac992eab3a0ab7acf15bb654fc1cf29b5a6142c4ef1058e6c408dd15115",
|
|
8508
9200
|
clmm_pools_id: "0x15b6a27dd9ae03eb455aba03b39e29aad74abd3757b8e18c0755651b2ae5b71e",
|
|
8509
9201
|
admin_cap_id: "0x39d78781750e193ce35c45ff32c6c0c3f2941fa3ddaf8595c90c555589ddb113",
|
|
8510
|
-
global_config_id: "0x0408fa4e4a4c03cc0de8f23d0c2bbfe8913d178713c9a271ed4080973fe42d8f",
|
|
8511
9202
|
coin_list_handle: "0x49136005e90e28c4695419ed4194cc240603f1ea8eb84e62275eaff088a71063",
|
|
8512
9203
|
launchpad_pools_handle: "0x5e194a8efcf653830daf85a85b52e3ae8f65dc39481d54b2382acda25068375c",
|
|
8513
|
-
clmm_pools_handle: "0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb"
|
|
9204
|
+
clmm_pools_handle: "0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb",
|
|
9205
|
+
global_config_id: "0x4f32c00706e7bdbce532acdcfc0afd91b14defd5ffc9e2723a0ce7ed84f5d380",
|
|
9206
|
+
voter_id: "0x2e2fae39d85e991e1adad756f6723bb1aebc33140b8b16897a41171640389f88",
|
|
9207
|
+
voting_escrow_id: "0x8c300ccc0cb221feb76d0ed0820ff0873477ab1ada266129d594d539c5cd2f11",
|
|
9208
|
+
reward_distributor_id: "0x289c10f62e998a2ee58a982262732af7e329b7b689f4c81b0e16de7c6589669c",
|
|
9209
|
+
magma_token: "0x4201f44d506036666a1d9166f7a3450a80c73c551a582684cf39f2dbb3d56461::magma_token::MAGMA_TOKEN",
|
|
9210
|
+
minter_id: "0xfaf1c9b59192a3f910f28d46325dbfb3ffcc92df43d11663f3820fec8faf540b"
|
|
8514
9211
|
}
|
|
8515
9212
|
};
|
|
8516
9213
|
var clmmMainnet = {
|
|
@@ -8524,13 +9221,17 @@ var clmmMainnet = {
|
|
|
8524
9221
|
config: SDKConfig.magmaConfig
|
|
8525
9222
|
},
|
|
8526
9223
|
clmm_pool: {
|
|
8527
|
-
package_id: "
|
|
8528
|
-
published_at: "
|
|
9224
|
+
package_id: "0x0a9b94307de472ebe7c1a24ea862eb013d954c9c003a0484e045861d05b31435",
|
|
9225
|
+
published_at: "0x0a9b94307de472ebe7c1a24ea862eb013d954c9c003a0484e045861d05b31435",
|
|
8529
9226
|
config: SDKConfig.clmmConfig
|
|
8530
9227
|
},
|
|
9228
|
+
distribution: {
|
|
9229
|
+
package_id: "0x4201f44d506036666a1d9166f7a3450a80c73c551a582684cf39f2dbb3d56461",
|
|
9230
|
+
published_at: "0x5c008a2e0aee9a034b19e32bbc119cf6e7b1a0ce1316b2199cde1704d9f64f3c"
|
|
9231
|
+
},
|
|
8531
9232
|
integrate: {
|
|
8532
|
-
package_id: "
|
|
8533
|
-
published_at: "
|
|
9233
|
+
package_id: "0x01268a2afbaf91538f0b9041269fe2780273eb83b642abd4fcacad7b660a3711",
|
|
9234
|
+
published_at: "0x01268a2afbaf91538f0b9041269fe2780273eb83b642abd4fcacad7b660a3711"
|
|
8534
9235
|
},
|
|
8535
9236
|
deepbook: {
|
|
8536
9237
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
@@ -8567,34 +9268,43 @@ var SDKConfig2 = {
|
|
|
8567
9268
|
launchpad_pools_id: "0xdc3a7bd66a6dcff73c77c866e87d73826e446e9171f34e1c1b656377314f94da",
|
|
8568
9269
|
clmm_pools_id: "0x26c85500f5dd2983bf35123918a144de24e18936d0b234ef2b49fbb2d3d6307d",
|
|
8569
9270
|
admin_cap_id: "0x1a496f6c67668eb2c27c99e07e1d61754715c1acf86dac45020c886ac601edb8",
|
|
8570
|
-
global_config_id: "0xe1f3db327e75f7ec30585fa52241edf66f7e359ef550b533f89aa1528dd1be52",
|
|
8571
9271
|
coin_list_handle: "0x3204350fc603609c91675e07b8f9ac0999b9607d83845086321fca7f469de235",
|
|
8572
9272
|
launchpad_pools_handle: "0xae67ff87c34aceea4d28107f9c6c62e297a111e9f8e70b9abbc2f4c9f5ec20fd",
|
|
8573
|
-
clmm_pools_handle: "0xd28736923703342b4752f5ed8c2f2a5c0cb2336c30e1fed42b387234ce8408ec"
|
|
9273
|
+
clmm_pools_handle: "0xd28736923703342b4752f5ed8c2f2a5c0cb2336c30e1fed42b387234ce8408ec",
|
|
9274
|
+
global_config_id: "0xbbe54f3c2bd06c5ab7f93950025bff6710c9a83836d7145636fea383b315774d",
|
|
9275
|
+
voter_id: "0x59571991a5c7041c4376d980061af5c7a6d8345006d6b5167bd1f00fc17b8ddb",
|
|
9276
|
+
voting_escrow_id: "0x9081c8044719135da4ff2d52907fcd40c19e2a40750cbba4c1d6a59610ae1446",
|
|
9277
|
+
reward_distributor_id: "0xdf213d8e0ca49c8f4a508e7d3b3a6983c4aafd639f7c99479fc75fb4451d752e",
|
|
9278
|
+
magma_token: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1::magma_token::MAGMA_TOKEN",
|
|
9279
|
+
minter_id: "0x89435d6b2a510ba50ca23303f10e91ec058f138a88f69a43fe03cd22edb214c5"
|
|
8574
9280
|
}
|
|
8575
9281
|
};
|
|
8576
9282
|
var clmmTestnet = {
|
|
8577
9283
|
fullRpcUrl: (0, import_client3.getFullnodeUrl)("testnet"),
|
|
8578
|
-
simulationAccount: {
|
|
8579
|
-
address: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
8580
|
-
},
|
|
8581
|
-
faucet: {
|
|
8582
|
-
package_id: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc",
|
|
8583
|
-
published_at: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc"
|
|
8584
|
-
},
|
|
8585
9284
|
magma_config: {
|
|
8586
9285
|
package_id: "0xf5ff7d5ba73b581bca6b4b9fa0049cd320360abd154b809f8700a8fd3cfaf7ca",
|
|
8587
9286
|
published_at: "0xf5ff7d5ba73b581bca6b4b9fa0049cd320360abd154b809f8700a8fd3cfaf7ca",
|
|
8588
9287
|
config: SDKConfig2.magmaConfig
|
|
8589
9288
|
},
|
|
8590
9289
|
clmm_pool: {
|
|
8591
|
-
package_id: "
|
|
8592
|
-
published_at: "
|
|
9290
|
+
package_id: "0x23e0b5ab4aa63d0e6fd98fa5e247bcf9b36ad716b479d39e56b2ba9ff631e09d",
|
|
9291
|
+
published_at: "0x23e0b5ab4aa63d0e6fd98fa5e247bcf9b36ad716b479d39e56b2ba9ff631e09d",
|
|
8593
9292
|
config: SDKConfig2.clmmConfig
|
|
8594
9293
|
},
|
|
9294
|
+
distribution: {
|
|
9295
|
+
package_id: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1",
|
|
9296
|
+
published_at: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1"
|
|
9297
|
+
},
|
|
8595
9298
|
integrate: {
|
|
8596
|
-
package_id: "
|
|
8597
|
-
published_at: "
|
|
9299
|
+
package_id: "0x6d225cd7b90ca74b13e7de114c6eba2f844a1e5e1a4d7459048386bfff0d45df",
|
|
9300
|
+
published_at: "0x6d225cd7b90ca74b13e7de114c6eba2f844a1e5e1a4d7459048386bfff0d45df"
|
|
9301
|
+
},
|
|
9302
|
+
simulationAccount: {
|
|
9303
|
+
address: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
9304
|
+
},
|
|
9305
|
+
faucet: {
|
|
9306
|
+
package_id: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc",
|
|
9307
|
+
published_at: "0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc"
|
|
8598
9308
|
},
|
|
8599
9309
|
deepbook: {
|
|
8600
9310
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
@@ -8660,6 +9370,7 @@ var src_default = MagmaClmmSDK;
|
|
|
8660
9370
|
GAS_SYMBOL,
|
|
8661
9371
|
GAS_TYPE_ARG,
|
|
8662
9372
|
GAS_TYPE_ARG_LONG,
|
|
9373
|
+
LockModule,
|
|
8663
9374
|
MAX_SQRT_PRICE,
|
|
8664
9375
|
MAX_TICK_INDEX,
|
|
8665
9376
|
MIN_SQRT_PRICE,
|
|
@@ -8673,6 +9384,7 @@ var src_default = MagmaClmmSDK;
|
|
|
8673
9384
|
PositionModule,
|
|
8674
9385
|
PositionStatus,
|
|
8675
9386
|
PositionUtil,
|
|
9387
|
+
RewardDistributor,
|
|
8676
9388
|
RouterModule,
|
|
8677
9389
|
RouterModuleV2,
|
|
8678
9390
|
RpcModule,
|
|
@@ -8692,6 +9404,8 @@ var src_default = MagmaClmmSDK;
|
|
|
8692
9404
|
U128,
|
|
8693
9405
|
U128_MAX,
|
|
8694
9406
|
U64_MAX,
|
|
9407
|
+
Voter,
|
|
9408
|
+
VotingEscrow,
|
|
8695
9409
|
ZERO,
|
|
8696
9410
|
addHexPrefix,
|
|
8697
9411
|
adjustForCoinSlippage,
|