@magmaprotocol/magma-clmm-sdk 0.5.18 → 0.5.20

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 CHANGED
@@ -3073,6 +3073,12 @@ type AddBribeReward = {
3073
3073
  amount: string;
3074
3074
  coinType: string;
3075
3075
  };
3076
+ type LockVoteEvent = {
3077
+ lock_id: string;
3078
+ last_voted_at: string;
3079
+ pools: string[];
3080
+ votes: string[];
3081
+ };
3076
3082
  declare class LockModule implements IModule {
3077
3083
  protected _sdk: MagmaClmmSDK;
3078
3084
  constructor(sdk: MagmaClmmSDK);
@@ -3091,6 +3097,7 @@ declare class LockModule implements IModule {
3091
3097
  pokePayload(params: PokeParams): Promise<Transaction>;
3092
3098
  addBribeReward(params: AddBribeReward): Promise<Transaction>;
3093
3099
  claimVotingBribe(locks: string[], incentive_tokens: string[]): Promise<Transaction>;
3100
+ claimVotingFeeAndBribeForPool(lockId: string, poolId: string, feeTokens: string[], incentiveTokens: string[]): Promise<Transaction>;
3094
3101
  locksOfUser(user: string): Promise<LocksInfo>;
3095
3102
  aLockInfo(lockId: string): Promise<LockInfo>;
3096
3103
  aLockSummary(lock_id: string): Promise<ALockSummary>;
@@ -3098,8 +3105,12 @@ declare class LockModule implements IModule {
3098
3105
  poolWeights(pools: string[]): Promise<PoolWeight[]>;
3099
3106
  getVotingFeeRewardTokens(lock_id: string): Promise<Map<string, string[]>>;
3100
3107
  getVotingBribeRewardTokens(lock_id: string): Promise<Map<string, string[]>>;
3101
- getPoolIncentiveRewrads(incentive_tokens: string[], locksId: string): Promise<Map<string, Map<string, string>>>;
3108
+ getPoolFeeRewards(lock_id: string, tokens: string[]): Promise<Map<string, Map<string, string>>>;
3109
+ _getPoolFeeRewards(lock_id: string, token_a: string, token_b: string, poolFeeRewardTokens: Map<string, Map<string, string>>): Promise<Map<string, Map<string, string>>>;
3110
+ getPoolIncentiveRewards(lock_id: string, incentive_tokens: string[]): Promise<Map<string, Map<string, string>>>;
3111
+ _getPoolIncentiveRewards(locksId: string, incentive_tokens: string[], poolBribeRewardTokens: Map<string, Map<string, string>>): Promise<Map<string, Map<string, string>>>;
3102
3112
  getPoolBribeRewardTokens(pool_id: string): Promise<Map<string, string[]>>;
3113
+ getLockVotingStats(lockId: string): Promise<LockVoteEvent | null>;
3103
3114
  }
3104
3115
 
3105
3116
  /**
@@ -4067,4 +4078,4 @@ interface InitMagmaSDKOptions {
4067
4078
  */
4068
4079
  declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
4069
4080
 
4070
- 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, DepositPosition, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, 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, StakedPositionOfPool, 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, WithdrawPosition, 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 };
4081
+ 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, DepositPosition, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityInput, LockModule, LockPermanentParams, LockVoteEvent, 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, StakedPositionOfPool, 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, WithdrawPosition, 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
@@ -7476,6 +7476,30 @@ var LockModule = class {
7476
7476
  }
7477
7477
  return TransactionUtil.buildClaimVotingBribe(this.sdk, locks, incentive_tokens);
7478
7478
  }
