@alphafi/alphafi-sdk 0.0.87 → 0.0.88
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/cjs/common/constants.d.ts +18 -0
- package/dist/cjs/common/constants.d.ts.map +1 -1
- package/dist/cjs/common/constants.js +23 -12
- package/dist/cjs/common/constants.js.map +1 -1
- package/dist/cjs/common/maps.d.ts +1 -0
- package/dist/cjs/common/maps.d.ts.map +1 -1
- package/dist/cjs/common/maps.js +4 -0
- package/dist/cjs/common/maps.js.map +1 -1
- package/dist/cjs/common/types.d.ts +8 -1
- package/dist/cjs/common/types.d.ts.map +1 -1
- package/dist/cjs/common/types.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js +15 -17
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchEvents.js +29 -3
- package/dist/cjs/sui-sdk/events/fetchEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/events/types.d.ts +15 -5
- package/dist/cjs/sui-sdk/events/types.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/types.js.map +1 -1
- package/dist/cjs/transactions/blueRewards.d.ts +1 -0
- package/dist/cjs/transactions/blueRewards.d.ts.map +1 -1
- package/dist/cjs/transactions/blueRewards.js +196 -471
- package/dist/cjs/transactions/blueRewards.js.map +1 -1
- package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
- package/dist/cjs/transactions/bluefin.js +83 -495
- package/dist/cjs/transactions/bluefin.js.map +1 -1
- package/dist/esm/common/constants.d.ts +18 -0
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +23 -12
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/common/maps.d.ts +1 -0
- package/dist/esm/common/maps.d.ts.map +1 -1
- package/dist/esm/common/maps.js +4 -0
- package/dist/esm/common/maps.js.map +1 -1
- package/dist/esm/common/types.d.ts +8 -1
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/common/types.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js +15 -17
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchEvents.js +29 -3
- package/dist/esm/sui-sdk/events/fetchEvents.js.map +1 -1
- package/dist/esm/sui-sdk/events/types.d.ts +15 -5
- package/dist/esm/sui-sdk/events/types.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/types.js.map +1 -1
- package/dist/esm/transactions/blueRewards.d.ts +1 -0
- package/dist/esm/transactions/blueRewards.d.ts.map +1 -1
- package/dist/esm/transactions/blueRewards.js +196 -472
- package/dist/esm/transactions/blueRewards.js.map +1 -1
- package/dist/esm/transactions/bluefin.d.ts.map +1 -1
- package/dist/esm/transactions/bluefin.js +84 -496
- package/dist/esm/transactions/bluefin.js.map +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/functions/alphaLpBreakdown.html +1 -1
- package/docs/functions/cetusLpBreakdown.html +1 -1
- package/docs/functions/claimRewardTxb.html +1 -1
- package/docs/functions/claimRewardsTxb.html +1 -1
- package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -1
- package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -1
- package/docs/functions/coinsInPool.html +1 -1
- package/docs/functions/collectRewardTxb.html +1 -0
- package/docs/functions/collectRewards.html +1 -1
- package/docs/functions/deposit.html +1 -1
- package/docs/functions/depositDoubleAssetTxb.html +1 -1
- package/docs/functions/depositSingleAssetTxb.html +1 -1
- package/docs/functions/fetchAfterTransactionEvents.html +1 -1
- package/docs/functions/fetchAirdropClaimEvents.html +1 -1
- package/docs/functions/fetchAutoCompoundingEvents.html +1 -1
- package/docs/functions/fetchAutoCompoundingEventsGql.html +1 -1
- package/docs/functions/fetchCetusPools.html +1 -1
- package/docs/functions/fetchChainIdentifier.html +1 -1
- package/docs/functions/fetchCheckRatioEvents.html +1 -1
- package/docs/functions/fetchEvents.html +1 -1
- package/docs/functions/fetchLiquidityChangeEvents.html +1 -1
- package/docs/functions/fetchMultiCategoryEvents.html +1 -1
- package/docs/functions/fetchMultiReceipts.html +1 -1
- package/docs/functions/fetchNftHolders.html +1 -1
- package/docs/functions/fetchPools.html +1 -1
- package/docs/functions/fetchPortfolioData.html +1 -1
- package/docs/functions/fetchProtocolData.html +1 -1
- package/docs/functions/fetchRequiredPrices.html +1 -1
- package/docs/functions/fetchTVL.html +1 -1
- package/docs/functions/fetchTransactions.html +1 -1
- package/docs/functions/fetchUserVaultBalances.html +1 -1
- package/docs/functions/fetchUserVaults.html +1 -1
- package/docs/functions/fetchUserWalletData.html +1 -1
- package/docs/functions/fetchVoloExchangeRate.html +1 -1
- package/docs/functions/fetchWithdrawV2Events.html +1 -1
- package/docs/functions/getAirdropShare.html +1 -1
- package/docs/functions/getAllDoubleAssetVaults.html +1 -1
- package/docs/functions/getAllSingleAssetVaults.html +1 -1
- package/docs/functions/getAllVaultBalances.html +1 -1
- package/docs/functions/getAllVaults.html +1 -1
- package/docs/functions/getAlphaUnlocks.html +1 -1
- package/docs/functions/getAlphaVaultBalance.html +1 -1
- package/docs/functions/getAmounts.html +1 -1
- package/docs/functions/getApr.html +1 -1
- package/docs/functions/getAprs.html +1 -1
- package/docs/functions/getApy.html +1 -1
- package/docs/functions/getApys.html +1 -1
- package/docs/functions/getCetusInvestorTicksMap.html +1 -1
- package/docs/functions/getCetusPool.html +1 -1
- package/docs/functions/getCetusSqrtPriceMap.html +1 -1
- package/docs/functions/getCoinAmountsFromLiquidity.html +1 -1
- package/docs/functions/getConf.html +1 -1
- package/docs/functions/getCurrentTick.html +1 -1
- package/docs/functions/getDistributor.html +1 -1
- package/docs/functions/getDoubleAssetVaultBalance.html +1 -1
- package/docs/functions/getDoubleAssetVaults.html +1 -1
- package/docs/functions/getInvestor.html +1 -1
- package/docs/functions/getInvestorPoolMap.html +1 -1
- package/docs/functions/getLastAutoCompoundTime.html +1 -1
- package/docs/functions/getLatestPrices.html +1 -1
- package/docs/functions/getLiquidity.html +1 -1
- package/docs/functions/getMultiCetusPool.html +1 -1
- package/docs/functions/getMultiInvestor.html +1 -1
- package/docs/functions/getMultiLatestPrices.html +1 -1
- package/docs/functions/getMultiParentPool.html +1 -1
- package/docs/functions/getMultiPool.html +1 -1
- package/docs/functions/getMultiReceipts.html +1 -1
- package/docs/functions/getParentPool.html +1 -1
- package/docs/functions/getPool.html +1 -1
- package/docs/functions/getPoolExchangeRate.html +1 -1
- package/docs/functions/getPoolExchangeRateMap.html +1 -1
- package/docs/functions/getPoolsWeightDistribution.html +1 -1
- package/docs/functions/getPositionRange.html +1 -1
- package/docs/functions/getPositionRanges.html +1 -1
- package/docs/functions/getPositionTicks.html +1 -1
- package/docs/functions/getPriceToTick.html +1 -1
- package/docs/functions/getRebalanceHistories.html +1 -1
- package/docs/functions/getRebalanceHistory.html +1 -1
- package/docs/functions/getReceipts.html +1 -1
- package/docs/functions/getSingleAssetVaultBalance.html +1 -1
- package/docs/functions/getSingleAssetVaults.html +1 -1
- package/docs/functions/getSuiClient.html +2 -2
- package/docs/functions/getSuiNodeUrl.html +2 -2
- package/docs/functions/getTVLs-1.html +1 -1
- package/docs/functions/getTickSpacing.html +1 -1
- package/docs/functions/getTickToPrice.html +1 -1
- package/docs/functions/getTvls.html +1 -1
- package/docs/functions/getVaultBalance.html +1 -1
- package/docs/functions/getVaults.html +1 -1
- package/docs/functions/getZapAmounts.html +1 -1
- package/docs/functions/lastAutocompoundTime.html +1 -1
- package/docs/functions/liquidityToTokens.html +1 -1
- package/docs/functions/migrateBoostedToLoop.html +1 -1
- package/docs/functions/multiLiquidityToTokens.html +1 -1
- package/docs/functions/multiTokensToUsd.html +1 -1
- package/docs/functions/multiXTokensToLiquidity.html +1 -1
- package/docs/functions/parseUserWalletData.html +1 -1
- package/docs/functions/pendingRewardAmount.html +1 -1
- package/docs/functions/setCustomSuiClient.html +2 -2
- package/docs/functions/setSuiClient.html +2 -2
- package/docs/functions/setSuiNodeUrl.html +2 -2
- package/docs/functions/setWeights.html +1 -1
- package/docs/functions/withdraw.html +1 -1
- package/docs/functions/withdrawAlphaTxb.html +1 -1
- package/docs/functions/withdrawTxb.html +1 -1
- package/docs/functions/zapDepositTxb.html +1 -1
- package/docs/index.html +2 -2
- package/docs/interfaces/Coin.html +6 -6
- package/docs/interfaces/CoinPair.html +2 -2
- package/docs/interfaces/CommonEventAttributes.html +2 -2
- package/docs/interfaces/NaviVoloData.html +2 -2
- package/docs/interfaces/PoolData.html +2 -2
- package/docs/interfaces/PoolWeightDistribution.html +2 -2
- package/docs/interfaces/RebalanceHistoryType.html +2 -2
- package/docs/modules.html +3 -2
- package/docs/types/AfterTransactionEventNode.html +1 -1
- package/docs/types/AirdropClaimEventNode.html +1 -1
- package/docs/types/Allocator.html +1 -1
- package/docs/types/AlphaFiDoubleAssetVault.html +1 -1
- package/docs/types/AlphaFiMultiVaultBalance.html +1 -1
- package/docs/types/AlphaFiSingleAssetVault.html +1 -1
- package/docs/types/AlphaFiVault.html +1 -1
- package/docs/types/AlphaFiVaultBalance.html +1 -1
- package/docs/types/AlphaLendInvestor.html +1 -1
- package/docs/types/AlphaPoolType.html +1 -1
- package/docs/types/AlphaReceipt.html +1 -1
- package/docs/types/AlphaReceiptFields.html +1 -1
- package/docs/types/AlphaVaultBalance.html +1 -1
- package/docs/types/AutoBalancePoolNames.html +1 -1
- package/docs/types/AutoCompoundingEventNode.html +1 -1
- package/docs/types/BluefinInvestor.html +1 -1
- package/docs/types/BluefinPoolType.html +1 -1
- package/docs/types/BucketInvestor.html +1 -1
- package/docs/types/CetusInvestor.html +1 -1
- package/docs/types/CetusPoolType.html +1 -1
- package/docs/types/CetusSwapOptions.html +1 -1
- package/docs/types/CoinAmounts.html +1 -1
- package/docs/types/CoinName.html +1 -1
- package/docs/types/CoinType.html +1 -1
- package/docs/types/CommonInvestorFields.html +1 -1
- package/docs/types/CreatePoolOptions.html +1 -1
- package/docs/types/Distributor.html +1 -1
- package/docs/types/DoubleAssetMultiVaultBalance.html +1 -1
- package/docs/types/DoubleAssetPoolNames.html +1 -1
- package/docs/types/DoubleAssetTokenHoldings.html +1 -1
- package/docs/types/DoubleAssetVaultBalance.html +1 -1
- package/docs/types/EventCategory.html +1 -1
- package/docs/types/EventNode.html +1 -1
- package/docs/types/GetHoldersParams.html +1 -1
- package/docs/types/GetTokenHoldingsParams.html +1 -1
- package/docs/types/GetUserTokensFromTransactionsParams.html +1 -1
- package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +1 -1
- package/docs/types/GetVaultBalanceParams.html +1 -1
- package/docs/types/HoldingsObj.html +1 -1
- package/docs/types/Icon.html +1 -1
- package/docs/types/Investor.html +1 -1
- package/docs/types/LiquidityChangeEventNode.html +1 -1
- package/docs/types/LiquidityToTokensParams.html +1 -1
- package/docs/types/LiquidityToUsdParams.html +1 -1
- package/docs/types/LoopingDebt.html +1 -1
- package/docs/types/LoopingPoolNames.html +1 -1
- package/docs/types/LpBreakdownType.html +1 -1
- package/docs/types/MemberPoolDataType.html +1 -1
- package/docs/types/MemberType.html +1 -1
- package/docs/types/MultiGetVaultBalancesParams.html +1 -1
- package/docs/types/NaviInvestor.html +1 -1
- package/docs/types/OtherReceiptFields.html +1 -1
- package/docs/types/PoolName.html +1 -1
- package/docs/types/PoolReceipt.html +1 -1
- package/docs/types/PoolType.html +1 -1
- package/docs/types/Receipt.html +1 -1
- package/docs/types/ReceiptGQL.html +1 -1
- package/docs/types/SingleAssetMultiVaultBalance.html +1 -1
- package/docs/types/SingleAssetPoolNames.html +1 -1
- package/docs/types/SingleAssetTokenHoldings.html +1 -1
- package/docs/types/SingleAssetVaultBalance.html +1 -1
- package/docs/types/SingleGetVaultBalancesParams.html +1 -1
- package/docs/types/StrategyType.html +1 -1
- package/docs/types/SuiNetwork.html +1 -1
- package/docs/types/SwapOptions.html +1 -1
- package/docs/types/TickSpacing.html +1 -1
- package/docs/types/TotalWeightType.html +1 -1
- package/docs/types/TransactionBlockType.html +1 -1
- package/docs/types/UserPoolLiquidity.html +1 -1
- package/docs/types/UserPoolTokenHoldings.html +1 -1
- package/docs/types/UserUsdHoldings.html +1 -1
- package/docs/types/VaultBalance.html +1 -1
- package/docs/types/VoteCastEvent.html +1 -1
- package/docs/types/WithdrawV2EventNode.html +1 -1
- package/docs/variables/alphalendMarketIdMap.html +1 -1
- package/docs/variables/bluefinPoolMap.html +1 -1
- package/docs/variables/cetusPoolMap.html +1 -1
- package/docs/variables/coinsList.html +1 -1
- package/docs/variables/defunctPoolsSet.html +1 -1
- package/docs/variables/doubleAssetPoolCoinMap.html +1 -1
- package/docs/variables/eventCategories.html +1 -1
- package/docs/variables/ignoredWalletsForDailyRevenue.html +1 -1
- package/docs/variables/loopingAccountAddresses.html +1 -1
- package/docs/variables/loopingPoolCoinMap.html +1 -1
- package/docs/variables/naviAssetMap.html +1 -1
- package/docs/variables/poolIdPoolNameMap.html +1 -1
- package/docs/variables/poolInfo.html +1 -1
- package/docs/variables/singleAssetPoolCoinMap.html +1 -1
- package/docs/variables/stableCoins.html +1 -1
- package/package.json +1 -1
|
@@ -23,77 +23,58 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.collectRewardTxb = collectRewardTxb;
|
|
26
27
|
exports.claimRewardsTxb = claimRewardsTxb;
|
|
27
28
|
exports.pendingRewardAmount = pendingRewardAmount;
|
|
28
29
|
const decimal_js_1 = require("decimal.js");
|
|
29
30
|
const index_js_1 = require("../index.js");
|
|
30
31
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
31
32
|
const maps_js_1 = require("../common/maps.js");
|
|
32
|
-
async function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
async function collectRewardTxb(poolName, ignoreCache, tx) {
|
|
34
|
+
let txb;
|
|
35
|
+
if (tx) {
|
|
36
|
+
txb = tx;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
txb = new transactions_1.Transaction();
|
|
40
|
+
}
|
|
41
|
+
const bluefinPool = (await (0, index_js_1.getParentPool)(poolName, ignoreCache));
|
|
42
|
+
const pool = index_js_1.poolInfo[poolName];
|
|
43
|
+
const coin1 = index_js_1.doubleAssetPoolCoinMap[poolName].coin1;
|
|
44
|
+
const coin2 = index_js_1.doubleAssetPoolCoinMap[poolName].coin2;
|
|
45
|
+
if (poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC" ||
|
|
46
|
+
poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC") {
|
|
47
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
48
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
42
49
|
txb.moveCall({
|
|
43
|
-
target: `${pool.packageId}::
|
|
44
|
-
typeArguments: [
|
|
45
|
-
index_js_1.coinsList["USDT"].type,
|
|
46
|
-
index_js_1.coinsList["USDC"].type,
|
|
47
|
-
index_js_1.coinsList["SUI"].type,
|
|
48
|
-
],
|
|
49
|
-
arguments: [
|
|
50
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
51
|
-
txb.object(pool.investorId),
|
|
52
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
53
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
|
|
54
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
|
|
55
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
56
|
-
],
|
|
57
|
-
});
|
|
58
|
-
const blueBalance = txb.moveCall({
|
|
59
|
-
target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
50
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
|
|
60
51
|
typeArguments: [
|
|
61
|
-
index_js_1.coinsList[
|
|
62
|
-
index_js_1.coinsList[
|
|
63
|
-
|
|
64
|
-
index_js_1.coinsList["SUI"].type,
|
|
52
|
+
index_js_1.coinsList[coin1].type,
|
|
53
|
+
index_js_1.coinsList[coin2].type,
|
|
54
|
+
rewardType,
|
|
65
55
|
],
|
|
66
56
|
arguments: [
|
|
67
|
-
txb.object(receipts[0].objectId),
|
|
68
57
|
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
69
58
|
txb.object(pool.poolId),
|
|
70
59
|
txb.object(pool.investorId),
|
|
71
60
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
72
61
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
73
|
-
txb.object(
|
|
74
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
|
|
75
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
|
|
76
|
-
txb.object(index_js_1.cetusPoolMap["USDC-USDT"]),
|
|
77
|
-
txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
|
|
78
|
-
txb.object((0, index_js_1.getConf)().LST_INFO),
|
|
79
|
-
txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
|
|
62
|
+
txb.object(pool.parentPoolId),
|
|
80
63
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
81
64
|
],
|
|
82
65
|
});
|
|
83
|
-
const blueCoin = txb.moveCall({
|
|
84
|
-
target: "0x2::coin::from_balance",
|
|
85
|
-
typeArguments: [index_js_1.coinsList["BLUE"].type],
|
|
86
|
-
arguments: [blueBalance],
|
|
87
|
-
});
|
|
88
|
-
rewards.push(blueCoin);
|
|
89
66
|
}
|
|
90
|
-
|
|
67
|
+
}
|
|
68
|
+
else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
|
|
69
|
+
poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
|
|
70
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
71
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
91
72
|
txb.moveCall({
|
|
92
|
-
target: `${pool.packageId}::
|
|
73
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::collect_reward`,
|
|
93
74
|
typeArguments: [
|
|
94
75
|
index_js_1.coinsList[coin1].type,
|
|
95
76
|
index_js_1.coinsList[coin2].type,
|
|
96
|
-
|
|
77
|
+
rewardType,
|
|
97
78
|
],
|
|
98
79
|
arguments: [
|
|
99
80
|
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
@@ -101,69 +82,81 @@ async function claimRewardsTxb(userAddress, poolName) {
|
|
|
101
82
|
txb.object(pool.investorId),
|
|
102
83
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
103
84
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
104
|
-
txb.object(
|
|
85
|
+
txb.object(pool.parentPoolId),
|
|
105
86
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
106
87
|
],
|
|
107
88
|
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
93
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
108
94
|
txb.moveCall({
|
|
109
|
-
target: `${pool.packageId}::
|
|
95
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_reward`,
|
|
110
96
|
typeArguments: [
|
|
111
97
|
index_js_1.coinsList[coin1].type,
|
|
112
98
|
index_js_1.coinsList[coin2].type,
|
|
113
|
-
|
|
114
|
-
],
|
|
115
|
-
arguments: [
|
|
116
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
117
|
-
txb.object(pool.poolId),
|
|
118
|
-
txb.object(pool.investorId),
|
|
119
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
120
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
121
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
|
|
122
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
123
|
-
],
|
|
124
|
-
});
|
|
125
|
-
const blueBalance = txb.moveCall({
|
|
126
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
127
|
-
typeArguments: [
|
|
128
|
-
index_js_1.coinsList["SUI"].type,
|
|
129
|
-
index_js_1.coinsList["USDC"].type,
|
|
130
|
-
index_js_1.coinsList["BLUE"].type,
|
|
99
|
+
rewardType,
|
|
131
100
|
],
|
|
132
101
|
arguments: [
|
|
133
|
-
txb.object(receipts[0].objectId),
|
|
134
102
|
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
135
103
|
txb.object(pool.poolId),
|
|
136
104
|
txb.object(pool.investorId),
|
|
137
105
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
138
106
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
139
|
-
txb.object(
|
|
107
|
+
txb.object(pool.parentPoolId),
|
|
140
108
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
141
109
|
],
|
|
142
110
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return txb;
|
|
114
|
+
}
|
|
115
|
+
async function claimRewardsTxb(userAddress, poolName) {
|
|
116
|
+
const { getReceipts } = await Promise.resolve().then(() => __importStar(require("../index.js")));
|
|
117
|
+
try {
|
|
118
|
+
const receipts = await getReceipts(poolName, userAddress, true);
|
|
119
|
+
const txb = await collectRewardTxb(poolName, true); //false for now
|
|
120
|
+
const bluefinPool = (await (0, index_js_1.getParentPool)(poolName, false));
|
|
121
|
+
const pool = index_js_1.poolInfo[poolName];
|
|
122
|
+
const coin1 = index_js_1.doubleAssetPoolCoinMap[poolName].coin1;
|
|
123
|
+
const coin2 = index_js_1.doubleAssetPoolCoinMap[poolName].coin2;
|
|
124
|
+
const rewards = [];
|
|
125
|
+
if (poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC" ||
|
|
126
|
+
poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC") {
|
|
127
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
128
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
129
|
+
const balance = txb.moveCall({
|
|
130
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
131
|
+
typeArguments: [
|
|
132
|
+
index_js_1.coinsList[coin1].type,
|
|
133
|
+
index_js_1.coinsList[coin2].type,
|
|
134
|
+
rewardType,
|
|
135
|
+
],
|
|
136
|
+
arguments: [
|
|
137
|
+
txb.object(receipts[0].objectId),
|
|
138
|
+
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
139
|
+
txb.object(pool.poolId),
|
|
140
|
+
txb.object(pool.investorId),
|
|
141
|
+
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
142
|
+
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
143
|
+
txb.object(pool.parentPoolId),
|
|
144
|
+
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
const coin = txb.moveCall({
|
|
148
|
+
target: "0x2::coin::from_balance",
|
|
149
|
+
typeArguments: [rewardType],
|
|
150
|
+
arguments: [balance],
|
|
151
|
+
});
|
|
152
|
+
rewards.push(coin);
|
|
153
|
+
}
|
|
154
|
+
const tBalance = txb.moveCall({
|
|
162
155
|
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
163
156
|
typeArguments: [
|
|
164
|
-
index_js_1.coinsList[
|
|
165
|
-
index_js_1.coinsList[
|
|
166
|
-
index_js_1.coinsList[
|
|
157
|
+
index_js_1.coinsList[coin1].type,
|
|
158
|
+
index_js_1.coinsList[coin2].type,
|
|
159
|
+
index_js_1.coinsList[coin1].type,
|
|
167
160
|
],
|
|
168
161
|
arguments: [
|
|
169
162
|
txb.object(receipts[0].objectId),
|
|
@@ -172,16 +165,16 @@ async function claimRewardsTxb(userAddress, poolName) {
|
|
|
172
165
|
txb.object(pool.investorId),
|
|
173
166
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
174
167
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
175
|
-
txb.object(
|
|
168
|
+
txb.object(pool.parentPoolId),
|
|
176
169
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
177
170
|
],
|
|
178
171
|
});
|
|
179
|
-
const
|
|
172
|
+
const sBalance = txb.moveCall({
|
|
180
173
|
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
181
174
|
typeArguments: [
|
|
182
|
-
index_js_1.coinsList[
|
|
183
|
-
index_js_1.coinsList[
|
|
184
|
-
index_js_1.coinsList[
|
|
175
|
+
index_js_1.coinsList[coin1].type,
|
|
176
|
+
index_js_1.coinsList[coin2].type,
|
|
177
|
+
index_js_1.coinsList[coin2].type,
|
|
185
178
|
],
|
|
186
179
|
arguments: [
|
|
187
180
|
txb.object(receipts[0].objectId),
|
|
@@ -190,92 +183,58 @@ async function claimRewardsTxb(userAddress, poolName) {
|
|
|
190
183
|
txb.object(pool.investorId),
|
|
191
184
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
192
185
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
193
|
-
txb.object(
|
|
186
|
+
txb.object(pool.parentPoolId),
|
|
194
187
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
195
188
|
],
|
|
196
189
|
});
|
|
197
|
-
const
|
|
198
|
-
target: "0x2::coin::from_balance",
|
|
199
|
-
typeArguments: [index_js_1.coinsList["BLUE"].type],
|
|
200
|
-
arguments: [blueBalance],
|
|
201
|
-
});
|
|
202
|
-
const stsuiCoin = txb.moveCall({
|
|
190
|
+
const tCoin = txb.moveCall({
|
|
203
191
|
target: "0x2::coin::from_balance",
|
|
204
|
-
typeArguments: [index_js_1.coinsList[
|
|
205
|
-
arguments: [
|
|
206
|
-
});
|
|
207
|
-
const suiCoin = txb.moveCall({
|
|
208
|
-
target: "0x2::coin::from_balance",
|
|
209
|
-
typeArguments: [index_js_1.coinsList["SUI"].type],
|
|
210
|
-
arguments: [suiBalance],
|
|
211
|
-
});
|
|
212
|
-
const usdcCoin = txb.moveCall({
|
|
213
|
-
target: "0x2::coin::from_balance",
|
|
214
|
-
typeArguments: [index_js_1.coinsList["USDC"].type],
|
|
215
|
-
arguments: [usdcBalance],
|
|
216
|
-
});
|
|
217
|
-
rewards.push(blueCoin);
|
|
218
|
-
rewards.push(stsuiCoin);
|
|
219
|
-
rewards.push(suiCoin);
|
|
220
|
-
rewards.push(usdcCoin);
|
|
221
|
-
}
|
|
222
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC") {
|
|
223
|
-
txb.moveCall({
|
|
224
|
-
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
|
|
225
|
-
typeArguments: [
|
|
226
|
-
index_js_1.coinsList["SUIUSDT"].type,
|
|
227
|
-
index_js_1.coinsList["USDC"].type,
|
|
228
|
-
index_js_1.coinsList["SUI"].type,
|
|
229
|
-
],
|
|
230
|
-
arguments: [
|
|
231
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
232
|
-
txb.object(pool.investorId),
|
|
233
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
234
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
|
|
235
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
|
|
236
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
237
|
-
],
|
|
238
|
-
});
|
|
239
|
-
const blueBalance = txb.moveCall({
|
|
240
|
-
target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
241
|
-
typeArguments: [
|
|
242
|
-
index_js_1.coinsList["SUIUSDT"].type,
|
|
243
|
-
index_js_1.coinsList["USDC"].type,
|
|
244
|
-
index_js_1.coinsList["BLUE"].type,
|
|
245
|
-
index_js_1.coinsList["SUI"].type,
|
|
246
|
-
],
|
|
247
|
-
arguments: [
|
|
248
|
-
txb.object(receipts[0].objectId),
|
|
249
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
250
|
-
txb.object(pool.poolId),
|
|
251
|
-
txb.object(pool.investorId),
|
|
252
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
253
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
254
|
-
txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
|
|
255
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
|
|
256
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
|
|
257
|
-
txb.object(index_js_1.cetusPoolMap["USDC-SUIUSDT"]),
|
|
258
|
-
txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
|
|
259
|
-
txb.object((0, index_js_1.getConf)().LST_INFO),
|
|
260
|
-
txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
|
|
261
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
262
|
-
],
|
|
192
|
+
typeArguments: [index_js_1.coinsList[coin1].type],
|
|
193
|
+
arguments: [tBalance],
|
|
263
194
|
});
|
|
264
|
-
const
|
|
195
|
+
const sCoin = txb.moveCall({
|
|
265
196
|
target: "0x2::coin::from_balance",
|
|
266
|
-
typeArguments: [index_js_1.coinsList[
|
|
267
|
-
arguments: [
|
|
197
|
+
typeArguments: [index_js_1.coinsList[coin2].type],
|
|
198
|
+
arguments: [sBalance],
|
|
268
199
|
});
|
|
269
|
-
rewards.push(
|
|
200
|
+
rewards.push(tCoin);
|
|
201
|
+
rewards.push(sCoin);
|
|
270
202
|
}
|
|
271
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-
|
|
272
|
-
|
|
273
|
-
|
|
203
|
+
else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
|
|
204
|
+
poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
|
|
205
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
206
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
207
|
+
const balance = txb.moveCall({
|
|
208
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
|
|
209
|
+
typeArguments: [
|
|
210
|
+
index_js_1.coinsList[coin1].type,
|
|
211
|
+
index_js_1.coinsList[coin2].type,
|
|
212
|
+
rewardType,
|
|
213
|
+
],
|
|
214
|
+
arguments: [
|
|
215
|
+
txb.object(receipts[0].objectId),
|
|
216
|
+
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
217
|
+
txb.object(pool.poolId),
|
|
218
|
+
txb.object(pool.investorId),
|
|
219
|
+
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
220
|
+
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
221
|
+
txb.object(pool.parentPoolId),
|
|
222
|
+
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
223
|
+
],
|
|
224
|
+
});
|
|
225
|
+
const coin = txb.moveCall({
|
|
226
|
+
target: "0x2::coin::from_balance",
|
|
227
|
+
typeArguments: [rewardType],
|
|
228
|
+
arguments: [balance],
|
|
229
|
+
});
|
|
230
|
+
rewards.push(coin);
|
|
231
|
+
}
|
|
232
|
+
const tBalance = txb.moveCall({
|
|
233
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
|
|
274
234
|
typeArguments: [
|
|
275
|
-
index_js_1.coinsList[
|
|
276
|
-
index_js_1.coinsList[
|
|
277
|
-
index_js_1.coinsList[
|
|
278
|
-
index_js_1.coinsList["SUI"].type,
|
|
235
|
+
index_js_1.coinsList[coin1].type,
|
|
236
|
+
index_js_1.coinsList[coin2].type,
|
|
237
|
+
index_js_1.coinsList[coin1].type,
|
|
279
238
|
],
|
|
280
239
|
arguments: [
|
|
281
240
|
txb.object(receipts[0].objectId),
|
|
@@ -284,30 +243,16 @@ async function claimRewardsTxb(userAddress, poolName) {
|
|
|
284
243
|
txb.object(pool.investorId),
|
|
285
244
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
286
245
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
287
|
-
txb.object(
|
|
288
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_DEEP_BLUE_POOL),
|
|
289
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
|
|
290
|
-
txb.object(index_js_1.cetusPoolMap["BLUE-DEEP"]),
|
|
291
|
-
txb.object(index_js_1.cetusPoolMap["BLUE-SUI"]),
|
|
292
|
-
txb.object((0, index_js_1.getConf)().LST_INFO),
|
|
293
|
-
txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
|
|
246
|
+
txb.object(pool.parentPoolId),
|
|
294
247
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
295
248
|
],
|
|
296
249
|
});
|
|
297
|
-
const
|
|
298
|
-
target:
|
|
299
|
-
typeArguments: [index_js_1.coinsList["BLUE"].type],
|
|
300
|
-
arguments: [blueBalance],
|
|
301
|
-
});
|
|
302
|
-
rewards.push(blueCoin);
|
|
303
|
-
}
|
|
304
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
|
|
305
|
-
const blueBalance = txb.moveCall({
|
|
306
|
-
target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v2`,
|
|
250
|
+
const sBalance = txb.moveCall({
|
|
251
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
|
|
307
252
|
typeArguments: [
|
|
308
|
-
index_js_1.coinsList[
|
|
309
|
-
index_js_1.coinsList[
|
|
310
|
-
index_js_1.coinsList[
|
|
253
|
+
index_js_1.coinsList[coin1].type,
|
|
254
|
+
index_js_1.coinsList[coin2].type,
|
|
255
|
+
index_js_1.coinsList[coin2].type,
|
|
311
256
|
],
|
|
312
257
|
arguments: [
|
|
313
258
|
txb.object(receipts[0].objectId),
|
|
@@ -316,250 +261,75 @@ async function claimRewardsTxb(userAddress, poolName) {
|
|
|
316
261
|
txb.object(pool.investorId),
|
|
317
262
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
318
263
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
319
|
-
txb.object(
|
|
320
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
|
|
321
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
|
|
322
|
-
txb.object(index_js_1.cetusPoolMap["DEEP-SUI"]),
|
|
323
|
-
txb.object((0, index_js_1.getConf)().LST_INFO),
|
|
324
|
-
txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
|
|
264
|
+
txb.object(pool.parentPoolId),
|
|
325
265
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
326
266
|
],
|
|
327
267
|
});
|
|
328
|
-
const
|
|
268
|
+
const tCoin = txb.moveCall({
|
|
329
269
|
target: "0x2::coin::from_balance",
|
|
330
|
-
typeArguments: [index_js_1.coinsList[
|
|
331
|
-
arguments: [
|
|
270
|
+
typeArguments: [index_js_1.coinsList[coin1].type],
|
|
271
|
+
arguments: [tBalance],
|
|
332
272
|
});
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI") {
|
|
336
|
-
const blueBalance = txb.moveCall({
|
|
337
|
-
target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v2`,
|
|
338
|
-
typeArguments: [
|
|
339
|
-
index_js_1.coinsList["BLUE"].type,
|
|
340
|
-
index_js_1.coinsList["SUI"].type,
|
|
341
|
-
index_js_1.coinsList["DEEP"].type,
|
|
342
|
-
],
|
|
343
|
-
arguments: [
|
|
344
|
-
txb.object(receipts[0].objectId),
|
|
345
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
346
|
-
txb.object(pool.poolId),
|
|
347
|
-
txb.object(pool.investorId),
|
|
348
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
349
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
350
|
-
txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
|
|
351
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
|
|
352
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
|
|
353
|
-
txb.object(index_js_1.cetusPoolMap["BLUE-SUI"]),
|
|
354
|
-
txb.object((0, index_js_1.getConf)().LST_INFO),
|
|
355
|
-
txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
|
|
356
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
357
|
-
],
|
|
358
|
-
});
|
|
359
|
-
const blueCoin = txb.moveCall({
|
|
273
|
+
const sCoin = txb.moveCall({
|
|
360
274
|
target: "0x2::coin::from_balance",
|
|
361
|
-
typeArguments: [index_js_1.coinsList[
|
|
362
|
-
arguments: [
|
|
275
|
+
typeArguments: [index_js_1.coinsList[coin2].type],
|
|
276
|
+
arguments: [sBalance],
|
|
363
277
|
});
|
|
364
|
-
rewards.push(
|
|
278
|
+
rewards.push(tCoin);
|
|
279
|
+
rewards.push(sCoin);
|
|
365
280
|
}
|
|
366
|
-
else
|
|
367
|
-
|
|
368
|
-
|
|
281
|
+
else {
|
|
282
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
283
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
284
|
+
const balance = txb.moveCall({
|
|
285
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
|
|
286
|
+
typeArguments: [
|
|
287
|
+
index_js_1.coinsList[coin1].type,
|
|
288
|
+
index_js_1.coinsList[coin2].type,
|
|
289
|
+
rewardType,
|
|
290
|
+
],
|
|
291
|
+
arguments: [
|
|
292
|
+
txb.object(receipts[0].objectId),
|
|
293
|
+
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
294
|
+
txb.object(pool.poolId),
|
|
295
|
+
txb.object(pool.investorId),
|
|
296
|
+
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
297
|
+
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
298
|
+
txb.object(pool.parentPoolId),
|
|
299
|
+
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
300
|
+
],
|
|
301
|
+
});
|
|
302
|
+
const coin = txb.moveCall({
|
|
303
|
+
target: "0x2::coin::from_balance",
|
|
304
|
+
typeArguments: [rewardType],
|
|
305
|
+
arguments: [balance],
|
|
306
|
+
});
|
|
307
|
+
rewards.push(coin);
|
|
308
|
+
}
|
|
309
|
+
const tBalance = txb.moveCall({
|
|
310
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
|
|
369
311
|
typeArguments: [
|
|
370
312
|
index_js_1.coinsList[coin1].type,
|
|
371
313
|
index_js_1.coinsList[coin2].type,
|
|
372
|
-
index_js_1.coinsList["BLUE"].type,
|
|
373
|
-
],
|
|
374
|
-
arguments: [
|
|
375
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
376
|
-
txb.object(pool.poolId),
|
|
377
|
-
txb.object(pool.investorId),
|
|
378
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
379
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
380
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
|
|
381
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
382
|
-
],
|
|
383
|
-
});
|
|
384
|
-
txb.moveCall({
|
|
385
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
|
|
386
|
-
typeArguments: [
|
|
387
314
|
index_js_1.coinsList[coin1].type,
|
|
388
|
-
index_js_1.coinsList[coin2].type,
|
|
389
|
-
index_js_1.coinsList["STSUI"].type,
|
|
390
315
|
],
|
|
391
316
|
arguments: [
|
|
317
|
+
txb.object(receipts[0].objectId),
|
|
392
318
|
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
393
319
|
txb.object(pool.poolId),
|
|
394
320
|
txb.object(pool.investorId),
|
|
395
321
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
396
322
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
397
|
-
txb.object(
|
|
323
|
+
txb.object(pool.parentPoolId),
|
|
398
324
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
399
325
|
],
|
|
400
326
|
});
|
|
401
|
-
txb.moveCall({
|
|
402
|
-
target: `${pool.packageId}::
|
|
327
|
+
const sBalance = txb.moveCall({
|
|
328
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
|
|
403
329
|
typeArguments: [
|
|
404
330
|
index_js_1.coinsList[coin1].type,
|
|
405
331
|
index_js_1.coinsList[coin2].type,
|
|
406
|
-
index_js_1.coinsList[
|
|
407
|
-
],
|
|
408
|
-
arguments: [
|
|
409
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
410
|
-
txb.object(pool.poolId),
|
|
411
|
-
txb.object(pool.investorId),
|
|
412
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
413
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
414
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
|
|
415
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
416
|
-
],
|
|
417
|
-
});
|
|
418
|
-
const blueBalance = txb.moveCall({
|
|
419
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
420
|
-
typeArguments: [
|
|
421
|
-
index_js_1.coinsList["SUI"].type,
|
|
422
|
-
index_js_1.coinsList["LBTC"].type,
|
|
423
|
-
index_js_1.coinsList["BLUE"].type,
|
|
424
|
-
],
|
|
425
|
-
arguments: [
|
|
426
|
-
txb.object(receipts[0].objectId),
|
|
427
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
428
|
-
txb.object(pool.poolId),
|
|
429
|
-
txb.object(pool.investorId),
|
|
430
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
431
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
432
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
|
|
433
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
434
|
-
],
|
|
435
|
-
});
|
|
436
|
-
const stsuiBalance = txb.moveCall({
|
|
437
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
438
|
-
typeArguments: [
|
|
439
|
-
index_js_1.coinsList["SUI"].type,
|
|
440
|
-
index_js_1.coinsList["LBTC"].type,
|
|
441
|
-
index_js_1.coinsList["STSUI"].type,
|
|
442
|
-
],
|
|
443
|
-
arguments: [
|
|
444
|
-
txb.object(receipts[0].objectId),
|
|
445
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
446
|
-
txb.object(pool.poolId),
|
|
447
|
-
txb.object(pool.investorId),
|
|
448
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
449
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
450
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
|
|
451
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
452
|
-
],
|
|
453
|
-
});
|
|
454
|
-
const suiBalance = txb.moveCall({
|
|
455
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
456
|
-
typeArguments: [
|
|
457
|
-
index_js_1.coinsList["SUI"].type,
|
|
458
|
-
index_js_1.coinsList["LBTC"].type,
|
|
459
|
-
index_js_1.coinsList["SUI"].type,
|
|
460
|
-
],
|
|
461
|
-
arguments: [
|
|
462
|
-
txb.object(receipts[0].objectId),
|
|
463
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
464
|
-
txb.object(pool.poolId),
|
|
465
|
-
txb.object(pool.investorId),
|
|
466
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
467
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
468
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
|
|
469
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
470
|
-
],
|
|
471
|
-
});
|
|
472
|
-
const lbtcBalance = txb.moveCall({
|
|
473
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
474
|
-
typeArguments: [
|
|
475
|
-
index_js_1.coinsList["SUI"].type,
|
|
476
|
-
index_js_1.coinsList["LBTC"].type,
|
|
477
|
-
index_js_1.coinsList["LBTC"].type,
|
|
478
|
-
],
|
|
479
|
-
arguments: [
|
|
480
|
-
txb.object(receipts[0].objectId),
|
|
481
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
482
|
-
txb.object(pool.poolId),
|
|
483
|
-
txb.object(pool.investorId),
|
|
484
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
485
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
486
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
|
|
487
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
488
|
-
],
|
|
489
|
-
});
|
|
490
|
-
const deepBalance = txb.moveCall({
|
|
491
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
492
|
-
typeArguments: [
|
|
493
|
-
index_js_1.coinsList["SUI"].type,
|
|
494
|
-
index_js_1.coinsList["LBTC"].type,
|
|
495
|
-
index_js_1.coinsList["DEEP"].type,
|
|
496
|
-
],
|
|
497
|
-
arguments: [
|
|
498
|
-
txb.object(receipts[0].objectId),
|
|
499
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
500
|
-
txb.object(pool.poolId),
|
|
501
|
-
txb.object(pool.investorId),
|
|
502
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
503
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
504
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
|
|
505
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
506
|
-
],
|
|
507
|
-
});
|
|
508
|
-
const blueCoin = txb.moveCall({
|
|
509
|
-
target: "0x2::coin::from_balance",
|
|
510
|
-
typeArguments: [index_js_1.coinsList["BLUE"].type],
|
|
511
|
-
arguments: [blueBalance],
|
|
512
|
-
});
|
|
513
|
-
const stsuiCoin = txb.moveCall({
|
|
514
|
-
target: "0x2::coin::from_balance",
|
|
515
|
-
typeArguments: [index_js_1.coinsList["STSUI"].type],
|
|
516
|
-
arguments: [stsuiBalance],
|
|
517
|
-
});
|
|
518
|
-
const suiCoin = txb.moveCall({
|
|
519
|
-
target: "0x2::coin::from_balance",
|
|
520
|
-
typeArguments: [index_js_1.coinsList["SUI"].type],
|
|
521
|
-
arguments: [suiBalance],
|
|
522
|
-
});
|
|
523
|
-
const lbtcCoin = txb.moveCall({
|
|
524
|
-
target: "0x2::coin::from_balance",
|
|
525
|
-
typeArguments: [index_js_1.coinsList["LBTC"].type],
|
|
526
|
-
arguments: [lbtcBalance],
|
|
527
|
-
});
|
|
528
|
-
const deepCoin = txb.moveCall({
|
|
529
|
-
target: "0x2::coin::from_balance",
|
|
530
|
-
typeArguments: [index_js_1.coinsList["DEEP"].type],
|
|
531
|
-
arguments: [deepBalance],
|
|
532
|
-
});
|
|
533
|
-
rewards.push(blueCoin);
|
|
534
|
-
rewards.push(stsuiCoin);
|
|
535
|
-
rewards.push(suiCoin);
|
|
536
|
-
rewards.push(lbtcCoin);
|
|
537
|
-
rewards.push(deepCoin);
|
|
538
|
-
}
|
|
539
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-WAL-USDC") {
|
|
540
|
-
txb.moveCall({
|
|
541
|
-
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
|
|
542
|
-
typeArguments: [
|
|
543
|
-
index_js_1.coinsList["WAL"].type,
|
|
544
|
-
index_js_1.coinsList["USDC"].type,
|
|
545
|
-
index_js_1.coinsList["SUI"].type,
|
|
546
|
-
],
|
|
547
|
-
arguments: [
|
|
548
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
549
|
-
txb.object(pool.investorId),
|
|
550
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
551
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_WAL_USDC_POOL),
|
|
552
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
|
|
553
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
554
|
-
],
|
|
555
|
-
});
|
|
556
|
-
const blueBalance = txb.moveCall({
|
|
557
|
-
target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
558
|
-
typeArguments: [
|
|
559
|
-
index_js_1.coinsList["WAL"].type,
|
|
560
|
-
index_js_1.coinsList["USDC"].type,
|
|
561
|
-
index_js_1.coinsList["BLUE"].type,
|
|
562
|
-
index_js_1.coinsList["SUI"].type,
|
|
332
|
+
index_js_1.coinsList[coin2].type,
|
|
563
333
|
],
|
|
564
334
|
arguments: [
|
|
565
335
|
txb.object(receipts[0].objectId),
|
|
@@ -568,71 +338,22 @@ async function claimRewardsTxb(userAddress, poolName) {
|
|
|
568
338
|
txb.object(pool.investorId),
|
|
569
339
|
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
570
340
|
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
571
|
-
txb.object(
|
|
572
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_WAL_USDC_POOL),
|
|
573
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
|
|
574
|
-
txb.object(index_js_1.cetusPoolMap["USDC-WAL"]),
|
|
575
|
-
txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
|
|
576
|
-
txb.object((0, index_js_1.getConf)().LST_INFO),
|
|
577
|
-
txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
|
|
341
|
+
txb.object(pool.parentPoolId),
|
|
578
342
|
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
579
343
|
],
|
|
580
344
|
});
|
|
581
|
-
const
|
|
345
|
+
const tCoin = txb.moveCall({
|
|
582
346
|
target: "0x2::coin::from_balance",
|
|
583
|
-
typeArguments: [index_js_1.coinsList[
|
|
584
|
-
arguments: [
|
|
585
|
-
});
|
|
586
|
-
rewards.push(blueCoin);
|
|
587
|
-
}
|
|
588
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC-ZERO-ZERO") {
|
|
589
|
-
txb.moveCall({
|
|
590
|
-
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
|
|
591
|
-
typeArguments: [
|
|
592
|
-
index_js_1.coinsList["SUIUSDT"].type,
|
|
593
|
-
index_js_1.coinsList["USDC"].type,
|
|
594
|
-
index_js_1.coinsList["SUI"].type,
|
|
595
|
-
],
|
|
596
|
-
arguments: [
|
|
597
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
598
|
-
txb.object(pool.investorId),
|
|
599
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
600
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_ZERO_ZERO_POOL),
|
|
601
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
|
|
602
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
603
|
-
],
|
|
604
|
-
});
|
|
605
|
-
const blueBalance = txb.moveCall({
|
|
606
|
-
target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
607
|
-
typeArguments: [
|
|
608
|
-
index_js_1.coinsList["SUIUSDT"].type,
|
|
609
|
-
index_js_1.coinsList["USDC"].type,
|
|
610
|
-
index_js_1.coinsList["BLUE"].type,
|
|
611
|
-
index_js_1.coinsList["SUI"].type,
|
|
612
|
-
],
|
|
613
|
-
arguments: [
|
|
614
|
-
txb.object(receipts[0].objectId),
|
|
615
|
-
txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
616
|
-
txb.object(pool.poolId),
|
|
617
|
-
txb.object(pool.investorId),
|
|
618
|
-
txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
|
|
619
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
|
|
620
|
-
txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
|
|
621
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_ZERO_ZERO_POOL),
|
|
622
|
-
txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
|
|
623
|
-
txb.object(index_js_1.cetusPoolMap["USDC-SUIUSDT"]),
|
|
624
|
-
txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
|
|
625
|
-
txb.object((0, index_js_1.getConf)().LST_INFO),
|
|
626
|
-
txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
|
|
627
|
-
txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
628
|
-
],
|
|
347
|
+
typeArguments: [index_js_1.coinsList[coin1].type],
|
|
348
|
+
arguments: [tBalance],
|
|
629
349
|
});
|
|
630
|
-
const
|
|
350
|
+
const sCoin = txb.moveCall({
|
|
631
351
|
target: "0x2::coin::from_balance",
|
|
632
|
-
typeArguments: [index_js_1.coinsList[
|
|
633
|
-
arguments: [
|
|
352
|
+
typeArguments: [index_js_1.coinsList[coin2].type],
|
|
353
|
+
arguments: [sBalance],
|
|
634
354
|
});
|
|
635
|
-
rewards.push(
|
|
355
|
+
rewards.push(tCoin);
|
|
356
|
+
rewards.push(sCoin);
|
|
636
357
|
}
|
|
637
358
|
return { txb: txb, coinOut: rewards };
|
|
638
359
|
}
|
|
@@ -665,6 +386,10 @@ async function pendingRewardAmount(userAddress, poolName) {
|
|
|
665
386
|
});
|
|
666
387
|
const coinTypeToCoin = maps_js_1.coinTypeMap;
|
|
667
388
|
Object.keys(curAcc).forEach((type) => {
|
|
389
|
+
if (!coinTypeToCoin[type]) {
|
|
390
|
+
console.error("coin not present", type);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
668
393
|
const cur = new decimal_js_1.Decimal(curAcc[type]);
|
|
669
394
|
const last = new decimal_js_1.Decimal(type in lastAcc ? lastAcc[type] : "0");
|
|
670
395
|
const pending = new decimal_js_1.Decimal(type in userPendingReward ? userPendingReward[type] : "0");
|