@alphafi/alphafi-sdk 0.0.86 → 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/coins.d.ts.map +1 -1
- package/dist/cjs/common/coins.js +12 -0
- package/dist/cjs/common/coins.js.map +1 -1
- 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/pyth.d.ts +1 -1
- package/dist/cjs/common/pyth.d.ts.map +1 -1
- package/dist/cjs/common/pyth.js.map +1 -1
- package/dist/cjs/common/types.d.ts +10 -3
- 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/coins.d.ts.map +1 -1
- package/dist/esm/common/coins.js +12 -0
- package/dist/esm/common/coins.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/pyth.d.ts +1 -1
- package/dist/esm/common/pyth.d.ts.map +1 -1
- package/dist/esm/common/pyth.js.map +1 -1
- package/dist/esm/common/types.d.ts +10 -3
- 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
|
@@ -1,72 +1,52 @@
|
|
|
1
1
|
import { Decimal } from "decimal.js";
|
|
2
|
-
import { getConf, poolInfo, coinsList,
|
|
2
|
+
import { getConf, poolInfo, coinsList, getPool, doubleAssetPoolCoinMap, getParentPool, } from "../index.js";
|
|
3
3
|
import { Transaction } from "@mysten/sui/transactions";
|
|
4
4
|
import { coinTypeMap } from "../common/maps.js";
|
|
5
|
-
export async function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
export async function collectRewardTxb(poolName, ignoreCache, tx) {
|
|
6
|
+
let txb;
|
|
7
|
+
if (tx) {
|
|
8
|
+
txb = tx;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
txb = new Transaction();
|
|
12
|
+
}
|
|
13
|
+
const bluefinPool = (await getParentPool(poolName, ignoreCache));
|
|
14
|
+
const pool = poolInfo[poolName];
|
|
15
|
+
const coin1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
16
|
+
const coin2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
17
|
+
if (poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC" ||
|
|
18
|
+
poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC") {
|
|
19
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
20
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
15
21
|
txb.moveCall({
|
|
16
|
-
target: `${pool.packageId}::
|
|
17
|
-
typeArguments: [
|
|
18
|
-
coinsList["USDT"].type,
|
|
19
|
-
coinsList["USDC"].type,
|
|
20
|
-
coinsList["SUI"].type,
|
|
21
|
-
],
|
|
22
|
-
arguments: [
|
|
23
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
24
|
-
txb.object(pool.investorId),
|
|
25
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
26
|
-
txb.object(getConf().BLUEFIN_USDT_USDC_POOL),
|
|
27
|
-
txb.object(getConf().BLUEFIN_SUI_USDC_POOL),
|
|
28
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
29
|
-
],
|
|
30
|
-
});
|
|
31
|
-
const blueBalance = txb.moveCall({
|
|
32
|
-
target: `${poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
22
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
|
|
33
23
|
typeArguments: [
|
|
34
|
-
coinsList[
|
|
35
|
-
coinsList[
|
|
36
|
-
|
|
37
|
-
coinsList["SUI"].type,
|
|
24
|
+
coinsList[coin1].type,
|
|
25
|
+
coinsList[coin2].type,
|
|
26
|
+
rewardType,
|
|
38
27
|
],
|
|
39
28
|
arguments: [
|
|
40
|
-
txb.object(receipts[0].objectId),
|
|
41
29
|
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
42
30
|
txb.object(pool.poolId),
|
|
43
31
|
txb.object(pool.investorId),
|
|
44
32
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
45
33
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
46
|
-
txb.object(
|
|
47
|
-
txb.object(getConf().BLUEFIN_USDT_USDC_POOL),
|
|
48
|
-
txb.object(getConf().BLUEFIN_BLUE_SUI_POOL),
|
|
49
|
-
txb.object(cetusPoolMap["USDC-USDT"]),
|
|
50
|
-
txb.object(cetusPoolMap["USDC-SUI"]),
|
|
51
|
-
txb.object(getConf().LST_INFO),
|
|
52
|
-
txb.object(getConf().SUI_SYSTEM_STATE),
|
|
34
|
+
txb.object(pool.parentPoolId),
|
|
53
35
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
54
36
|
],
|
|
55
37
|
});
|
|
56
|
-
const blueCoin = txb.moveCall({
|
|
57
|
-
target: "0x2::coin::from_balance",
|
|
58
|
-
typeArguments: [coinsList["BLUE"].type],
|
|
59
|
-
arguments: [blueBalance],
|
|
60
|
-
});
|
|
61
|
-
rewards.push(blueCoin);
|
|
62
38
|
}
|
|
63
|
-
|
|
39
|
+
}
|
|
40
|
+
else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
|
|
41
|
+
poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
|
|
42
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
43
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
64
44
|
txb.moveCall({
|
|
65
|
-
target: `${pool.packageId}::
|
|
45
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::collect_reward`,
|
|
66
46
|
typeArguments: [
|
|
67
47
|
coinsList[coin1].type,
|
|
68
48
|
coinsList[coin2].type,
|
|
69
|
-
|
|
49
|
+
rewardType,
|
|
70
50
|
],
|
|
71
51
|
arguments: [
|
|
72
52
|
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
@@ -74,69 +54,81 @@ export async function claimRewardsTxb(userAddress, poolName) {
|
|
|
74
54
|
txb.object(pool.investorId),
|
|
75
55
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
76
56
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
77
|
-
txb.object(
|
|
57
|
+
txb.object(pool.parentPoolId),
|
|
78
58
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
79
59
|
],
|
|
80
60
|
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
65
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
81
66
|
txb.moveCall({
|
|
82
|
-
target: `${pool.packageId}::
|
|
67
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_reward`,
|
|
83
68
|
typeArguments: [
|
|
84
69
|
coinsList[coin1].type,
|
|
85
70
|
coinsList[coin2].type,
|
|
86
|
-
|
|
87
|
-
],
|
|
88
|
-
arguments: [
|
|
89
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
90
|
-
txb.object(pool.poolId),
|
|
91
|
-
txb.object(pool.investorId),
|
|
92
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
93
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
94
|
-
txb.object(getConf().BLUEFIN_SUI_USDC_POOL),
|
|
95
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
96
|
-
],
|
|
97
|
-
});
|
|
98
|
-
const blueBalance = txb.moveCall({
|
|
99
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
100
|
-
typeArguments: [
|
|
101
|
-
coinsList["SUI"].type,
|
|
102
|
-
coinsList["USDC"].type,
|
|
103
|
-
coinsList["BLUE"].type,
|
|
71
|
+
rewardType,
|
|
104
72
|
],
|
|
105
73
|
arguments: [
|
|
106
|
-
txb.object(receipts[0].objectId),
|
|
107
74
|
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
108
75
|
txb.object(pool.poolId),
|
|
109
76
|
txb.object(pool.investorId),
|
|
110
77
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
111
78
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
112
|
-
txb.object(
|
|
79
|
+
txb.object(pool.parentPoolId),
|
|
113
80
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
114
81
|
],
|
|
115
82
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return txb;
|
|
86
|
+
}
|
|
87
|
+
export async function claimRewardsTxb(userAddress, poolName) {
|
|
88
|
+
const { getReceipts } = await import("../index.js");
|
|
89
|
+
try {
|
|
90
|
+
const receipts = await getReceipts(poolName, userAddress, true);
|
|
91
|
+
const txb = await collectRewardTxb(poolName, true); //false for now
|
|
92
|
+
const bluefinPool = (await getParentPool(poolName, false));
|
|
93
|
+
const pool = poolInfo[poolName];
|
|
94
|
+
const coin1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
95
|
+
const coin2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
96
|
+
const rewards = [];
|
|
97
|
+
if (poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC" ||
|
|
98
|
+
poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC") {
|
|
99
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
100
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
101
|
+
const balance = txb.moveCall({
|
|
102
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
103
|
+
typeArguments: [
|
|
104
|
+
coinsList[coin1].type,
|
|
105
|
+
coinsList[coin2].type,
|
|
106
|
+
rewardType,
|
|
107
|
+
],
|
|
108
|
+
arguments: [
|
|
109
|
+
txb.object(receipts[0].objectId),
|
|
110
|
+
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
111
|
+
txb.object(pool.poolId),
|
|
112
|
+
txb.object(pool.investorId),
|
|
113
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
114
|
+
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
115
|
+
txb.object(pool.parentPoolId),
|
|
116
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
const coin = txb.moveCall({
|
|
120
|
+
target: "0x2::coin::from_balance",
|
|
121
|
+
typeArguments: [rewardType],
|
|
122
|
+
arguments: [balance],
|
|
123
|
+
});
|
|
124
|
+
rewards.push(coin);
|
|
125
|
+
}
|
|
126
|
+
const tBalance = txb.moveCall({
|
|
135
127
|
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
136
128
|
typeArguments: [
|
|
137
|
-
coinsList[
|
|
138
|
-
coinsList[
|
|
139
|
-
coinsList[
|
|
129
|
+
coinsList[coin1].type,
|
|
130
|
+
coinsList[coin2].type,
|
|
131
|
+
coinsList[coin1].type,
|
|
140
132
|
],
|
|
141
133
|
arguments: [
|
|
142
134
|
txb.object(receipts[0].objectId),
|
|
@@ -145,16 +137,16 @@ export async function claimRewardsTxb(userAddress, poolName) {
|
|
|
145
137
|
txb.object(pool.investorId),
|
|
146
138
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
147
139
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
148
|
-
txb.object(
|
|
140
|
+
txb.object(pool.parentPoolId),
|
|
149
141
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
150
142
|
],
|
|
151
143
|
});
|
|
152
|
-
const
|
|
144
|
+
const sBalance = txb.moveCall({
|
|
153
145
|
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
154
146
|
typeArguments: [
|
|
155
|
-
coinsList[
|
|
156
|
-
coinsList[
|
|
157
|
-
coinsList[
|
|
147
|
+
coinsList[coin1].type,
|
|
148
|
+
coinsList[coin2].type,
|
|
149
|
+
coinsList[coin2].type,
|
|
158
150
|
],
|
|
159
151
|
arguments: [
|
|
160
152
|
txb.object(receipts[0].objectId),
|
|
@@ -163,92 +155,58 @@ export async function claimRewardsTxb(userAddress, poolName) {
|
|
|
163
155
|
txb.object(pool.investorId),
|
|
164
156
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
165
157
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
166
|
-
txb.object(
|
|
158
|
+
txb.object(pool.parentPoolId),
|
|
167
159
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
168
160
|
],
|
|
169
161
|
});
|
|
170
|
-
const
|
|
171
|
-
target: "0x2::coin::from_balance",
|
|
172
|
-
typeArguments: [coinsList["BLUE"].type],
|
|
173
|
-
arguments: [blueBalance],
|
|
174
|
-
});
|
|
175
|
-
const stsuiCoin = txb.moveCall({
|
|
162
|
+
const tCoin = txb.moveCall({
|
|
176
163
|
target: "0x2::coin::from_balance",
|
|
177
|
-
typeArguments: [coinsList[
|
|
178
|
-
arguments: [
|
|
179
|
-
});
|
|
180
|
-
const suiCoin = txb.moveCall({
|
|
181
|
-
target: "0x2::coin::from_balance",
|
|
182
|
-
typeArguments: [coinsList["SUI"].type],
|
|
183
|
-
arguments: [suiBalance],
|
|
184
|
-
});
|
|
185
|
-
const usdcCoin = txb.moveCall({
|
|
186
|
-
target: "0x2::coin::from_balance",
|
|
187
|
-
typeArguments: [coinsList["USDC"].type],
|
|
188
|
-
arguments: [usdcBalance],
|
|
189
|
-
});
|
|
190
|
-
rewards.push(blueCoin);
|
|
191
|
-
rewards.push(stsuiCoin);
|
|
192
|
-
rewards.push(suiCoin);
|
|
193
|
-
rewards.push(usdcCoin);
|
|
194
|
-
}
|
|
195
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC") {
|
|
196
|
-
txb.moveCall({
|
|
197
|
-
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
|
|
198
|
-
typeArguments: [
|
|
199
|
-
coinsList["SUIUSDT"].type,
|
|
200
|
-
coinsList["USDC"].type,
|
|
201
|
-
coinsList["SUI"].type,
|
|
202
|
-
],
|
|
203
|
-
arguments: [
|
|
204
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
205
|
-
txb.object(pool.investorId),
|
|
206
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
207
|
-
txb.object(getConf().BLUEFIN_SUIUSDT_USDC_POOL),
|
|
208
|
-
txb.object(getConf().BLUEFIN_SUI_USDC_POOL),
|
|
209
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
210
|
-
],
|
|
211
|
-
});
|
|
212
|
-
const blueBalance = txb.moveCall({
|
|
213
|
-
target: `${poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
214
|
-
typeArguments: [
|
|
215
|
-
coinsList["SUIUSDT"].type,
|
|
216
|
-
coinsList["USDC"].type,
|
|
217
|
-
coinsList["BLUE"].type,
|
|
218
|
-
coinsList["SUI"].type,
|
|
219
|
-
],
|
|
220
|
-
arguments: [
|
|
221
|
-
txb.object(receipts[0].objectId),
|
|
222
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
223
|
-
txb.object(pool.poolId),
|
|
224
|
-
txb.object(pool.investorId),
|
|
225
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
226
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
227
|
-
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
228
|
-
txb.object(getConf().BLUEFIN_SUIUSDT_USDC_POOL),
|
|
229
|
-
txb.object(getConf().BLUEFIN_BLUE_SUI_POOL),
|
|
230
|
-
txb.object(cetusPoolMap["USDC-SUIUSDT"]),
|
|
231
|
-
txb.object(cetusPoolMap["USDC-SUI"]),
|
|
232
|
-
txb.object(getConf().LST_INFO),
|
|
233
|
-
txb.object(getConf().SUI_SYSTEM_STATE),
|
|
234
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
235
|
-
],
|
|
164
|
+
typeArguments: [coinsList[coin1].type],
|
|
165
|
+
arguments: [tBalance],
|
|
236
166
|
});
|
|
237
|
-
const
|
|
167
|
+
const sCoin = txb.moveCall({
|
|
238
168
|
target: "0x2::coin::from_balance",
|
|
239
|
-
typeArguments: [coinsList[
|
|
240
|
-
arguments: [
|
|
169
|
+
typeArguments: [coinsList[coin2].type],
|
|
170
|
+
arguments: [sBalance],
|
|
241
171
|
});
|
|
242
|
-
rewards.push(
|
|
172
|
+
rewards.push(tCoin);
|
|
173
|
+
rewards.push(sCoin);
|
|
243
174
|
}
|
|
244
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-
|
|
245
|
-
|
|
246
|
-
|
|
175
|
+
else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
|
|
176
|
+
poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
|
|
177
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
178
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
179
|
+
const balance = txb.moveCall({
|
|
180
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
|
|
181
|
+
typeArguments: [
|
|
182
|
+
coinsList[coin1].type,
|
|
183
|
+
coinsList[coin2].type,
|
|
184
|
+
rewardType,
|
|
185
|
+
],
|
|
186
|
+
arguments: [
|
|
187
|
+
txb.object(receipts[0].objectId),
|
|
188
|
+
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
189
|
+
txb.object(pool.poolId),
|
|
190
|
+
txb.object(pool.investorId),
|
|
191
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
192
|
+
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
193
|
+
txb.object(pool.parentPoolId),
|
|
194
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
195
|
+
],
|
|
196
|
+
});
|
|
197
|
+
const coin = txb.moveCall({
|
|
198
|
+
target: "0x2::coin::from_balance",
|
|
199
|
+
typeArguments: [rewardType],
|
|
200
|
+
arguments: [balance],
|
|
201
|
+
});
|
|
202
|
+
rewards.push(coin);
|
|
203
|
+
}
|
|
204
|
+
const tBalance = txb.moveCall({
|
|
205
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
|
|
247
206
|
typeArguments: [
|
|
248
|
-
coinsList[
|
|
249
|
-
coinsList[
|
|
250
|
-
coinsList[
|
|
251
|
-
coinsList["SUI"].type,
|
|
207
|
+
coinsList[coin1].type,
|
|
208
|
+
coinsList[coin2].type,
|
|
209
|
+
coinsList[coin1].type,
|
|
252
210
|
],
|
|
253
211
|
arguments: [
|
|
254
212
|
txb.object(receipts[0].objectId),
|
|
@@ -257,30 +215,16 @@ export async function claimRewardsTxb(userAddress, poolName) {
|
|
|
257
215
|
txb.object(pool.investorId),
|
|
258
216
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
259
217
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
260
|
-
txb.object(
|
|
261
|
-
txb.object(getConf().BLUEFIN_DEEP_BLUE_POOL),
|
|
262
|
-
txb.object(getConf().BLUEFIN_BLUE_SUI_POOL),
|
|
263
|
-
txb.object(cetusPoolMap["BLUE-DEEP"]),
|
|
264
|
-
txb.object(cetusPoolMap["BLUE-SUI"]),
|
|
265
|
-
txb.object(getConf().LST_INFO),
|
|
266
|
-
txb.object(getConf().SUI_SYSTEM_STATE),
|
|
218
|
+
txb.object(pool.parentPoolId),
|
|
267
219
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
268
220
|
],
|
|
269
221
|
});
|
|
270
|
-
const
|
|
271
|
-
target:
|
|
272
|
-
typeArguments: [coinsList["BLUE"].type],
|
|
273
|
-
arguments: [blueBalance],
|
|
274
|
-
});
|
|
275
|
-
rewards.push(blueCoin);
|
|
276
|
-
}
|
|
277
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
|
|
278
|
-
const blueBalance = txb.moveCall({
|
|
279
|
-
target: `${poolInfo[poolName].packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v2`,
|
|
222
|
+
const sBalance = txb.moveCall({
|
|
223
|
+
target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
|
|
280
224
|
typeArguments: [
|
|
281
|
-
coinsList[
|
|
282
|
-
coinsList[
|
|
283
|
-
coinsList[
|
|
225
|
+
coinsList[coin1].type,
|
|
226
|
+
coinsList[coin2].type,
|
|
227
|
+
coinsList[coin2].type,
|
|
284
228
|
],
|
|
285
229
|
arguments: [
|
|
286
230
|
txb.object(receipts[0].objectId),
|
|
@@ -289,250 +233,75 @@ export async function claimRewardsTxb(userAddress, poolName) {
|
|
|
289
233
|
txb.object(pool.investorId),
|
|
290
234
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
291
235
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
292
|
-
txb.object(
|
|
293
|
-
txb.object(getConf().BLUEFIN_DEEP_SUI_POOL),
|
|
294
|
-
txb.object(getConf().BLUEFIN_BLUE_SUI_POOL),
|
|
295
|
-
txb.object(cetusPoolMap["DEEP-SUI"]),
|
|
296
|
-
txb.object(getConf().LST_INFO),
|
|
297
|
-
txb.object(getConf().SUI_SYSTEM_STATE),
|
|
236
|
+
txb.object(pool.parentPoolId),
|
|
298
237
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
299
238
|
],
|
|
300
239
|
});
|
|
301
|
-
const
|
|
240
|
+
const tCoin = txb.moveCall({
|
|
302
241
|
target: "0x2::coin::from_balance",
|
|
303
|
-
typeArguments: [coinsList[
|
|
304
|
-
arguments: [
|
|
242
|
+
typeArguments: [coinsList[coin1].type],
|
|
243
|
+
arguments: [tBalance],
|
|
305
244
|
});
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI") {
|
|
309
|
-
const blueBalance = txb.moveCall({
|
|
310
|
-
target: `${poolInfo[poolName].packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v2`,
|
|
311
|
-
typeArguments: [
|
|
312
|
-
coinsList["BLUE"].type,
|
|
313
|
-
coinsList["SUI"].type,
|
|
314
|
-
coinsList["DEEP"].type,
|
|
315
|
-
],
|
|
316
|
-
arguments: [
|
|
317
|
-
txb.object(receipts[0].objectId),
|
|
318
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
319
|
-
txb.object(pool.poolId),
|
|
320
|
-
txb.object(pool.investorId),
|
|
321
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
322
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
323
|
-
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
324
|
-
txb.object(getConf().BLUEFIN_BLUE_SUI_POOL),
|
|
325
|
-
txb.object(getConf().BLUEFIN_DEEP_SUI_POOL),
|
|
326
|
-
txb.object(cetusPoolMap["BLUE-SUI"]),
|
|
327
|
-
txb.object(getConf().LST_INFO),
|
|
328
|
-
txb.object(getConf().SUI_SYSTEM_STATE),
|
|
329
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
330
|
-
],
|
|
331
|
-
});
|
|
332
|
-
const blueCoin = txb.moveCall({
|
|
245
|
+
const sCoin = txb.moveCall({
|
|
333
246
|
target: "0x2::coin::from_balance",
|
|
334
|
-
typeArguments: [coinsList[
|
|
335
|
-
arguments: [
|
|
247
|
+
typeArguments: [coinsList[coin2].type],
|
|
248
|
+
arguments: [sBalance],
|
|
336
249
|
});
|
|
337
|
-
rewards.push(
|
|
250
|
+
rewards.push(tCoin);
|
|
251
|
+
rewards.push(sCoin);
|
|
338
252
|
}
|
|
339
|
-
else
|
|
340
|
-
|
|
341
|
-
|
|
253
|
+
else {
|
|
254
|
+
for (const reward of bluefinPool.content.fields.reward_infos) {
|
|
255
|
+
const rewardType = "0x" + reward.fields.reward_coin_type;
|
|
256
|
+
const balance = txb.moveCall({
|
|
257
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
|
|
258
|
+
typeArguments: [
|
|
259
|
+
coinsList[coin1].type,
|
|
260
|
+
coinsList[coin2].type,
|
|
261
|
+
rewardType,
|
|
262
|
+
],
|
|
263
|
+
arguments: [
|
|
264
|
+
txb.object(receipts[0].objectId),
|
|
265
|
+
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
266
|
+
txb.object(pool.poolId),
|
|
267
|
+
txb.object(pool.investorId),
|
|
268
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
269
|
+
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
270
|
+
txb.object(pool.parentPoolId),
|
|
271
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
272
|
+
],
|
|
273
|
+
});
|
|
274
|
+
const coin = txb.moveCall({
|
|
275
|
+
target: "0x2::coin::from_balance",
|
|
276
|
+
typeArguments: [rewardType],
|
|
277
|
+
arguments: [balance],
|
|
278
|
+
});
|
|
279
|
+
rewards.push(coin);
|
|
280
|
+
}
|
|
281
|
+
const tBalance = txb.moveCall({
|
|
282
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
|
|
342
283
|
typeArguments: [
|
|
343
284
|
coinsList[coin1].type,
|
|
344
285
|
coinsList[coin2].type,
|
|
345
|
-
coinsList["BLUE"].type,
|
|
346
|
-
],
|
|
347
|
-
arguments: [
|
|
348
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
349
|
-
txb.object(pool.poolId),
|
|
350
|
-
txb.object(pool.investorId),
|
|
351
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
352
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
353
|
-
txb.object(getConf().BLUEFIN_SUI_LBTC_POOL),
|
|
354
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
355
|
-
],
|
|
356
|
-
});
|
|
357
|
-
txb.moveCall({
|
|
358
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
|
|
359
|
-
typeArguments: [
|
|
360
286
|
coinsList[coin1].type,
|
|
361
|
-
coinsList[coin2].type,
|
|
362
|
-
coinsList["STSUI"].type,
|
|
363
287
|
],
|
|
364
288
|
arguments: [
|
|
289
|
+
txb.object(receipts[0].objectId),
|
|
365
290
|
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
366
291
|
txb.object(pool.poolId),
|
|
367
292
|
txb.object(pool.investorId),
|
|
368
293
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
369
294
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
370
|
-
txb.object(
|
|
295
|
+
txb.object(pool.parentPoolId),
|
|
371
296
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
372
297
|
],
|
|
373
298
|
});
|
|
374
|
-
txb.moveCall({
|
|
375
|
-
target: `${pool.packageId}::
|
|
299
|
+
const sBalance = txb.moveCall({
|
|
300
|
+
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
|
|
376
301
|
typeArguments: [
|
|
377
302
|
coinsList[coin1].type,
|
|
378
303
|
coinsList[coin2].type,
|
|
379
|
-
coinsList[
|
|
380
|
-
],
|
|
381
|
-
arguments: [
|
|
382
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
383
|
-
txb.object(pool.poolId),
|
|
384
|
-
txb.object(pool.investorId),
|
|
385
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
386
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
387
|
-
txb.object(getConf().BLUEFIN_SUI_LBTC_POOL),
|
|
388
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
389
|
-
],
|
|
390
|
-
});
|
|
391
|
-
const blueBalance = txb.moveCall({
|
|
392
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
393
|
-
typeArguments: [
|
|
394
|
-
coinsList["SUI"].type,
|
|
395
|
-
coinsList["LBTC"].type,
|
|
396
|
-
coinsList["BLUE"].type,
|
|
397
|
-
],
|
|
398
|
-
arguments: [
|
|
399
|
-
txb.object(receipts[0].objectId),
|
|
400
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
401
|
-
txb.object(pool.poolId),
|
|
402
|
-
txb.object(pool.investorId),
|
|
403
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
404
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
405
|
-
txb.object(getConf().BLUEFIN_SUI_LBTC_POOL),
|
|
406
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
407
|
-
],
|
|
408
|
-
});
|
|
409
|
-
const stsuiBalance = txb.moveCall({
|
|
410
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
411
|
-
typeArguments: [
|
|
412
|
-
coinsList["SUI"].type,
|
|
413
|
-
coinsList["LBTC"].type,
|
|
414
|
-
coinsList["STSUI"].type,
|
|
415
|
-
],
|
|
416
|
-
arguments: [
|
|
417
|
-
txb.object(receipts[0].objectId),
|
|
418
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
419
|
-
txb.object(pool.poolId),
|
|
420
|
-
txb.object(pool.investorId),
|
|
421
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
422
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
423
|
-
txb.object(getConf().BLUEFIN_SUI_LBTC_POOL),
|
|
424
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
425
|
-
],
|
|
426
|
-
});
|
|
427
|
-
const suiBalance = txb.moveCall({
|
|
428
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
429
|
-
typeArguments: [
|
|
430
|
-
coinsList["SUI"].type,
|
|
431
|
-
coinsList["LBTC"].type,
|
|
432
|
-
coinsList["SUI"].type,
|
|
433
|
-
],
|
|
434
|
-
arguments: [
|
|
435
|
-
txb.object(receipts[0].objectId),
|
|
436
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
437
|
-
txb.object(pool.poolId),
|
|
438
|
-
txb.object(pool.investorId),
|
|
439
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
440
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
441
|
-
txb.object(getConf().BLUEFIN_SUI_LBTC_POOL),
|
|
442
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
443
|
-
],
|
|
444
|
-
});
|
|
445
|
-
const lbtcBalance = txb.moveCall({
|
|
446
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
447
|
-
typeArguments: [
|
|
448
|
-
coinsList["SUI"].type,
|
|
449
|
-
coinsList["LBTC"].type,
|
|
450
|
-
coinsList["LBTC"].type,
|
|
451
|
-
],
|
|
452
|
-
arguments: [
|
|
453
|
-
txb.object(receipts[0].objectId),
|
|
454
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
455
|
-
txb.object(pool.poolId),
|
|
456
|
-
txb.object(pool.investorId),
|
|
457
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
458
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
459
|
-
txb.object(getConf().BLUEFIN_SUI_LBTC_POOL),
|
|
460
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
461
|
-
],
|
|
462
|
-
});
|
|
463
|
-
const deepBalance = txb.moveCall({
|
|
464
|
-
target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
|
|
465
|
-
typeArguments: [
|
|
466
|
-
coinsList["SUI"].type,
|
|
467
|
-
coinsList["LBTC"].type,
|
|
468
|
-
coinsList["DEEP"].type,
|
|
469
|
-
],
|
|
470
|
-
arguments: [
|
|
471
|
-
txb.object(receipts[0].objectId),
|
|
472
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
473
|
-
txb.object(pool.poolId),
|
|
474
|
-
txb.object(pool.investorId),
|
|
475
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
476
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
477
|
-
txb.object(getConf().BLUEFIN_SUI_LBTC_POOL),
|
|
478
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
479
|
-
],
|
|
480
|
-
});
|
|
481
|
-
const blueCoin = txb.moveCall({
|
|
482
|
-
target: "0x2::coin::from_balance",
|
|
483
|
-
typeArguments: [coinsList["BLUE"].type],
|
|
484
|
-
arguments: [blueBalance],
|
|
485
|
-
});
|
|
486
|
-
const stsuiCoin = txb.moveCall({
|
|
487
|
-
target: "0x2::coin::from_balance",
|
|
488
|
-
typeArguments: [coinsList["STSUI"].type],
|
|
489
|
-
arguments: [stsuiBalance],
|
|
490
|
-
});
|
|
491
|
-
const suiCoin = txb.moveCall({
|
|
492
|
-
target: "0x2::coin::from_balance",
|
|
493
|
-
typeArguments: [coinsList["SUI"].type],
|
|
494
|
-
arguments: [suiBalance],
|
|
495
|
-
});
|
|
496
|
-
const lbtcCoin = txb.moveCall({
|
|
497
|
-
target: "0x2::coin::from_balance",
|
|
498
|
-
typeArguments: [coinsList["LBTC"].type],
|
|
499
|
-
arguments: [lbtcBalance],
|
|
500
|
-
});
|
|
501
|
-
const deepCoin = txb.moveCall({
|
|
502
|
-
target: "0x2::coin::from_balance",
|
|
503
|
-
typeArguments: [coinsList["DEEP"].type],
|
|
504
|
-
arguments: [deepBalance],
|
|
505
|
-
});
|
|
506
|
-
rewards.push(blueCoin);
|
|
507
|
-
rewards.push(stsuiCoin);
|
|
508
|
-
rewards.push(suiCoin);
|
|
509
|
-
rewards.push(lbtcCoin);
|
|
510
|
-
rewards.push(deepCoin);
|
|
511
|
-
}
|
|
512
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-WAL-USDC") {
|
|
513
|
-
txb.moveCall({
|
|
514
|
-
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
|
|
515
|
-
typeArguments: [
|
|
516
|
-
coinsList["WAL"].type,
|
|
517
|
-
coinsList["USDC"].type,
|
|
518
|
-
coinsList["SUI"].type,
|
|
519
|
-
],
|
|
520
|
-
arguments: [
|
|
521
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
522
|
-
txb.object(pool.investorId),
|
|
523
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
524
|
-
txb.object(getConf().BLUEFIN_WAL_USDC_POOL),
|
|
525
|
-
txb.object(getConf().BLUEFIN_SUI_USDC_POOL),
|
|
526
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
527
|
-
],
|
|
528
|
-
});
|
|
529
|
-
const blueBalance = txb.moveCall({
|
|
530
|
-
target: `${poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
531
|
-
typeArguments: [
|
|
532
|
-
coinsList["WAL"].type,
|
|
533
|
-
coinsList["USDC"].type,
|
|
534
|
-
coinsList["BLUE"].type,
|
|
535
|
-
coinsList["SUI"].type,
|
|
304
|
+
coinsList[coin2].type,
|
|
536
305
|
],
|
|
537
306
|
arguments: [
|
|
538
307
|
txb.object(receipts[0].objectId),
|
|
@@ -541,71 +310,22 @@ export async function claimRewardsTxb(userAddress, poolName) {
|
|
|
541
310
|
txb.object(pool.investorId),
|
|
542
311
|
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
543
312
|
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
544
|
-
txb.object(
|
|
545
|
-
txb.object(getConf().BLUEFIN_WAL_USDC_POOL),
|
|
546
|
-
txb.object(getConf().BLUEFIN_BLUE_SUI_POOL),
|
|
547
|
-
txb.object(cetusPoolMap["USDC-WAL"]),
|
|
548
|
-
txb.object(cetusPoolMap["USDC-SUI"]),
|
|
549
|
-
txb.object(getConf().LST_INFO),
|
|
550
|
-
txb.object(getConf().SUI_SYSTEM_STATE),
|
|
313
|
+
txb.object(pool.parentPoolId),
|
|
551
314
|
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
552
315
|
],
|
|
553
316
|
});
|
|
554
|
-
const
|
|
317
|
+
const tCoin = txb.moveCall({
|
|
555
318
|
target: "0x2::coin::from_balance",
|
|
556
|
-
typeArguments: [coinsList[
|
|
557
|
-
arguments: [
|
|
558
|
-
});
|
|
559
|
-
rewards.push(blueCoin);
|
|
560
|
-
}
|
|
561
|
-
else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC-ZERO-ZERO") {
|
|
562
|
-
txb.moveCall({
|
|
563
|
-
target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
|
|
564
|
-
typeArguments: [
|
|
565
|
-
coinsList["SUIUSDT"].type,
|
|
566
|
-
coinsList["USDC"].type,
|
|
567
|
-
coinsList["SUI"].type,
|
|
568
|
-
],
|
|
569
|
-
arguments: [
|
|
570
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
571
|
-
txb.object(pool.investorId),
|
|
572
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
573
|
-
txb.object(getConf().BLUEFIN_SUIUSDT_USDC_ZERO_ZERO_POOL),
|
|
574
|
-
txb.object(getConf().BLUEFIN_SUI_USDC_POOL),
|
|
575
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
576
|
-
],
|
|
577
|
-
});
|
|
578
|
-
const blueBalance = txb.moveCall({
|
|
579
|
-
target: `${poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
|
|
580
|
-
typeArguments: [
|
|
581
|
-
coinsList["SUIUSDT"].type,
|
|
582
|
-
coinsList["USDC"].type,
|
|
583
|
-
coinsList["BLUE"].type,
|
|
584
|
-
coinsList["SUI"].type,
|
|
585
|
-
],
|
|
586
|
-
arguments: [
|
|
587
|
-
txb.object(receipts[0].objectId),
|
|
588
|
-
txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
|
|
589
|
-
txb.object(pool.poolId),
|
|
590
|
-
txb.object(pool.investorId),
|
|
591
|
-
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
592
|
-
txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
|
|
593
|
-
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
594
|
-
txb.object(getConf().BLUEFIN_SUIUSDT_USDC_ZERO_ZERO_POOL),
|
|
595
|
-
txb.object(getConf().BLUEFIN_BLUE_SUI_POOL),
|
|
596
|
-
txb.object(cetusPoolMap["USDC-SUIUSDT"]),
|
|
597
|
-
txb.object(cetusPoolMap["USDC-SUI"]),
|
|
598
|
-
txb.object(getConf().LST_INFO),
|
|
599
|
-
txb.object(getConf().SUI_SYSTEM_STATE),
|
|
600
|
-
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
601
|
-
],
|
|
319
|
+
typeArguments: [coinsList[coin1].type],
|
|
320
|
+
arguments: [tBalance],
|
|
602
321
|
});
|
|
603
|
-
const
|
|
322
|
+
const sCoin = txb.moveCall({
|
|
604
323
|
target: "0x2::coin::from_balance",
|
|
605
|
-
typeArguments: [coinsList[
|
|
606
|
-
arguments: [
|
|
324
|
+
typeArguments: [coinsList[coin2].type],
|
|
325
|
+
arguments: [sBalance],
|
|
607
326
|
});
|
|
608
|
-
rewards.push(
|
|
327
|
+
rewards.push(tCoin);
|
|
328
|
+
rewards.push(sCoin);
|
|
609
329
|
}
|
|
610
330
|
return { txb: txb, coinOut: rewards };
|
|
611
331
|
}
|
|
@@ -638,6 +358,10 @@ export async function pendingRewardAmount(userAddress, poolName) {
|
|
|
638
358
|
});
|
|
639
359
|
const coinTypeToCoin = coinTypeMap;
|
|
640
360
|
Object.keys(curAcc).forEach((type) => {
|
|
361
|
+
if (!coinTypeToCoin[type]) {
|
|
362
|
+
console.error("coin not present", type);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
641
365
|
const cur = new Decimal(curAcc[type]);
|
|
642
366
|
const last = new Decimal(type in lastAcc ? lastAcc[type] : "0");
|
|
643
367
|
const pending = new Decimal(type in userPendingReward ? userPendingReward[type] : "0");
|