@magmaprotocol/magma-clmm-sdk 0.5.17 → 0.5.19
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 +14 -2
- package/dist/index.js +160 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1620,6 +1620,13 @@ type StakedPositionOfPool = {
|
|
|
1620
1620
|
earned: string;
|
|
1621
1621
|
name: string;
|
|
1622
1622
|
};
|
|
1623
|
+
type GetRewardByPosition = {
|
|
1624
|
+
poolId: string;
|
|
1625
|
+
gaugeId: string;
|
|
1626
|
+
positionId: string;
|
|
1627
|
+
coinTypeA: string;
|
|
1628
|
+
coinTypeB: string;
|
|
1629
|
+
};
|
|
1623
1630
|
|
|
1624
1631
|
type BigNumber = Decimal.Value | number | string;
|
|
1625
1632
|
|
|
@@ -3091,7 +3098,10 @@ declare class LockModule implements IModule {
|
|
|
3091
3098
|
poolWeights(pools: string[]): Promise<PoolWeight[]>;
|
|
3092
3099
|
getVotingFeeRewardTokens(lock_id: string): Promise<Map<string, string[]>>;
|
|
3093
3100
|
getVotingBribeRewardTokens(lock_id: string): Promise<Map<string, string[]>>;
|
|
3094
|
-
|
|
3101
|
+
getPoolFeeRewards(lock_id: string, tokens: string[]): Promise<Map<string, Map<string, string>>>;
|
|
3102
|
+
_getPoolFeeRewards(lock_id: string, token_a: string, token_b: string, poolFeeRewardTokens: Map<string, Map<string, string>>): Promise<Map<string, Map<string, string>>>;
|
|
3103
|
+
getPoolIncentiveRewards(lock_id: string, incentive_tokens: string[]): Promise<Map<string, Map<string, string>>>;
|
|
3104
|
+
_getPoolIncentiveRewards(locksId: string, incentive_tokens: string[], poolBribeRewardTokens: Map<string, Map<string, string>>): Promise<Map<string, Map<string, string>>>;
|
|
3095
3105
|
getPoolBribeRewardTokens(pool_id: string): Promise<Map<string, string[]>>;
|
|
3096
3106
|
}
|
|
3097
3107
|
|
|
@@ -3331,6 +3341,8 @@ declare class GaugeModule implements IModule {
|
|
|
3331
3341
|
getPoolGaguers(): Promise<Map<string, string>>;
|
|
3332
3342
|
getPoolCoins(pools: string[]): Promise<Map<string, string[]>>;
|
|
3333
3343
|
getEmissions(): Promise<EpochEmission>;
|
|
3344
|
+
getRewardByPosition(params: GetRewardByPosition): Promise<Transaction>;
|
|
3345
|
+
getEpochRewardByPool(pool: string, incentive_tokens: string[]): Promise<Map<string, string>>;
|
|
3334
3346
|
}
|
|
3335
3347
|
|
|
3336
3348
|
/**
|
|
@@ -4058,4 +4070,4 @@ interface InitMagmaSDKOptions {
|
|
|
4058
4070
|
*/
|
|
4059
4071
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4060
4072
|
|
|
4061
|
-
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, 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 };
|
|
4073
|
+
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
|
@@ -7490,11 +7490,16 @@ var LockModule = class {
|
|
|
7490
7490
|
const { fields } = item.data.content;
|
|
7491
7491
|
const aLockSummary = await this.aLockSummary(fields.id.id);
|
|
7492
7492
|
const poolIncentiveTokens = await this.getVotingBribeRewardTokens(fields.id.id);
|
|
7493
|
+
const poolFeeTokens = await this.getVotingFeeRewardTokens(fields.id.id);
|
|
7493
7494
|
const incentiveTokens = [];
|
|
7494
7495
|
poolIncentiveTokens.forEach((value, key) => {
|
|
7495
7496
|
incentiveTokens.push(...value);
|
|
7496
7497
|
});
|
|
7497
|
-
const
|
|
7498
|
+
const feeTokens = [];
|
|
7499
|
+
poolFeeTokens.forEach((value, key) => {
|
|
7500
|
+
feeTokens.push(...value);
|
|
7501
|
+
});
|
|
7502
|
+
const poolIncentiveRewards = await this.getPoolIncentiveRewards(fields.id.id, incentiveTokens);
|
|
7498
7503
|
const votingRewards = /* @__PURE__ */ new Map();
|
|
7499
7504
|
poolIncentiveRewards.forEach((value, coin) => {
|
|
7500
7505
|
value.forEach((amount, pool) => {
|
|
@@ -7508,6 +7513,19 @@ var LockModule = class {
|
|
|
7508
7513
|
});
|
|
7509
7514
|
});
|
|
7510
7515
|
});
|
|
7516
|
+
const poolFeeRewards = await this.getPoolFeeRewards(fields.id.id, feeTokens);
|
|
7517
|
+
poolFeeRewards.forEach((value, coin) => {
|
|
7518
|
+
value.forEach((amount, pool) => {
|
|
7519
|
+
if (!votingRewards.has(pool)) {
|
|
7520
|
+
votingRewards.set(pool, []);
|
|
7521
|
+
}
|
|
7522
|
+
votingRewards.get(pool)?.push({
|
|
7523
|
+
kind: "fee" /* Fee */,
|
|
7524
|
+
token_addr: coin,
|
|
7525
|
+
amount: amount.toString()
|
|
7526
|
+
});
|
|
7527
|
+
});
|
|
7528
|
+
});
|
|
7511
7529
|
const lockInfo = {
|
|
7512
7530
|
lock_id: fields.id.id,
|
|
7513
7531
|
amount: fields.amount,
|
|
@@ -7520,7 +7538,7 @@ var LockModule = class {
|
|
|
7520
7538
|
amount: aLockSummary.reward_distributor_claimable
|
|
7521
7539
|
},
|
|
7522
7540
|
voting_power: aLockSummary.voting_power,
|
|
7523
|
-
// pool => incentive => amount
|
|
7541
|
+
// pool => incentive/fee => amount
|
|
7524
7542
|
voting_rewards: votingRewards
|
|
7525
7543
|
};
|
|
7526
7544
|
locksInfo.lockInfo.push(lockInfo);
|
|
@@ -7528,7 +7546,6 @@ var LockModule = class {
|
|
|
7528
7546
|
return locksInfo;
|
|
7529
7547
|
}
|
|
7530
7548
|
async aLockInfo(lockId) {
|
|
7531
|
-
const aLockSummary = await this.aLockSummary(lockId);
|
|
7532
7549
|
const lockObj = await this._sdk.fullClient.getObject({
|
|
7533
7550
|
id: lockId,
|
|
7534
7551
|
options: {
|
|
@@ -7540,13 +7557,25 @@ var LockModule = class {
|
|
|
7540
7557
|
showType: true
|
|
7541
7558
|
}
|
|
7542
7559
|
});
|
|
7560
|
+
if (lockObj.error != null || lockObj.data?.content?.dataType !== "moveObject") {
|
|
7561
|
+
throw new ClmmpoolsError(
|
|
7562
|
+
`getPool error code: ${lockObj.error?.code ?? "unknown error"}, please check config and object id`,
|
|
7563
|
+
"InvalidLockObject" /* InvalidLockObject */
|
|
7564
|
+
);
|
|
7565
|
+
}
|
|
7543
7566
|
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7567
|
+
const aLockSummary = await this.aLockSummary(lockId);
|
|
7544
7568
|
const poolIncentiveTokens = await this.getVotingBribeRewardTokens(lockId);
|
|
7569
|
+
const poolFeeTokens = await this.getVotingFeeRewardTokens(lockId);
|
|
7545
7570
|
const incentiveTokens = [];
|
|
7546
7571
|
poolIncentiveTokens.forEach((value, key) => {
|
|
7547
7572
|
incentiveTokens.push(...value);
|
|
7548
7573
|
});
|
|
7549
|
-
const
|
|
7574
|
+
const feeTokens = [];
|
|
7575
|
+
poolFeeTokens.forEach((value, key) => {
|
|
7576
|
+
feeTokens.push(...value);
|
|
7577
|
+
});
|
|
7578
|
+
const poolIncentiveRewards = await this.getPoolIncentiveRewards(lockId, incentiveTokens);
|
|
7550
7579
|
const votingRewards = /* @__PURE__ */ new Map();
|
|
7551
7580
|
poolIncentiveRewards.forEach((value, coin) => {
|
|
7552
7581
|
value.forEach((amount, pool) => {
|
|
@@ -7560,12 +7589,19 @@ var LockModule = class {
|
|
|
7560
7589
|
});
|
|
7561
7590
|
});
|
|
7562
7591
|
});
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7592
|
+
const poolFeeRewards = await this.getPoolFeeRewards(lockId, feeTokens);
|
|
7593
|
+
poolFeeRewards.forEach((value, coin) => {
|
|
7594
|
+
value.forEach((amount, pool) => {
|
|
7595
|
+
if (!votingRewards.has(pool)) {
|
|
7596
|
+
votingRewards.set(pool, []);
|
|
7597
|
+
}
|
|
7598
|
+
votingRewards.get(pool)?.push({
|
|
7599
|
+
kind: "fee" /* Fee */,
|
|
7600
|
+
token_addr: coin,
|
|
7601
|
+
amount: amount.toString()
|
|
7602
|
+
});
|
|
7603
|
+
});
|
|
7604
|
+
});
|
|
7569
7605
|
const fields = getObjectFields(lockObj);
|
|
7570
7606
|
const lockInfo = {
|
|
7571
7607
|
lock_id: lockId,
|
|
@@ -7780,11 +7816,72 @@ var LockModule = class {
|
|
|
7780
7816
|
});
|
|
7781
7817
|
return poolBirbeRewardTokens;
|
|
7782
7818
|
}
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7819
|
+
async getPoolFeeRewards(lock_id, tokens) {
|
|
7820
|
+
const poolFeeRewardTokens = /* @__PURE__ */ new Map();
|
|
7821
|
+
if (tokens.length === 0) {
|
|
7822
|
+
return poolFeeRewardTokens;
|
|
7823
|
+
}
|
|
7824
|
+
if (tokens.length % 2 !== 0) {
|
|
7825
|
+
tokens.push(tokens[0]);
|
|
7826
|
+
}
|
|
7827
|
+
for (let i = 0; i + 1 < tokens.length; i += 2) {
|
|
7828
|
+
await this._getPoolFeeRewards(lock_id, tokens[i], tokens[i + 1], poolFeeRewardTokens);
|
|
7829
|
+
}
|
|
7830
|
+
return poolFeeRewardTokens;
|
|
7831
|
+
}
|
|
7832
|
+
// if you have many tokens, call this function multi times
|
|
7833
|
+
async _getPoolFeeRewards(lock_id, token_a, token_b, poolFeeRewardTokens) {
|
|
7834
|
+
const tx = new import_transactions9.Transaction();
|
|
7835
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
7836
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7837
|
+
const typeArguments = [magma_token, token_a, token_b];
|
|
7838
|
+
const args = [tx.object(voter_id), tx.object(lock_id), tx.object(CLOCK_ADDRESS)];
|
|
7839
|
+
const targetFunc = `${integrate.published_at}::${Voter}::claimable_voting_fee_rewards`;
|
|
7840
|
+
tx.moveCall({
|
|
7841
|
+
target: targetFunc,
|
|
7842
|
+
arguments: args,
|
|
7843
|
+
typeArguments
|
|
7844
|
+
});
|
|
7845
|
+
if (!checkInvalidSuiAddress(simulationAccount.address)) {
|
|
7846
|
+
throw Error("this config simulationAccount is not set right");
|
|
7847
|
+
}
|
|
7848
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
7849
|
+
transactionBlock: tx,
|
|
7850
|
+
sender: simulationAccount.address
|
|
7851
|
+
});
|
|
7852
|
+
if (simulateRes.error != null) {
|
|
7853
|
+
throw new Error(`getPoolFeeRewards error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7854
|
+
}
|
|
7855
|
+
simulateRes.events?.forEach((item) => {
|
|
7856
|
+
if (extractStructTagFromType(item.type).name === `ClaimableVotingFee`) {
|
|
7857
|
+
item.parsedJson.data.contents.forEach((rewardTokens) => {
|
|
7858
|
+
if (!poolFeeRewardTokens.has(rewardTokens.key.name)) {
|
|
7859
|
+
poolFeeRewardTokens.set(rewardTokens.key.name, /* @__PURE__ */ new Map());
|
|
7860
|
+
}
|
|
7861
|
+
rewardTokens.value.contents.forEach((token) => {
|
|
7862
|
+
poolFeeRewardTokens.get(rewardTokens.key.name)?.set(token.key, token.value);
|
|
7863
|
+
});
|
|
7864
|
+
});
|
|
7865
|
+
}
|
|
7866
|
+
});
|
|
7867
|
+
return poolFeeRewardTokens;
|
|
7868
|
+
}
|
|
7869
|
+
async getPoolIncentiveRewards(lock_id, incentive_tokens) {
|
|
7870
|
+
const poolBribeRewardTokens = /* @__PURE__ */ new Map();
|
|
7786
7871
|
if (incentive_tokens.length === 0) {
|
|
7787
|
-
return
|
|
7872
|
+
return poolBribeRewardTokens;
|
|
7873
|
+
}
|
|
7874
|
+
let i = 0;
|
|
7875
|
+
for (; i + 3 < incentive_tokens.length; i += 3) {
|
|
7876
|
+
await this._getPoolIncentiveRewards(lock_id, incentive_tokens.slice(i, i + 3), poolBribeRewardTokens);
|
|
7877
|
+
}
|
|
7878
|
+
await this._getPoolIncentiveRewards(lock_id, incentive_tokens.slice(i), poolBribeRewardTokens);
|
|
7879
|
+
return poolBribeRewardTokens;
|
|
7880
|
+
}
|
|
7881
|
+
// tokenId => pool => incentive_tokens
|
|
7882
|
+
async _getPoolIncentiveRewards(locksId, incentive_tokens, poolBribeRewardTokens) {
|
|
7883
|
+
if (incentive_tokens.length > 3) {
|
|
7884
|
+
throw Error("Too many tokens");
|
|
7788
7885
|
}
|
|
7789
7886
|
const tx = new import_transactions9.Transaction();
|
|
7790
7887
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -7808,21 +7905,21 @@ var LockModule = class {
|
|
|
7808
7905
|
sender: simulationAccount.address
|
|
7809
7906
|
});
|
|
7810
7907
|
if (simulateRes.error != null) {
|
|
7811
|
-
throw new Error(`
|
|
7908
|
+
throw new Error(`getPoolIncentiveRewards error code: ${simulateRes.error ?? "unknown error"}`);
|
|
7812
7909
|
}
|
|
7813
7910
|
simulateRes.events?.forEach((item) => {
|
|
7814
7911
|
if (extractStructTagFromType(item.type).name === `ClaimableVotingBribes`) {
|
|
7815
7912
|
item.parsedJson.data.contents.forEach((rewardTokens) => {
|
|
7816
|
-
if (!
|
|
7817
|
-
|
|
7913
|
+
if (!poolBribeRewardTokens.has(rewardTokens.key.name)) {
|
|
7914
|
+
poolBribeRewardTokens.set(rewardTokens.key.name, /* @__PURE__ */ new Map());
|
|
7818
7915
|
}
|
|
7819
7916
|
rewardTokens.value.contents.forEach((token) => {
|
|
7820
|
-
|
|
7917
|
+
poolBribeRewardTokens.get(rewardTokens.key.name)?.set(token.key, token.value);
|
|
7821
7918
|
});
|
|
7822
7919
|
});
|
|
7823
7920
|
}
|
|
7824
7921
|
});
|
|
7825
|
-
return
|
|
7922
|
+
return poolBribeRewardTokens;
|
|
7826
7923
|
}
|
|
7827
7924
|
async getPoolBribeRewardTokens(pool_id) {
|
|
7828
7925
|
const tx = new import_transactions9.Transaction();
|
|
@@ -9275,6 +9372,7 @@ var GaugeModule = class {
|
|
|
9275
9372
|
const stakedPositionOfPool = await this.getUserStakedPositionInfoOfPool(userAddr, pool, gauger, coins[0], coins[1]);
|
|
9276
9373
|
console.log("stakedPositionOfPool", stakedPositionOfPool);
|
|
9277
9374
|
stakedPositionOfPool.forEach((value) => {
|
|
9375
|
+
;
|
|
9278
9376
|
value.infos.forEach((info) => {
|
|
9279
9377
|
res.push({
|
|
9280
9378
|
coin_type_a: coins[0],
|
|
@@ -9392,6 +9490,49 @@ var GaugeModule = class {
|
|
|
9392
9490
|
});
|
|
9393
9491
|
return res;
|
|
9394
9492
|
}
|
|
9493
|
+
async getRewardByPosition(params) {
|
|
9494
|
+
const tx = new import_transactions11.Transaction();
|
|
9495
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
9496
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
9497
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB, magma_token];
|
|
9498
|
+
const args = [tx.object(params.gaugeId), tx.object(params.poolId), tx.object(params.positionId), tx.object(CLOCK_ADDRESS)];
|
|
9499
|
+
tx.moveCall({
|
|
9500
|
+
target: `${integrate.published_at}::${Gauge}::get_reward_by_position`,
|
|
9501
|
+
arguments: args,
|
|
9502
|
+
typeArguments
|
|
9503
|
+
});
|
|
9504
|
+
return tx;
|
|
9505
|
+
}
|
|
9506
|
+
async getEpochRewardByPool(pool, incentive_tokens) {
|
|
9507
|
+
const tx = new import_transactions11.Transaction();
|
|
9508
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
9509
|
+
const { magma_token, voter_id } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
9510
|
+
const typeArguments = [magma_token, ...incentive_tokens];
|
|
9511
|
+
const args = [tx.object(voter_id), tx.object(pool), tx.object(CLOCK_ADDRESS)];
|
|
9512
|
+
let targetFunc = `${integrate.published_at}::${Voter}::epoch_reward_by_pool${incentive_tokens.length}`;
|
|
9513
|
+
if (incentive_tokens.length === 1) {
|
|
9514
|
+
targetFunc = `${integrate.published_at}::${Voter}::epoch_reward_by_pool`;
|
|
9515
|
+
}
|
|
9516
|
+
tx.moveCall({
|
|
9517
|
+
target: targetFunc,
|
|
9518
|
+
arguments: args,
|
|
9519
|
+
typeArguments
|
|
9520
|
+
});
|
|
9521
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
9522
|
+
transactionBlock: tx,
|
|
9523
|
+
sender: simulationAccount.address
|
|
9524
|
+
});
|
|
9525
|
+
if (simulateRes.error != null) {
|
|
9526
|
+
throw new Error(`getEpochRewardByPool error code: ${simulateRes.error ?? "unknown error"}`);
|
|
9527
|
+
}
|
|
9528
|
+
const res = /* @__PURE__ */ new Map();
|
|
9529
|
+
simulateRes.events?.forEach((item) => {
|
|
9530
|
+
if (extractStructTagFromType(item.type).name === `EventPoolIncentivesAmount`) {
|
|
9531
|
+
res.set(item.parsedJson.token, item.parsedJson.amount);
|
|
9532
|
+
}
|
|
9533
|
+
});
|
|
9534
|
+
return res;
|
|
9535
|
+
}
|
|
9395
9536
|
};
|
|
9396
9537
|
|
|
9397
9538
|
// src/sdk.ts
|