@magmaprotocol/magma-clmm-sdk 0.5.8 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +41 -1
- package/dist/index.js +206 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ declare const ClmmIntegrateUtilsModule = "utils";
|
|
|
35
35
|
declare const VotingEscrow = "voting_escrow";
|
|
36
36
|
declare const Voter = "voter";
|
|
37
37
|
declare const RewardDistributor = "reward_distributor";
|
|
38
|
+
declare const Gauge = "gauge";
|
|
39
|
+
declare const Minter = "minter";
|
|
38
40
|
/**
|
|
39
41
|
* The address for CoinInfo module.
|
|
40
42
|
*/
|
|
@@ -3028,6 +3030,10 @@ type ALockSummary = {
|
|
|
3028
3030
|
reward_distributor_claimable: string;
|
|
3029
3031
|
voting_power: string;
|
|
3030
3032
|
};
|
|
3033
|
+
type AddBribeReward = {
|
|
3034
|
+
amount: string;
|
|
3035
|
+
coinType: string;
|
|
3036
|
+
};
|
|
3031
3037
|
declare class LockModule implements IModule {
|
|
3032
3038
|
protected _sdk: MagmaClmmSDK;
|
|
3033
3039
|
constructor(sdk: MagmaClmmSDK);
|
|
@@ -3044,6 +3050,7 @@ declare class LockModule implements IModule {
|
|
|
3044
3050
|
claimVotingRewardsPoolsPayload(params: ClaimFeesPoolsParams): Promise<Transaction>;
|
|
3045
3051
|
claimAndLockRebasesPayload(params: ClaimAndLockParams): Promise<Transaction>;
|
|
3046
3052
|
pokePayload(params: PokeParams): Promise<Transaction>;
|
|
3053
|
+
addBribeReward(params: AddBribeReward): Promise<Transaction>;
|
|
3047
3054
|
claimVotingBribe(locks: string[], incentive_tokens: string[]): Promise<Transaction>;
|
|
3048
3055
|
locksOfUser(user: string): Promise<LocksInfo>;
|
|
3049
3056
|
aLockInfo(lockId: string): Promise<LockInfo>;
|
|
@@ -3281,6 +3288,37 @@ declare class RpcModule extends SuiClient {
|
|
|
3281
3288
|
sendSimulationTransaction(tx: Transaction, simulationAccount: string, useDevInspect?: boolean): Promise<DevInspectResults | undefined>;
|
|
3282
3289
|
}
|
|
3283
3290
|
|
|
3291
|
+
type DepositPosition = {
|
|
3292
|
+
poolId: string;
|
|
3293
|
+
positionId: string;
|
|
3294
|
+
coinTypeA: string;
|
|
3295
|
+
coinTypeB: string;
|
|
3296
|
+
};
|
|
3297
|
+
type WithdrawPosition = {
|
|
3298
|
+
poolId: string;
|
|
3299
|
+
positionId: string;
|
|
3300
|
+
coinTypeA: string;
|
|
3301
|
+
coinTypeB: string;
|
|
3302
|
+
};
|
|
3303
|
+
type EpochEmission = {
|
|
3304
|
+
emission: number | string;
|
|
3305
|
+
rebase: number | string;
|
|
3306
|
+
total_supply: number | string;
|
|
3307
|
+
total_locked: number | string;
|
|
3308
|
+
};
|
|
3309
|
+
declare class GaugeModule implements IModule {
|
|
3310
|
+
protected _sdk: MagmaClmmSDK;
|
|
3311
|
+
constructor(sdk: MagmaClmmSDK);
|
|
3312
|
+
get sdk(): MagmaClmmSDK;
|
|
3313
|
+
depositPosition(params: DepositPosition): Promise<Transaction>;
|
|
3314
|
+
withdrawPosition(params: WithdrawPosition): Promise<Transaction>;
|
|
3315
|
+
getUserStakedPositionInfo(userAddr: string): Promise<any[]>;
|
|
3316
|
+
getUserStakedPositionInfoOfPool(userAddr: string, pool: string, gauger: string, poolCoinA: string, poolCoinB: string): Promise<any[]>;
|
|
3317
|
+
getPoolGaguers(): Promise<Map<string, string>>;
|
|
3318
|
+
getPoolCoins(pools: string[]): Promise<Map<string, string[]>>;
|
|
3319
|
+
getEmissions(): Promise<EpochEmission>;
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3284
3322
|
/**
|
|
3285
3323
|
* Represents options and configurations for an SDK.
|
|
3286
3324
|
*/
|
|
@@ -3365,6 +3403,7 @@ declare class MagmaClmmSDK {
|
|
|
3365
3403
|
* Provide interact with a lock interface.
|
|
3366
3404
|
*/
|
|
3367
3405
|
protected _lock: LockModule;
|
|
3406
|
+
protected _gauge: GaugeModule;
|
|
3368
3407
|
/**
|
|
3369
3408
|
* Provide interact with a position rewarder interface.
|
|
3370
3409
|
*/
|
|
@@ -3411,6 +3450,7 @@ declare class MagmaClmmSDK {
|
|
|
3411
3450
|
*/
|
|
3412
3451
|
get Swap(): SwapModule;
|
|
3413
3452
|
get Lock(): LockModule;
|
|
3453
|
+
get Gauge(): GaugeModule;
|
|
3414
3454
|
/**
|
|
3415
3455
|
* Getter for the fullClient property.
|
|
3416
3456
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -4004,4 +4044,4 @@ interface InitMagmaSDKOptions {
|
|
|
4004
4044
|
*/
|
|
4005
4045
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4006
4046
|
|
|
4007
|
-
export { AMM_SWAP_MODULE, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityInput, LockModule, LockPermanentParams, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16 };
|
|
4047
|
+
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityInput, LockModule, LockPermanentParams, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, Minter, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16 };
|
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
|
+
Gauge: () => Gauge,
|
|
71
72
|
LockModule: () => LockModule,
|
|
72
73
|
MAX_SQRT_PRICE: () => MAX_SQRT_PRICE,
|
|
73
74
|
MAX_TICK_INDEX: () => MAX_TICK_INDEX,
|
|
@@ -75,6 +76,7 @@ __export(src_exports, {
|
|
|
75
76
|
MIN_TICK_INDEX: () => MIN_TICK_INDEX,
|
|
76
77
|
MagmaClmmSDK: () => MagmaClmmSDK,
|
|
77
78
|
MathUtil: () => MathUtil,
|
|
79
|
+
Minter: () => Minter,
|
|
78
80
|
ONE: () => ONE,
|
|
79
81
|
POOL_STRUCT: () => POOL_STRUCT,
|
|
80
82
|
Percentage: () => Percentage,
|
|
@@ -504,6 +506,8 @@ var ClmmIntegrateUtilsModule = "utils";
|
|
|
504
506
|
var VotingEscrow = "voting_escrow";
|
|
505
507
|
var Voter = "voter";
|
|
506
508
|
var RewardDistributor = "reward_distributor";
|
|
509
|
+
var Gauge = "gauge";
|
|
510
|
+
var Minter = "minter";
|
|
507
511
|
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
508
512
|
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
509
513
|
var DeepbookCustodianV2Moudle = "custodian_v2";
|
|
@@ -3217,7 +3221,6 @@ var _TransactionUtil = class {
|
|
|
3217
3221
|
static buildVoteTransaction(sdk, params) {
|
|
3218
3222
|
const tx = new import_transactions.Transaction();
|
|
3219
3223
|
tx.setSender(sdk.senderAddress);
|
|
3220
|
-
tx.setGasBudget(1e8);
|
|
3221
3224
|
const { integrate } = sdk.sdkOptions;
|
|
3222
3225
|
const { distribution_cfg, voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3223
3226
|
const typeArguments = [magma_token];
|
|
@@ -7448,6 +7451,25 @@ var LockModule = class {
|
|
|
7448
7451
|
}
|
|
7449
7452
|
return TransactionUtil.buildPoke(this.sdk, params);
|
|
7450
7453
|
}
|
|
7454
|
+
async addBribeReward(params) {
|
|
7455
|
+
if (this._sdk.senderAddress.length === 0) {
|
|
7456
|
+
throw Error("this config sdk senderAddress is empty");
|
|
7457
|
+
}
|
|
7458
|
+
const tx = new import_transactions9.Transaction();
|
|
7459
|
+
tx.setSender(this.sdk.senderAddress);
|
|
7460
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
7461
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7462
|
+
const typeArguments = [magma_token, params.coinType];
|
|
7463
|
+
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
7464
|
+
const coinInput = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(params.amount), params.coinType, false, true);
|
|
7465
|
+
const args = [tx.object(voter_id), coinInput.targetCoin, tx.object(CLOCK_ADDRESS)];
|
|
7466
|
+
tx.moveCall({
|
|
7467
|
+
target: `${integrate.published_at}::${Voter}::add_bribe_reward`,
|
|
7468
|
+
typeArguments,
|
|
7469
|
+
arguments: args
|
|
7470
|
+
});
|
|
7471
|
+
return tx;
|
|
7472
|
+
}
|
|
7451
7473
|
async claimVotingBribe(locks, incentive_tokens) {
|
|
7452
7474
|
if (this._sdk.senderAddress.length === 0) {
|
|
7453
7475
|
throw Error("this config sdk senderAddress is empty");
|
|
@@ -7692,14 +7714,14 @@ var LockModule = class {
|
|
|
7692
7714
|
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7693
7715
|
const typeArguments = [magma_token];
|
|
7694
7716
|
const args = [tx.object(voter_id), tx.object(lock_id)];
|
|
7717
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7718
|
+
throw Error("this config simulationAccount is not set right");
|
|
7719
|
+
}
|
|
7695
7720
|
tx.moveCall({
|
|
7696
7721
|
target: `${integrate.published_at}::${Voter}::get_voting_fee_reward_tokens`,
|
|
7697
7722
|
arguments: args,
|
|
7698
7723
|
typeArguments
|
|
7699
7724
|
});
|
|
7700
|
-
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7701
|
-
throw Error("this config simulationAccount is not set right");
|
|
7702
|
-
}
|
|
7703
7725
|
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7704
7726
|
transactionBlock: tx,
|
|
7705
7727
|
sender: simulationAccount.address
|
|
@@ -9184,6 +9206,178 @@ var RpcModule = class extends import_client.SuiClient {
|
|
|
9184
9206
|
}
|
|
9185
9207
|
};
|
|
9186
9208
|
|
|
9209
|
+
// src/modules/gauge.ts
|
|
9210
|
+
var import_transactions11 = require("@mysten/sui/transactions");
|
|
9211
|
+
var GaugeModule = class {
|
|
9212
|
+
_sdk;
|
|
9213
|
+
constructor(sdk) {
|
|
9214
|
+
this._sdk = sdk;
|
|
9215
|
+
}
|
|
9216
|
+
get sdk() {
|
|
9217
|
+
return this._sdk;
|
|
9218
|
+
}
|
|
9219
|
+
async depositPosition(params) {
|
|
9220
|
+
const tx = new import_transactions11.Transaction();
|
|
9221
|
+
tx.setSender(this.sdk.senderAddress);
|
|
9222
|
+
const poolGauge = await this.getPoolGaguers();
|
|
9223
|
+
const gauge = poolGauge.get(params.poolId);
|
|
9224
|
+
if (gauge === void 0) {
|
|
9225
|
+
throw Error(`Fetch gauge of pool ${params.poolId} failed`);
|
|
9226
|
+
}
|
|
9227
|
+
const { distribution_cfg, magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
9228
|
+
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
9229
|
+
const clmmConfig = getPackagerConfigs(clmm_pool);
|
|
9230
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB, magma_token];
|
|
9231
|
+
const args = [
|
|
9232
|
+
tx.object(clmmConfig.global_config_id),
|
|
9233
|
+
tx.object(distribution_cfg),
|
|
9234
|
+
tx.object(gauge),
|
|
9235
|
+
tx.object(params.poolId),
|
|
9236
|
+
tx.object(params.positionId),
|
|
9237
|
+
tx.object(CLOCK_ADDRESS)
|
|
9238
|
+
];
|
|
9239
|
+
tx.moveCall({
|
|
9240
|
+
target: `${integrate.published_at}::${Gauge}::deposit_position`,
|
|
9241
|
+
typeArguments,
|
|
9242
|
+
arguments: args
|
|
9243
|
+
});
|
|
9244
|
+
return tx;
|
|
9245
|
+
}
|
|
9246
|
+
async withdrawPosition(params) {
|
|
9247
|
+
const tx = new import_transactions11.Transaction();
|
|
9248
|
+
tx.setSender(this.sdk.senderAddress);
|
|
9249
|
+
const poolGauge = await this.sdk.Gauge.getPoolGaguers();
|
|
9250
|
+
const gauge = poolGauge.get(params.poolId);
|
|
9251
|
+
if (gauge === void 0) {
|
|
9252
|
+
throw Error(`Fetch gauge of pool ${params.poolId} failed`);
|
|
9253
|
+
}
|
|
9254
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
9255
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
9256
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB, magma_token];
|
|
9257
|
+
const args = [tx.object(gauge), tx.object(params.poolId), tx.object(params.positionId), tx.object(CLOCK_ADDRESS)];
|
|
9258
|
+
tx.moveCall({
|
|
9259
|
+
target: `${integrate.published_at}::${Gauge}::withdraw_position`,
|
|
9260
|
+
typeArguments,
|
|
9261
|
+
arguments: args
|
|
9262
|
+
});
|
|
9263
|
+
return tx;
|
|
9264
|
+
}
|
|
9265
|
+
async getUserStakedPositionInfo(userAddr) {
|
|
9266
|
+
const poolGauger = await this.getPoolGaguers();
|
|
9267
|
+
const poolCoins = await this.getPoolCoins([...poolGauger.keys()]);
|
|
9268
|
+
const res = [];
|
|
9269
|
+
for (const [pool, gauger] of poolGauger) {
|
|
9270
|
+
const coins = poolCoins.get(pool);
|
|
9271
|
+
if (coins === void 0) {
|
|
9272
|
+
console.log(`Failed to get coins of pool: ${pool}`);
|
|
9273
|
+
continue;
|
|
9274
|
+
}
|
|
9275
|
+
const stakedPositionOfPool = await this.getUserStakedPositionInfoOfPool(userAddr, pool, gauger, coins[0], coins[1]);
|
|
9276
|
+
res.push(...stakedPositionOfPool);
|
|
9277
|
+
}
|
|
9278
|
+
return res;
|
|
9279
|
+
}
|
|
9280
|
+
async getUserStakedPositionInfoOfPool(userAddr, pool, gauger, poolCoinA, poolCoinB) {
|
|
9281
|
+
const tx = new import_transactions11.Transaction();
|
|
9282
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
9283
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
9284
|
+
const typeArguments = [magma_token, poolCoinA, poolCoinB];
|
|
9285
|
+
const args = [tx.object(voter_id), tx.object(gauger), tx.object(pool), tx.pure.address(userAddr), tx.object(CLOCK_ADDRESS)];
|
|
9286
|
+
tx.moveCall({
|
|
9287
|
+
target: `${integrate.published_at}::${Gauge}::user_staked_position_infos`,
|
|
9288
|
+
arguments: args,
|
|
9289
|
+
typeArguments
|
|
9290
|
+
});
|
|
9291
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
9292
|
+
transactionBlock: tx,
|
|
9293
|
+
sender: simulationAccount.address
|
|
9294
|
+
});
|
|
9295
|
+
if (simulateRes.error != null) {
|
|
9296
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
9297
|
+
}
|
|
9298
|
+
const res = [];
|
|
9299
|
+
simulateRes.events?.forEach((item) => {
|
|
9300
|
+
res.push(item.parsedJson);
|
|
9301
|
+
});
|
|
9302
|
+
return res;
|
|
9303
|
+
}
|
|
9304
|
+
async getPoolGaguers() {
|
|
9305
|
+
const tx = new import_transactions11.Transaction();
|
|
9306
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
9307
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
9308
|
+
const typeArguments = [magma_token];
|
|
9309
|
+
const args = [tx.object(voter_id)];
|
|
9310
|
+
tx.moveCall({
|
|
9311
|
+
target: `${integrate.published_at}::${Voter}::pools_gauges`,
|
|
9312
|
+
arguments: args,
|
|
9313
|
+
typeArguments
|
|
9314
|
+
});
|
|
9315
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
9316
|
+
transactionBlock: tx,
|
|
9317
|
+
sender: simulationAccount.address
|
|
9318
|
+
});
|
|
9319
|
+
if (simulateRes.error != null) {
|
|
9320
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
9321
|
+
}
|
|
9322
|
+
const poolGauger = /* @__PURE__ */ new Map();
|
|
9323
|
+
simulateRes.events?.forEach((item) => {
|
|
9324
|
+
const { gauges } = item.parsedJson;
|
|
9325
|
+
console.log("parsedJson", item.parsedJson);
|
|
9326
|
+
item.parsedJson.pools.map((pool, index) => {
|
|
9327
|
+
poolGauger.set(pool, gauges[index]);
|
|
9328
|
+
});
|
|
9329
|
+
});
|
|
9330
|
+
return poolGauger;
|
|
9331
|
+
}
|
|
9332
|
+
async getPoolCoins(pools) {
|
|
9333
|
+
const res = await this._sdk.fullClient.multiGetObjects({ ids: pools, options: { showContent: true } });
|
|
9334
|
+
const poolCoins = /* @__PURE__ */ new Map();
|
|
9335
|
+
res.forEach((item) => {
|
|
9336
|
+
if (item.error != null || item.data?.content?.dataType !== "moveObject") {
|
|
9337
|
+
throw new Error(`Failed to get poolCoins with err: ${item.error}`);
|
|
9338
|
+
}
|
|
9339
|
+
const type = getObjectType(item);
|
|
9340
|
+
const poolTypeFields = extractStructTagFromType(type);
|
|
9341
|
+
poolCoins.set(poolTypeFields.address, poolTypeFields.type_arguments);
|
|
9342
|
+
});
|
|
9343
|
+
return poolCoins;
|
|
9344
|
+
}
|
|
9345
|
+
async getEmissions() {
|
|
9346
|
+
const tx = new import_transactions11.Transaction();
|
|
9347
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
9348
|
+
const { magma_token, minter_id, voting_escrow_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
9349
|
+
const typeArguments = [magma_token];
|
|
9350
|
+
const args = [tx.object(minter_id), tx.object(voting_escrow_id)];
|
|
9351
|
+
tx.moveCall({
|
|
9352
|
+
target: `${integrate.published_at}::${Minter}::emissions`,
|
|
9353
|
+
arguments: args,
|
|
9354
|
+
typeArguments
|
|
9355
|
+
});
|
|
9356
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
9357
|
+
transactionBlock: tx,
|
|
9358
|
+
sender: simulationAccount.address
|
|
9359
|
+
});
|
|
9360
|
+
if (simulateRes.error != null) {
|
|
9361
|
+
throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
|
|
9362
|
+
}
|
|
9363
|
+
let res = {
|
|
9364
|
+
emission: 0,
|
|
9365
|
+
rebase: 0,
|
|
9366
|
+
total_supply: 0,
|
|
9367
|
+
total_locked: 0
|
|
9368
|
+
};
|
|
9369
|
+
simulateRes.events?.forEach((item) => {
|
|
9370
|
+
res = {
|
|
9371
|
+
emission: item.parsedJson.emission,
|
|
9372
|
+
rebase: item.parsedJson.rebase,
|
|
9373
|
+
total_supply: item.parsedJson.total_supply,
|
|
9374
|
+
total_locked: item.parsedJson.total_locked
|
|
9375
|
+
};
|
|
9376
|
+
});
|
|
9377
|
+
return res;
|
|
9378
|
+
}
|
|
9379
|
+
};
|
|
9380
|
+
|
|
9187
9381
|
// src/sdk.ts
|
|
9188
9382
|
var MagmaClmmSDK = class {
|
|
9189
9383
|
_cache = {};
|
|
@@ -9207,6 +9401,7 @@ var MagmaClmmSDK = class {
|
|
|
9207
9401
|
* Provide interact with a lock interface.
|
|
9208
9402
|
*/
|
|
9209
9403
|
_lock;
|
|
9404
|
+
_gauge;
|
|
9210
9405
|
/**
|
|
9211
9406
|
* Provide interact with a position rewarder interface.
|
|
9212
9407
|
*/
|
|
@@ -9243,6 +9438,7 @@ var MagmaClmmSDK = class {
|
|
|
9243
9438
|
});
|
|
9244
9439
|
this._swap = new SwapModule(this);
|
|
9245
9440
|
this._lock = new LockModule(this);
|
|
9441
|
+
this._gauge = new GaugeModule(this);
|
|
9246
9442
|
this._pool = new PoolModule(this);
|
|
9247
9443
|
this._position = new PositionModule(this);
|
|
9248
9444
|
this._rewarder = new RewarderModule(this);
|
|
@@ -9277,6 +9473,9 @@ var MagmaClmmSDK = class {
|
|
|
9277
9473
|
get Lock() {
|
|
9278
9474
|
return this._lock;
|
|
9279
9475
|
}
|
|
9476
|
+
get Gauge() {
|
|
9477
|
+
return this._gauge;
|
|
9478
|
+
}
|
|
9280
9479
|
/**
|
|
9281
9480
|
* Getter for the fullClient property.
|
|
9282
9481
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -9492,7 +9691,7 @@ var clmmMainnet = {
|
|
|
9492
9691
|
},
|
|
9493
9692
|
integrate: {
|
|
9494
9693
|
package_id: "0x6e3ae31a16362c563c0fef5293348d262646882a10c307f20f6be8577960f1ef",
|
|
9495
|
-
published_at: "
|
|
9694
|
+
published_at: "0xba2255e57f407e1e171f0bacd54d9e743bb12e3e9bb9d51a41a362749b9e51c2"
|
|
9496
9695
|
},
|
|
9497
9696
|
deepbook: {
|
|
9498
9697
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
@@ -9632,6 +9831,7 @@ var src_default = MagmaClmmSDK;
|
|
|
9632
9831
|
GAS_SYMBOL,
|
|
9633
9832
|
GAS_TYPE_ARG,
|
|
9634
9833
|
GAS_TYPE_ARG_LONG,
|
|
9834
|
+
Gauge,
|
|
9635
9835
|
LockModule,
|
|
9636
9836
|
MAX_SQRT_PRICE,
|
|
9637
9837
|
MAX_TICK_INDEX,
|
|
@@ -9639,6 +9839,7 @@ var src_default = MagmaClmmSDK;
|
|
|
9639
9839
|
MIN_TICK_INDEX,
|
|
9640
9840
|
MagmaClmmSDK,
|
|
9641
9841
|
MathUtil,
|
|
9842
|
+
Minter,
|
|
9642
9843
|
ONE,
|
|
9643
9844
|
POOL_STRUCT,
|
|
9644
9845
|
Percentage,
|