@magmaprotocol/magma-clmm-sdk 0.5.16 → 0.5.18

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
@@ -1590,6 +1590,44 @@ type PokeParams = {
1590
1590
  lockId: SuiObjectIdType;
1591
1591
  };
1592
1592
 
1593
+ type DepositPosition = {
1594
+ poolId: string;
1595
+ positionId: string;
1596
+ coinTypeA: string;
1597
+ coinTypeB: string;
1598
+ };
1599
+ type WithdrawPosition = {
1600
+ poolId: string;
1601
+ positionId: string;
1602
+ coinTypeA: string;
1603
+ coinTypeB: string;
1604
+ };
1605
+ type EpochEmission = {
1606
+ emission: number | string;
1607
+ rebase: number | string;
1608
+ total_supply: number | string;
1609
+ total_locked: number | string;
1610
+ };
1611
+ type StakedPositionOfPool = {
1612
+ coin_type_a: string;
1613
+ coin_type_b: string;
1614
+ liquidity: string;
1615
+ tick_lower_index: number;
1616
+ tick_upper_index: number;
1617
+ pos_object_id: string;
1618
+ magma_distribution_staked: boolean;
1619
+ pool: string;
1620
+ earned: string;
1621
+ name: string;
1622
+ };
1623
+ type GetRewardByPosition = {
1624
+ poolId: string;
1625
+ gaugeId: string;
1626
+ positionId: string;
1627
+ coinTypeA: string;
1628
+ coinTypeB: string;
1629
+ };
1630
+
1593
1631
  type BigNumber = Decimal.Value | number | string;
1594
1632
 
1595
1633
  interface IModule {
@@ -3289,35 +3327,19 @@ declare class RpcModule extends SuiClient {
3289
3327
  sendSimulationTransaction(tx: Transaction, simulationAccount: string, useDevInspect?: boolean): Promise<DevInspectResults | undefined>;
3290
3328
  }
3291
3329
 
3292
- type DepositPosition = {
3293
- poolId: string;
3294
- positionId: string;
3295
- coinTypeA: string;
3296
- coinTypeB: string;
3297
- };
3298
- type WithdrawPosition = {
3299
- poolId: string;
3300
- positionId: string;
3301
- coinTypeA: string;
3302
- coinTypeB: string;
3303
- };
3304
- type EpochEmission = {
3305
- emission: number | string;
3306
- rebase: number | string;
3307
- total_supply: number | string;
3308
- total_locked: number | string;
3309
- };
3310
3330
  declare class GaugeModule implements IModule {
3311
3331
  protected _sdk: MagmaClmmSDK;
3312
3332
  constructor(sdk: MagmaClmmSDK);
3313
3333
  get sdk(): MagmaClmmSDK;
3314
3334
  depositPosition(params: DepositPosition): Promise<Transaction>;
3315
3335
  withdrawPosition(params: WithdrawPosition): Promise<Transaction>;
3316
- getUserStakedPositionInfo(userAddr: string): Promise<any[]>;
3336
+ getUserStakedPositionInfo(userAddr: string): Promise<StakedPositionOfPool[]>;
3317
3337
  getUserStakedPositionInfoOfPool(userAddr: string, pool: string, gauger: string, poolCoinA: string, poolCoinB: string): Promise<any[]>;
3318
3338
  getPoolGaguers(): Promise<Map<string, string>>;
3319
3339
  getPoolCoins(pools: string[]): Promise<Map<string, string[]>>;
3320
3340
  getEmissions(): Promise<EpochEmission>;
3341
+ getRewardByPosition(params: GetRewardByPosition): Promise<Transaction>;
3342
+ getEpochRewardByPool(pool: string, incentive_tokens: string[]): Promise<Map<string, string>>;
3321
3343
  }
3322
3344
 
3323
3345
  /**
@@ -4045,4 +4067,4 @@ interface InitMagmaSDKOptions {
4045
4067
  */
4046
4068
  declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
4047
4069
 
4048
- 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 };
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 };
package/dist/index.js CHANGED
@@ -7843,7 +7843,7 @@ var LockModule = class {
7843
7843
  sender: simulationAccount.address
7844
7844
  });
7845
7845
  if (simulateRes.error != null) {
7846
- throw new Error(`all_lock_summary error code: ${simulateRes.error ?? "unknown error"}`);
7846
+ throw new Error(`getPoolBribeRewardTokens error code: ${simulateRes.error ?? "unknown error"}`);
7847
7847
  }
7848
7848
  const poolBirbeRewardTokens = /* @__PURE__ */ new Map();
7849
7849
  simulateRes.events?.forEach((item) => {
@@ -9275,6 +9275,7 @@ var GaugeModule = class {
9275
9275
  const stakedPositionOfPool = await this.getUserStakedPositionInfoOfPool(userAddr, pool, gauger, coins[0], coins[1]);
9276
9276
  console.log("stakedPositionOfPool", stakedPositionOfPool);
9277
9277
  stakedPositionOfPool.forEach((value) => {
9278
+ ;
9278
9279
  value.infos.forEach((info) => {
9279
9280
  res.push({
9280
9281
  coin_type_a: coins[0],
@@ -9392,6 +9393,49 @@ var GaugeModule = class {
9392
9393
  });
9393
9394
  return res;
9394
9395
  }
9396
+ async getRewardByPosition(params) {
9397
+ const tx = new import_transactions11.Transaction();
9398
+ const { integrate } = this.sdk.sdkOptions;
9399
+ const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
9400
+ const typeArguments = [params.coinTypeA, params.coinTypeB, magma_token];
9401
+ const args = [tx.object(params.gaugeId), tx.object(params.poolId), tx.object(params.positionId), tx.object(CLOCK_ADDRESS)];
9402
+ tx.moveCall({
9403
+ target: `${integrate.published_at}::${Gauge}::get_reward_by_position`,
9404
+ arguments: args,
9405
+ typeArguments
9406
+ });
9407
+ return tx;
9408
+ }
9409
+ async getEpochRewardByPool(pool, incentive_tokens) {
9410
+ const tx = new import_transactions11.Transaction();
9411
+ const { integrate, simulationAccount } = this.sdk.sdkOptions;
9412
+ const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
9413
+ const typeArguments = [magma_token, ...incentive_tokens];
9414
+ const args = [tx.object(voter_id), tx.object(pool), tx.object(CLOCK_ADDRESS)];
9415
+ let targetFunc = `${integrate.published_at}::${Voter}::epoch_reward_by_pool${incentive_tokens.length}`;
9416
+ if (incentive_tokens.length === 1) {
9417
+ targetFunc = `${integrate.published_at}::${Voter}::epoch_reward_by_pool`;
9418
+ }
9419
+ tx.moveCall({
9420
+ target: targetFunc,
9421
+ arguments: args,
9422
+ typeArguments
9423
+ });
9424
+ const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
9425
+ transactionBlock: tx,
9426
+ sender: simulationAccount.address
9427
+ });
9428
+ if (simulateRes.error != null) {
9429
+ throw new Error(`getEpochRewardByPool error code: ${simulateRes.error ?? "unknown error"}`);
9430
+ }
9431
+ const res = /* @__PURE__ */ new Map();
9432
+ simulateRes.events?.forEach((item) => {
9433
+ if (extractStructTagFromType(item.type).name === `EventPoolIncentivesAmount`) {
9434
+ res.set(item.parsedJson.token, item.parsedJson.amount);
9435
+ }
9436
+ });
9437
+ return res;
9438
+ }
9395
9439
  };
9396
9440
 
9397
9441
  // src/sdk.ts