7479
+ async claimVotingFeeAndBribeForPool(lockId, poolId, feeTokens, incentiveTokens) {
7480
+ if (feeTokens.length !== 2) {
7481
+ throw Error("feeTokens length must be 2");
7482
+ }
7483
+ if (incentiveTokens.length < 1 || incentiveTokens.length > 3) {
7484
+ throw Error("incentiveTokens length must be between 1 and 3");
7485
+ }
7486
+ const { integrate } = this.sdk.sdkOptions;
7487
+ const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
7488
+ const typeArguments = [magma_token, ...feeTokens, ...incentiveTokens];
7489
+ let targetFunc = `${integrate.published_at}::${Voter}::claim_voting_bribes_for_single_pool${incentiveTokens.length}`;
7490
+ if (incentiveTokens.length === 1) {
7491
+ targetFunc = `${integrate.published_at}::${Voter}::claim_voting_bribes_for_single_pool`;
7492
+ }
7493
+ const tx = new import_transactions9.Transaction();
7494
+ tx.setSender(this.sdk.senderAddress);
7495
+ const args = [tx.object(voter_id), tx.object(voting_escrow_id), tx.object(lockId), tx.object(poolId), tx.object(CLOCK_ADDRESS)];
7496
+ tx.moveCall({
7497
+ target: targetFunc,
7498
+ typeArguments,
7499
+ arguments: args
7500
+ });
7501
+ return tx;
7502
+ }
7479
7503
  async locksOfUser(user) {
7480
7504
  const locksInfo = { owner: user, lockInfo: [] };
7481
7505
  const { distribution } = this._sdk.sdkOptions;
@@ -7490,11 +7514,16 @@ var LockModule = class {
7490
7514
  const { fields } = item.data.content;
7491
7515
  const aLockSummary = await this.aLockSummary(fields.id.id);
7492
7516
  const poolIncentiveTokens = await this.getVotingBribeRewardTokens(fields.id.id);
7517
+ const poolFeeTokens = await this.getVotingFeeRewardTokens(fields.id.id);
7493
7518
  const incentiveTokens = [];
7494
7519
  poolIncentiveTokens.forEach((value, key) => {
7495
7520
  incentiveTokens.push(...value);
7496
7521
  });
7497
- const poolIncentiveRewards = await this.getPoolIncentiveRewrads(incentiveTokens, fields.id.id);
7522
+ const feeTokens = [];
7523
+ poolFeeTokens.forEach((value, key) => {
7524
+ feeTokens.push(...value);
7525
+ });
7526
+ const poolIncentiveRewards = await this.getPoolIncentiveRewards(fields.id.id, incentiveTokens);
7498
7527
  const votingRewards = /* @__PURE__ */ new Map();
7499
7528
  poolIncentiveRewards.forEach((value, coin) => {
7500
7529
  value.forEach((amount, pool) => {
@@ -7508,6 +7537,19 @@ var LockModule = class {
7508
7537
  });
7509
7538
  });
7510
7539
  });
7540
+ const poolFeeRewards = await this.getPoolFeeRewards(fields.id.id, feeTokens);
7541
+ poolFeeRewards.forEach((value, coin) => {
7542
+ value.forEach((amount, pool) => {
7543
+ if (!votingRewards.has(pool)) {
7544
+ votingRewards.set(pool, []);
7545
+ }
7546
+ votingRewards.get(pool)?.push({
7547
+ kind: "fee" /* Fee */,
7548
+ token_addr: coin,
7549
+ amount: amount.toString()
7550
+ });
7551
+ });
7552
+ });
7511
7553
  const lockInfo = {
7512
7554
  lock_id: fields.id.id,
7513
7555
  amount: fields.amount,
@@ -7520,7 +7562,7 @@ var LockModule = class {
7520
7562
  amount: aLockSummary.reward_distributor_claimable
7521
7563
  },
7522
7564
  voting_power: aLockSummary.voting_power,
7523
- // pool => incentive => amount
7565
+ // pool => incentive/fee => amount
7524
7566
  voting_rewards: votingRewards
7525
7567
  };
7526
7568
  locksInfo.lockInfo.push(lockInfo);
@@ -7528,7 +7570,6 @@ var LockModule = class {
7528
7570
  return locksInfo;
7529
7571
  }
7530
7572
  async aLockInfo(lockId) {
7531
- const aLockSummary = await this.aLockSummary(lockId);
7532
7573
  const lockObj = await this._sdk.fullClient.getObject({
7533
7574
  id: lockId,
7534
7575
  options: {
@@ -7540,13 +7581,25 @@ var LockModule = class {
7540
7581
  showType: true
7541
7582
  }
7542
7583
  });
7584
+ if (lockObj.error != null || lockObj.data?.content?.dataType !== "moveObject") {
7585
+ throw new ClmmpoolsError(
7586
+ `getPool error code: ${lockObj.error?.code ?? "unknown error"}, please check config and object id`,
7587
+ "InvalidLockObject" /* InvalidLockObject */
7588
+ );
7589
+ }
7543
7590
  const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
7591
+ const aLockSummary = await this.aLockSummary(lockId);
7544
7592
  const poolIncentiveTokens = await this.getVotingBribeRewardTokens(lockId);
7593
+ const poolFeeTokens = await this.getVotingFeeRewardTokens(lockId);
7545
7594
  const incentiveTokens = [];
7546
7595
  poolIncentiveTokens.forEach((value, key) => {
7547
7596
  incentiveTokens.push(...value);
7548
7597
  });
7549
- const poolIncentiveRewards = await this.getPoolIncentiveRewrads(incentiveTokens, lockId);
7598
+ const feeTokens = [];
7599
+ poolFeeTokens.forEach((value, key) => {
7600
+ feeTokens.push(...value);
7601
+ });
7602
+ const poolIncentiveRewards = await this.getPoolIncentiveRewards(lockId, incentiveTokens);
7550
7603
  const votingRewards = /* @__PURE__ */ new Map();
7551
7604
  poolIncentiveRewards.forEach((value, coin) => {
7552
7605
  value.forEach((amount, pool) => {
@@ -7560,12 +7613,19 @@ var LockModule = class {
7560
7613
  });
7561
7614
  });
7562
7615
  });
7563
- if (lockObj.error != null || lockObj.data?.content?.dataType !== "moveObject") {
7564
- throw new ClmmpoolsError(
7565
- `getPool error code: ${lockObj.error?.code ?? "unknown error"}, please check config and object id`,
7566
- "InvalidLockObject" /* InvalidLockObject */
7567
- );
7568
- }
7616
+ const poolFeeRewards = await this.getPoolFeeRewards(lockId, feeTokens);
7617
+ poolFeeRewards.forEach((value, coin) => {
7618
+ value.forEach((amount, pool) => {
7619
+ if (!votingRewards.has(pool)) {
7620
+ votingRewards.set(pool, []);
7621
+ }
7622
+ votingRewards.get(pool)?.push({
7623
+ kind: "fee" /* Fee */,
7624
+ token_addr: coin,
7625
+ amount: amount.toString()
7626
+ });
7627
+ });
7628
+ });
7569
7629
  const fields = getObjectFields(lockObj);
7570
7630
  const lockInfo = {
7571
7631
  lock_id: lockId,
@@ -7780,11 +7840,72 @@ var LockModule = class {
7780
7840
  });
7781
7841
  return poolBirbeRewardTokens;
7782
7842
  }
7783
- // tokenId => pool => incentive_tokens
7784
- async getPoolIncentiveRewrads(incentive_tokens, locksId) {
7785
- const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
7843
+ async getPoolFeeRewards(lock_id, tokens) {
7844
+ const poolFeeRewardTokens = /* @__PURE__ */ new Map();
7845
+ if (tokens.length === 0) {
7846
+ return poolFeeRewardTokens;
7847
+ }
7848
+ if (tokens.length % 2 !== 0) {
7849
+ tokens.push(tokens[0]);
7850
+ }
7851
+ for (let i = 0; i + 1 < tokens.length; i += 2) {
7852
+ await this._getPoolFeeRewards(lock_id, tokens[i], tokens[i + 1], poolFeeRewardTokens);
7853
+ }
7854
+ return poolFeeRewardTokens;
7855
+ }
7856
+ // if you have many tokens, call this function multi times
7857
+ async _getPoolFeeRewards(lock_id, token_a, token_b, poolFeeRewardTokens) {
7858
+ const tx = new import_transactions9.Transaction();
7859
+ const { integrate, simulationAccount } = this.sdk.sdkOptions;
7860
+ const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
7861
+ const typeArguments = [magma_token, token_a, token_b];
7862
+ const args = [tx.object(voter_id), tx.object(lock_id), tx.object(CLOCK_ADDRESS)];
7863
+ const targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_fee_rewards`;
7864
+ tx.moveCall({
7865
+ target: targetFunc,
7866
+ arguments: args,
7867
+ typeArguments
7868
+ });
7869
+ if (!checkInvalidSuiAddress(simulationAccount.address)) {
7870
+ throw Error("this config simulationAccount is not set right");
7871
+ }
7872
+ const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
7873
+ transactionBlock: tx,
7874
+ sender: simulationAccount.address
7875
+ });
7876
+ if (simulateRes.error != null) {
7877
+ throw new Error(`getPoolFeeRewards error code: ${simulateRes.error ?? "unknown error"}`);
7878
+ }
7879
+ simulateRes.events?.forEach((item) => {
7880
+ if (extractStructTagFromType(item.type).name === `ClaimableVotingFee`) {
7881
+ item.parsedJson.data.contents.forEach((rewardTokens) => {
7882
+ if (!poolFeeRewardTokens.has(rewardTokens.key.name)) {
7883
+ poolFeeRewardTokens.set(rewardTokens.key.name, /* @__PURE__ */ new Map());
7884
+ }
7885
+ rewardTokens.value.contents.forEach((token) => {
7886
+ poolFeeRewardTokens.get(rewardTokens.key.name)?.set(token.key, token.value);
7887
+ });
7888
+ });
7889
+ }
7890
+ });
7891
+ return poolFeeRewardTokens;
7892
+ }
7893
+ async getPoolIncentiveRewards(lock_id, incentive_tokens) {
7894
+ const poolBribeRewardTokens = /* @__PURE__ */ new Map();
7786
7895
  if (incentive_tokens.length === 0) {
7787
- return poolBirbeRewardTokens;
7896
+ return poolBribeRewardTokens;
7897
+ }
7898
+ let i = 0;
7899
+ for (; i + 3 < incentive_tokens.length; i += 3) {
7900
+ await this._getPoolIncentiveRewards(lock_id, incentive_tokens.slice(i, i + 3), poolBribeRewardTokens);
7901
+ }
7902
+ await this._getPoolIncentiveRewards(lock_id, incentive_tokens.slice(i), poolBribeRewardTokens);
7903
+ return poolBribeRewardTokens;
7904
+ }
7905
+ // tokenId => pool => incentive_tokens
7906
+ async _getPoolIncentiveRewards(locksId, incentive_tokens, poolBribeRewardTokens) {
7907
+ if (incentive_tokens.length > 3) {
7908
+ throw Error("Too many tokens");
7788
7909
  }
7789
7910
  const tx = new import_transactions9.Transaction();
7790
7911
  const { integrate, simulationAccount } = this.sdk.sdkOptions;
@@ -7808,21 +7929,21 @@ var LockModule = class {
7808
7929
  sender: simulationAccount.address
7809
7930
  });
7810
7931
  if (simulateRes.error != null) {
7811
- throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
7932
+ throw new Error(`getPoolIncentiveRewards error code: ${simulateRes.error ?? "unknown error"}`);
7812
7933
  }
7813
7934
  simulateRes.events?.forEach((item) => {
7814
7935
  if (extractStructTagFromType(item.type).name === `ClaimableVotingBribes`) {
7815
7936
  item.parsedJson.data.contents.forEach((rewardTokens) => {
7816
- if (!poolBirbeRewardTokens.has(rewardTokens.key.name)) {
7817
- poolBirbeRewardTokens.set(rewardTokens.key.name, /* @__PURE__ */ new Map());
7937
+ if (!poolBribeRewardTokens.has(rewardTokens.key.name)) {
7938
+ poolBribeRewardTokens.set(rewardTokens.key.name, /* @__PURE__ */ new Map());
7818
7939
  }
7819
7940
  rewardTokens.value.contents.forEach((token) => {
7820
- poolBirbeRewardTokens.get(rewardTokens.key.name)?.set(token.key, token.value);
7941
+ poolBribeRewardTokens.get(rewardTokens.key.name)?.set(token.key, token.value);
7821
7942
  });
7822
7943
  });
7823
7944
  }
7824
7945
  });
7825
- return poolBirbeRewardTokens;
7946
+ return poolBribeRewardTokens;
7826
7947
  }
7827
7948
  async getPoolBribeRewardTokens(pool_id) {
7828
7949
  const tx = new import_transactions9.Transaction();
@@ -7860,6 +7981,46 @@ var LockModule = class {
7860
7981
  });
7861
7982
  return poolBirbeRewardTokens;
7862
7983
  }
7984
+ async getLockVotingStats(lockId) {
7985
+ const tx = new import_transactions9.Transaction();
7986
+ const { integrate, simulationAccount } = this.sdk.sdkOptions;
7987
+ const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
7988
+ const args = [tx.object(voter_id), tx.object(lockId), tx.object(CLOCK_ADDRESS)];
7989
+ const typeArguments = [magma_token];
7990
+ tx.moveCall({
7991
+ target: `${integrate.published_at}::${Voter}::lock_voting_stats`,
7992
+ arguments: args,
7993
+ typeArguments
7994
+ });
7995
+ if (!checkInvalidSuiAddress(simulationAccount.address)) {
7996
+ throw Error("this config simulationAccount is not set right");
7997
+ }
7998
+ const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
7999
+ transactionBlock: tx,
8000
+ sender: simulationAccount.address
8001
+ });
8002
+ if (simulateRes.error != null) {
8003
+ console.log(`error code: ${simulateRes.error ?? "unknown error"}`);
8004
+ return null;
8005
+ }
8006
+ let res = {
8007
+ lock_id: lockId,
8008
+ last_voted_at: "",
8009
+ pools: [],
8010
+ votes: []
8011
+ };
8012
+ simulateRes.events?.forEach((item) => {
8013
+ if (extractStructTagFromType(item.type).name === `EventLockVotingStats`) {
8014
+ res = {
8015
+ lock_id: item.parsedJson.lock_id,
8016
+ last_voted_at: item.parsedJson.last_voted_at,
8017
+ pools: item.parsedJson.pools,
8018
+ votes: item.parsedJson.votes
8019
+ };
8020
+ }
8021
+ });
8022
+ return res;
8023
+ }
7863
8024
  };
7864
8025
 
7865
8026
  // src/modules/tokenModule.ts
@@ -9722,12 +9883,12 @@ var SDKConfig = {
9722
9883
  launchpad_pools_handle: "0x5e194a8efcf653830daf85a85b52e3ae8f65dc39481d54b2382acda25068375c",
9723
9884
  clmm_pools_handle: "0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb",
9724
9885
  global_config_id: "0x4f32c00706e7bdbce532acdcfc0afd91b14defd5ffc9e2723a0ce7ed84f5d380",
9725
- voter_id: "0xe8e0c266602404caa463f85bee4ccf6000c8c2566204a3949400a06857295ceb",
9726
- voting_escrow_id: "0x143aab8c7c13c58a94d99ae281b4226f1877abc21bc01b9d75b58a7217fc3b2c",
9727
- reward_distributor_id: "0x93bf24d3db08f93a02ba90abc7095f8d8086e5a1f72bac8bd866df21defe83ab",
9728
- distribution_cfg: "0x94e23846c975e2faf89a61bfc2b10ad64decab9069eb1f9fc39752b010868c74",
9729
- magma_token: "0x3abcdefce1a0ec1252237b69efc6dc3881325d543fceaad2e2f360a02d2f5bd9::magma_token::MAGMA_TOKEN",
9730
- minter_id: "0x92877b638c3febf8576d0d7caebf9a2c43753b2e441669fb434e709458ece345"
9886
+ voter_id: "0xaab0f3a90da96d29d743e09c269e1ae48ec1bae52a28cd38c49c5dc8c1bf92b8",
9887
+ voting_escrow_id: "0x7ab45fbe01da26e07ba21757916d540c8747cf7daa88f3171e13db17373d5adc",
9888
+ reward_distributor_id: "0x9f4f882245e49fd9213278dfbcb63a14fdbdd2ce7e25e9353a0cecdca30de853",
9889
+ distribution_cfg: "0xaff8d151ac29317201151f97d28c546b3c5923d8cfc5499f40dea61c4022c949",
9890
+ magma_token: "0x7161c6c6bb65f852797c8f7f5c4f8d57adaf796e1b840921f9e23fabeadfd54e::magma::MAGMA",
9891
+ minter_id: "0x4fa5766cd83b33b215b139fec27ac344040f3bbd84fcbee7b61fc671aadc51fa"
9731
9892
  }
9732
9893
  };
9733
9894
  var clmmMainnet = {
@@ -9746,12 +9907,12 @@ var clmmMainnet = {
9746
9907
  config: SDKConfig.clmmConfig
9747
9908
  },
9748
9909
  distribution: {
9749
- package_id: "0x3abcdefce1a0ec1252237b69efc6dc3881325d543fceaad2e2f360a02d2f5bd9",
9750
- published_at: "0x3abcdefce1a0ec1252237b69efc6dc3881325d543fceaad2e2f360a02d2f5bd9"
9910
+ package_id: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b",
9911
+ published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
9751
9912
  },
9752
9913
  integrate: {
9753
- package_id: "0x6e3ae31a16362c563c0fef5293348d262646882a10c307f20f6be8577960f1ef",
9754
- published_at: "0xba2255e57f407e1e171f0bacd54d9e743bb12e3e9bb9d51a41a362749b9e51c2"
9914
+ package_id: "0xc08328e57f004fdd16a38c62df1eaba2be4db74fb9680986cd911460692aaf67",
9915
+ published_at: "0xc08328e57f004fdd16a38c62df1eaba2be4db74fb9680986cd911460692aaf67"
9755
9916
  },
9756
9917
  deepbook: {
9757
9918
  package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",