@alphafi/alphafi-sdk 0.0.102 → 0.0.103
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/#package.json# +98 -0
- package/FETCH_OVERRIDE_FIX.md +222 -0
- package/dist/cjs/adminFunctions.d.ts +8 -0
- package/dist/cjs/adminFunctions.d.ts.map +1 -1
- package/dist/cjs/adminFunctions.js +97 -3
- package/dist/cjs/adminFunctions.js.map +1 -1
- package/dist/cjs/common/constants.d.ts +79 -10
- package/dist/cjs/common/constants.d.ts.map +1 -1
- package/dist/cjs/common/constants.js +108 -23
- package/dist/cjs/common/constants.js.map +1 -1
- package/dist/cjs/common/maps.d.ts.map +1 -1
- package/dist/cjs/common/maps.js +72 -4
- package/dist/cjs/common/maps.js.map +1 -1
- package/dist/cjs/common/types.d.ts +76 -26
- package/dist/cjs/common/types.d.ts.map +1 -1
- package/dist/cjs/common/types.js.map +1 -1
- package/dist/cjs/getAprs.d.ts.map +1 -1
- package/dist/cjs/getAprs.js +0 -27
- package/dist/cjs/getAprs.js.map +1 -1
- package/dist/cjs/graphql/getMultiReceipts.js +1 -1
- package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +13 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sui-sdk/functions/getReceipts.d.ts +4 -0
- package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/functions/getReceipts.js +31 -15
- package/dist/cjs/sui-sdk/functions/getReceipts.js.map +1 -1
- package/dist/cjs/transactions/alphaVault.d.ts +26 -0
- package/dist/cjs/transactions/alphaVault.d.ts.map +1 -0
- package/dist/cjs/transactions/alphaVault.js +385 -0
- package/dist/cjs/transactions/alphaVault.js.map +1 -0
- package/dist/cjs/transactions/alphalend.d.ts.map +1 -1
- package/dist/cjs/transactions/alphalend.js +10 -32
- package/dist/cjs/transactions/alphalend.js.map +1 -1
- package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
- package/dist/cjs/transactions/bluefin.js +30 -80
- package/dist/cjs/transactions/bluefin.js.map +1 -1
- package/dist/cjs/transactions/bucket.d.ts.map +1 -1
- package/dist/cjs/transactions/bucket.js +5 -16
- package/dist/cjs/transactions/bucket.js.map +1 -1
- package/dist/cjs/transactions/cetus.d.ts.map +1 -1
- package/dist/cjs/transactions/cetus.js +17 -50
- package/dist/cjs/transactions/cetus.js.map +1 -1
- package/dist/cjs/transactions/collect_rewards.d.ts +1 -0
- package/dist/cjs/transactions/collect_rewards.d.ts.map +1 -1
- package/dist/cjs/transactions/collect_rewards.js +143 -38
- package/dist/cjs/transactions/collect_rewards.js.map +1 -1
- package/dist/cjs/transactions/deposit.d.ts.map +1 -1
- package/dist/cjs/transactions/deposit.js +4 -0
- package/dist/cjs/transactions/deposit.js.map +1 -1
- package/dist/cjs/transactions/navi-looping.d.ts +11 -11
- package/dist/cjs/transactions/navi-looping.d.ts.map +1 -1
- package/dist/cjs/transactions/navi-looping.js +61 -134
- package/dist/cjs/transactions/navi-looping.js.map +1 -1
- package/dist/cjs/transactions/navi.d.ts.map +1 -1
- package/dist/cjs/transactions/navi.js +61 -106
- package/dist/cjs/transactions/navi.js.map +1 -1
- package/dist/cjs/transactions/slush.d.ts +12 -0
- package/dist/cjs/transactions/slush.d.ts.map +1 -0
- package/dist/cjs/transactions/slush.js +143 -0
- package/dist/cjs/transactions/slush.js.map +1 -0
- package/dist/cjs/transactions/withdraw.d.ts.map +1 -1
- package/dist/cjs/transactions/withdraw.js +4 -0
- package/dist/cjs/transactions/withdraw.js.map +1 -1
- package/dist/esm/adminFunctions.d.ts +8 -0
- package/dist/esm/adminFunctions.d.ts.map +1 -1
- package/dist/esm/adminFunctions.js +95 -5
- package/dist/esm/adminFunctions.js.map +1 -1
- package/dist/esm/common/constants.d.ts +79 -10
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +108 -23
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/common/maps.d.ts.map +1 -1
- package/dist/esm/common/maps.js +72 -4
- package/dist/esm/common/maps.js.map +1 -1
- package/dist/esm/common/types.d.ts +76 -26
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/common/types.js.map +1 -1
- package/dist/esm/getAprs.d.ts.map +1 -1
- package/dist/esm/getAprs.js +0 -27
- package/dist/esm/getAprs.js.map +1 -1
- package/dist/esm/graphql/getMultiReceipts.js +1 -1
- package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sui-sdk/functions/getReceipts.d.ts +4 -0
- package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/esm/sui-sdk/functions/getReceipts.js +31 -15
- package/dist/esm/sui-sdk/functions/getReceipts.js.map +1 -1
- package/dist/esm/transactions/alphaVault.d.ts +26 -0
- package/dist/esm/transactions/alphaVault.d.ts.map +1 -0
- package/dist/esm/transactions/alphaVault.js +377 -0
- package/dist/esm/transactions/alphaVault.js.map +1 -0
- package/dist/esm/transactions/alphalend.d.ts.map +1 -1
- package/dist/esm/transactions/alphalend.js +10 -32
- package/dist/esm/transactions/alphalend.js.map +1 -1
- package/dist/esm/transactions/bluefin.d.ts.map +1 -1
- package/dist/esm/transactions/bluefin.js +30 -80
- package/dist/esm/transactions/bluefin.js.map +1 -1
- package/dist/esm/transactions/bucket.d.ts.map +1 -1
- package/dist/esm/transactions/bucket.js +5 -16
- package/dist/esm/transactions/bucket.js.map +1 -1
- package/dist/esm/transactions/cetus.d.ts.map +1 -1
- package/dist/esm/transactions/cetus.js +17 -50
- package/dist/esm/transactions/cetus.js.map +1 -1
- package/dist/esm/transactions/collect_rewards.d.ts +1 -0
- package/dist/esm/transactions/collect_rewards.d.ts.map +1 -1
- package/dist/esm/transactions/collect_rewards.js +142 -38
- package/dist/esm/transactions/collect_rewards.js.map +1 -1
- package/dist/esm/transactions/deposit.d.ts.map +1 -1
- package/dist/esm/transactions/deposit.js +4 -0
- package/dist/esm/transactions/deposit.js.map +1 -1
- package/dist/esm/transactions/navi-looping.d.ts +11 -11
- package/dist/esm/transactions/navi-looping.d.ts.map +1 -1
- package/dist/esm/transactions/navi-looping.js +61 -134
- package/dist/esm/transactions/navi-looping.js.map +1 -1
- package/dist/esm/transactions/navi.d.ts.map +1 -1
- package/dist/esm/transactions/navi.js +61 -106
- package/dist/esm/transactions/navi.js.map +1 -1
- package/dist/esm/transactions/slush.d.ts +12 -0
- package/dist/esm/transactions/slush.d.ts.map +1 -0
- package/dist/esm/transactions/slush.js +137 -0
- package/dist/esm/transactions/slush.js.map +1 -0
- package/dist/esm/transactions/withdraw.d.ts.map +1 -1
- package/dist/esm/transactions/withdraw.js +4 -0
- package/dist/esm/transactions/withdraw.js.map +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/functions/addAirdropCoin.html +1 -0
- package/docs/functions/alphaLpBreakdown.html +1 -1
- package/docs/functions/cetusLpBreakdown.html +1 -1
- package/docs/functions/claimAirdropTx.html +1 -0
- package/docs/functions/claimRewardTxb.html +1 -1
- package/docs/functions/claimRewardsTxb.html +1 -1
- package/docs/functions/claimWithdrawAlphaTx.html +1 -0
- package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -1
- package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -1
- package/docs/functions/coinsInPool.html +1 -1
- package/docs/functions/collectAndSwapRewardsLyf.html +1 -1
- package/docs/functions/collectAndSwapRewardsSingleLoop.html +1 -1
- package/docs/functions/collectRewardTxb.html +1 -1
- package/docs/functions/collectRewards.html +1 -1
- package/docs/functions/collectRewardsAndSwapSlush.html +1 -0
- package/docs/functions/collectUnsuppliedBalance.html +1 -0
- package/docs/functions/deposit.html +1 -1
- package/docs/functions/depositAlphaTx.html +1 -0
- 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/getSlushUserTotalXtokens.html +1 -0
- 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/getWithdrawRequestAndUnsuppliedAmounts.html +1 -0
- package/docs/functions/initiateWithdrawAlpha.html +1 -0
- 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/processWithdrawRequestsManual.html +1 -0
- 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/slushDeposit.html +1 -0
- package/docs/functions/slushWithdraw.html +1 -0
- package/docs/functions/withdraw.html +1 -1
- package/docs/functions/withdrawAlphaTxb.html +1 -1
- package/docs/functions/withdrawTxb.html +1 -1
- package/docs/functions/zapDepositQuoteTxb.html +1 -1
- package/docs/functions/zapDepositTxb.html +1 -1
- package/docs/hierarchy.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 +1 -1
- package/docs/types/AfterTransactionEventNode.html +1 -1
- package/docs/types/AirdropClaimEventNode.html +1 -1
- package/docs/types/Allocator.html +2 -2
- package/docs/types/AlphaFiDoubleAssetVault.html +2 -2
- package/docs/types/AlphaFiMultiVaultBalance.html +1 -1
- package/docs/types/AlphaFiSingleAssetVault.html +2 -2
- 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 +2 -2
- package/docs/types/AlphaReceipt.html +2 -2
- package/docs/types/AlphaReceiptFields.html +2 -2
- package/docs/types/AlphaVaultBalance.html +2 -2
- package/docs/types/AutoBalancePoolNames.html +1 -1
- package/docs/types/AutoCompoundingEventNode.html +1 -1
- package/docs/types/Bag.html +3 -0
- package/docs/types/BluefinInvestor.html +1 -1
- package/docs/types/BluefinLyfInvestor.html +1 -1
- package/docs/types/BluefinPoolType.html +2 -2
- package/docs/types/BucketInvestor.html +2 -2
- package/docs/types/CetusInvestor.html +2 -2
- package/docs/types/CetusPoolType.html +2 -2
- package/docs/types/CetusSwapOptions.html +1 -1
- package/docs/types/CoinAmounts.html +2 -2
- package/docs/types/CoinName.html +1 -1
- package/docs/types/CoinType.html +1 -1
- package/docs/types/CommonInvestorFields.html +2 -2
- package/docs/types/CreatePoolOptions.html +2 -2
- package/docs/types/Distributor.html +2 -2
- package/docs/types/DoubleAssetMultiVaultBalance.html +2 -2
- package/docs/types/DoubleAssetPoolNames.html +1 -1
- package/docs/types/DoubleAssetTokenHoldings.html +2 -2
- package/docs/types/DoubleAssetVaultBalance.html +2 -2
- package/docs/types/EventCategory.html +1 -1
- package/docs/types/EventNode.html +1 -1
- package/docs/types/GetHoldersParams.html +2 -2
- package/docs/types/GetTokenHoldingsParams.html +2 -2
- package/docs/types/GetUserTokensFromTransactionsParams.html +2 -2
- package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +2 -2
- package/docs/types/GetVaultBalanceParams.html +1 -1
- package/docs/types/HoldingsObj.html +2 -2
- 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 +2 -2
- package/docs/types/LiquidityToUsdParams.html +2 -2
- package/docs/types/LoopingDebt.html +2 -2
- package/docs/types/LoopingPoolNames.html +1 -1
- package/docs/types/LpBreakdownType.html +2 -2
- package/docs/types/MemberPoolDataType.html +2 -2
- package/docs/types/MemberType.html +2 -2
- package/docs/types/MultiGetVaultBalancesParams.html +2 -2
- package/docs/types/NaviInvestor.html +2 -2
- package/docs/types/ObjectTable.html +1 -0
- package/docs/types/OtherReceiptFields.html +2 -2
- package/docs/types/PoolName.html +1 -1
- package/docs/types/PoolReceipt.html +1 -1
- package/docs/types/PoolType.html +2 -2
- package/docs/types/Receipt.html +2 -2
- package/docs/types/ReceiptGQL.html +2 -2
- package/docs/types/SingleAssetMultiVaultBalance.html +2 -2
- package/docs/types/SingleAssetPoolNames.html +1 -1
- package/docs/types/SingleAssetTokenHoldings.html +2 -2
- package/docs/types/SingleAssetVaultBalance.html +2 -2
- package/docs/types/SingleGetVaultBalancesParams.html +2 -2
- 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 +2 -2
- package/docs/types/TransactionBlockType.html +2 -2
- package/docs/types/UserPoolLiquidity.html +2 -2
- package/docs/types/UserPoolTokenHoldings.html +1 -1
- package/docs/types/UserUsdHoldings.html +2 -2
- package/docs/types/VaultBalance.html +1 -1
- package/docs/types/VecMap.html +3 -0
- package/docs/types/VoteCastEvent.html +1 -1
- package/docs/types/WithdrawV2EventNode.html +1 -1
- package/docs/variables/AUTOBALANCE_SUI_FIRST_POOLS.html +1 -1
- package/docs/variables/AUTOBALANCE_SUI_SECOND_POOLS.html +1 -1
- package/docs/variables/AUTOBALANCE_TYPE_1_POOLS.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 +2 -1
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.depositAlphaTx = depositAlphaTx;
|
|
4
|
+
exports.initiateWithdrawAlpha = initiateWithdrawAlpha;
|
|
5
|
+
exports.claimAirdropTx = claimAirdropTx;
|
|
6
|
+
exports.claimWithdrawAlphaTx = claimWithdrawAlphaTx;
|
|
7
|
+
exports.getCoinFromWallet = getCoinFromWallet;
|
|
8
|
+
exports.parseAlphaFiReceipt = parseAlphaFiReceipt;
|
|
9
|
+
const transactions_1 = require("@mysten/sui/transactions");
|
|
10
|
+
const constants_js_1 = require("../common/constants.js");
|
|
11
|
+
const maps_js_1 = require("../common/maps.js");
|
|
12
|
+
const coins_js_1 = require("../common/coins.js");
|
|
13
|
+
const getReceipts_js_1 = require("../sui-sdk/functions/getReceipts.js");
|
|
14
|
+
const decimal_js_1 = require("decimal.js");
|
|
15
|
+
async function depositAlphaTx(amount, address, suiClient) {
|
|
16
|
+
const tx = new transactions_1.Transaction();
|
|
17
|
+
const poolinfo = maps_js_1.poolInfo["ALPHA"];
|
|
18
|
+
// Fetch ALPHA coins from the user's wallet
|
|
19
|
+
const coin = await getCoinFromWallet(tx, suiClient, address, poolinfo.assetTypes[0]);
|
|
20
|
+
const [depositCoin] = tx.splitCoins(coin, [amount]);
|
|
21
|
+
// Transfer remaining coins back to user
|
|
22
|
+
tx.transferObjects([coin], address);
|
|
23
|
+
// Get receipts
|
|
24
|
+
const receipts = await (0, getReceipts_js_1.getReceipts)("ALPHA", address, true);
|
|
25
|
+
const receipt = receipts.length > 0 ? receipts[0] : undefined;
|
|
26
|
+
const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);
|
|
27
|
+
if (alphafiReceipt.length === 0) {
|
|
28
|
+
// Create new AlphaFi receipt
|
|
29
|
+
const alphafiReceiptObj = createAlphaFiReceipt(tx);
|
|
30
|
+
// Convert alpha receipt to ember position if alpha receipt exists
|
|
31
|
+
if (receipt) {
|
|
32
|
+
tx.moveCall({
|
|
33
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,
|
|
34
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
35
|
+
arguments: [
|
|
36
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
37
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
38
|
+
alphafiReceiptObj,
|
|
39
|
+
tx.object(receipt.objectId),
|
|
40
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_POOL),
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// Deposit to ember pool
|
|
45
|
+
tx.moveCall({
|
|
46
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_deposit`,
|
|
47
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
48
|
+
arguments: [
|
|
49
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
50
|
+
alphafiReceiptObj,
|
|
51
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
52
|
+
depositCoin,
|
|
53
|
+
tx.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
tx.moveCall({
|
|
57
|
+
target: `${(0, constants_js_1.getConf)().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::transfer_receipt_to_new_owner`,
|
|
58
|
+
arguments: [
|
|
59
|
+
alphafiReceiptObj,
|
|
60
|
+
tx.pure.address(address),
|
|
61
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_RECEIPT_WHITELISTED_ADDRESSES),
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const existingReceipt = alphafiReceipt[0];
|
|
67
|
+
// Convert alpha receipt to ember position if needed
|
|
68
|
+
if (receipt) {
|
|
69
|
+
const isPresent = isPositionPresent(existingReceipt, (0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL);
|
|
70
|
+
if (!isPresent) {
|
|
71
|
+
tx.moveCall({
|
|
72
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,
|
|
73
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
74
|
+
arguments: [
|
|
75
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
76
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
77
|
+
tx.object(existingReceipt.id),
|
|
78
|
+
tx.object(receipt.objectId),
|
|
79
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_POOL),
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Deposit to ember pool
|
|
85
|
+
tx.moveCall({
|
|
86
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_deposit`,
|
|
87
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
88
|
+
arguments: [
|
|
89
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
90
|
+
tx.object(existingReceipt.id),
|
|
91
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
92
|
+
depositCoin,
|
|
93
|
+
tx.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return tx;
|
|
98
|
+
}
|
|
99
|
+
async function initiateWithdrawAlpha(amount, withdrawMax, address, suiClient) {
|
|
100
|
+
let xtokens = 0;
|
|
101
|
+
const alphaPool = (await (0, getReceipts_js_1.getPool)("ALPHA", true));
|
|
102
|
+
if (withdrawMax) {
|
|
103
|
+
const alphafiReceipts = await getAlphaFiReceipt(address, suiClient);
|
|
104
|
+
const receipts = await (0, getReceipts_js_1.getReceipts)("ALPHA", address, true);
|
|
105
|
+
const receipt = receipts.length > 0 ? receipts[0] : undefined;
|
|
106
|
+
if (alphafiReceipts.length === 0 && !receipt) {
|
|
107
|
+
throw new Error(`No AlphaFi receipts or receit found for address ${address}`);
|
|
108
|
+
}
|
|
109
|
+
if (alphafiReceipts.length === 0 && receipt) {
|
|
110
|
+
xtokens = Number(receipt.content.fields.xTokenBalance);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
let positionUpdate = alphaPool.content.fields.recently_updated_alphafi_receipts.fields.contents.find((item) => item.fields.key === alphafiReceipts[0].id);
|
|
114
|
+
xtokens =
|
|
115
|
+
Number(await getAlphaTotalShares(suiClient, alphafiReceipts[0])) -
|
|
116
|
+
(positionUpdate
|
|
117
|
+
? Number(positionUpdate.fields.value.fields.xtokens_to_remove) -
|
|
118
|
+
Number(positionUpdate.fields.value.fields.xtokens_to_add)
|
|
119
|
+
: 0);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
xtokens = new decimal_js_1.Decimal(amount)
|
|
124
|
+
.div(new decimal_js_1.Decimal(alphaPool.content.fields.current_exchange_rate.fields.value).div(1e18))
|
|
125
|
+
.ceil()
|
|
126
|
+
.toNumber();
|
|
127
|
+
}
|
|
128
|
+
return initiateWithdrawAlphaTx(xtokens.toString(), address, suiClient);
|
|
129
|
+
}
|
|
130
|
+
async function getAlphaTotalShares(suiClient, alphafiReceipt) {
|
|
131
|
+
let entry = alphafiReceipt.position_pool_map.find((item) => item.value.pool_id === maps_js_1.poolInfo["ALPHA"].poolId);
|
|
132
|
+
if (!entry) {
|
|
133
|
+
console.error("no position for pool id found");
|
|
134
|
+
return "0";
|
|
135
|
+
}
|
|
136
|
+
const position = await suiClient.getObject({
|
|
137
|
+
id: entry.key,
|
|
138
|
+
options: {
|
|
139
|
+
showContent: true,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
return (position.data?.content).fields.xtokens.toString();
|
|
143
|
+
}
|
|
144
|
+
async function initiateWithdrawAlphaTx(xTokens, address, suiClient) {
|
|
145
|
+
const tx = new transactions_1.Transaction();
|
|
146
|
+
const receipts = await (0, getReceipts_js_1.getReceipts)("ALPHA", address, true);
|
|
147
|
+
const receipt = receipts.length > 0 ? receipts[0] : undefined;
|
|
148
|
+
const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);
|
|
149
|
+
if (alphafiReceipt.length === 0) {
|
|
150
|
+
// Create new AlphaFi receipt
|
|
151
|
+
const alphafiReceiptObj = createAlphaFiReceipt(tx);
|
|
152
|
+
if (!receipt) {
|
|
153
|
+
throw new Error("No alphafi receipt and no alpha receipt found");
|
|
154
|
+
}
|
|
155
|
+
// Convert alpha receipt to ember position
|
|
156
|
+
tx.moveCall({
|
|
157
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,
|
|
158
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
159
|
+
arguments: [
|
|
160
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
161
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
162
|
+
alphafiReceiptObj,
|
|
163
|
+
tx.object(receipt.objectId),
|
|
164
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_POOL),
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
// Initiate withdrawal
|
|
168
|
+
tx.moveCall({
|
|
169
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_initiate_withdraw`,
|
|
170
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
171
|
+
arguments: [
|
|
172
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
173
|
+
alphafiReceiptObj,
|
|
174
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
175
|
+
tx.pure.u64(xTokens),
|
|
176
|
+
tx.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
tx.moveCall({
|
|
180
|
+
target: `${(0, constants_js_1.getConf)().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::transfer_receipt_to_new_owner`,
|
|
181
|
+
arguments: [
|
|
182
|
+
alphafiReceiptObj,
|
|
183
|
+
tx.pure.address(address),
|
|
184
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_RECEIPT_WHITELISTED_ADDRESSES),
|
|
185
|
+
],
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
const existingReceipt = alphafiReceipt[0];
|
|
190
|
+
const isPresent = isPositionPresent(existingReceipt, (0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL);
|
|
191
|
+
if (!isPresent && !receipt) {
|
|
192
|
+
throw new Error("No position or old alpha receipt found");
|
|
193
|
+
}
|
|
194
|
+
// Convert alpha receipt to ember position if needed
|
|
195
|
+
if (!isPresent && receipt) {
|
|
196
|
+
tx.moveCall({
|
|
197
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,
|
|
198
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
199
|
+
arguments: [
|
|
200
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
201
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
202
|
+
tx.object(existingReceipt.id),
|
|
203
|
+
tx.object(receipt.objectId),
|
|
204
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_POOL),
|
|
205
|
+
],
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// Initiate withdrawal
|
|
209
|
+
tx.moveCall({
|
|
210
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_initiate_withdraw`,
|
|
211
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
212
|
+
arguments: [
|
|
213
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
214
|
+
tx.object(existingReceipt.id),
|
|
215
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
216
|
+
tx.pure.u64(xTokens),
|
|
217
|
+
tx.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
218
|
+
],
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return tx;
|
|
222
|
+
}
|
|
223
|
+
async function claimAirdropTx(address, suiClient) {
|
|
224
|
+
const tx = new transactions_1.Transaction();
|
|
225
|
+
let airdropCoin;
|
|
226
|
+
const receipts = await (0, getReceipts_js_1.getReceipts)("ALPHA", address, true);
|
|
227
|
+
const receipt = receipts.length > 0 ? receipts[0] : undefined;
|
|
228
|
+
const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);
|
|
229
|
+
if (alphafiReceipt.length === 0) {
|
|
230
|
+
// Create new AlphaFi receipt
|
|
231
|
+
const alphafiReceiptObj = createAlphaFiReceipt(tx);
|
|
232
|
+
if (!receipt) {
|
|
233
|
+
throw new Error("No alphafi receipt and no alpha receipt found");
|
|
234
|
+
}
|
|
235
|
+
// Convert alpha receipt to ember position
|
|
236
|
+
tx.moveCall({
|
|
237
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,
|
|
238
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
239
|
+
arguments: [
|
|
240
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
241
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
242
|
+
alphafiReceiptObj,
|
|
243
|
+
tx.object(receipt.objectId),
|
|
244
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_POOL),
|
|
245
|
+
],
|
|
246
|
+
});
|
|
247
|
+
// Get user rewards
|
|
248
|
+
airdropCoin = tx.moveCall({
|
|
249
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::get_user_rewards`,
|
|
250
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE, coins_js_1.coinsList["SUI"].type],
|
|
251
|
+
arguments: [
|
|
252
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
253
|
+
alphafiReceiptObj,
|
|
254
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
255
|
+
],
|
|
256
|
+
});
|
|
257
|
+
tx.moveCall({
|
|
258
|
+
target: `${(0, constants_js_1.getConf)().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::transfer_receipt_to_new_owner`,
|
|
259
|
+
arguments: [
|
|
260
|
+
alphafiReceiptObj,
|
|
261
|
+
tx.pure.address(address),
|
|
262
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_RECEIPT_WHITELISTED_ADDRESSES),
|
|
263
|
+
],
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
const existingReceipt = alphafiReceipt[0];
|
|
268
|
+
const isPresent = isPositionPresent(existingReceipt, (0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL);
|
|
269
|
+
if (!isPresent && !receipt) {
|
|
270
|
+
throw new Error("No position or old alpha receipt found");
|
|
271
|
+
}
|
|
272
|
+
// Convert alpha receipt to ember position if needed
|
|
273
|
+
if (!isPresent && receipt) {
|
|
274
|
+
tx.moveCall({
|
|
275
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,
|
|
276
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
277
|
+
arguments: [
|
|
278
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
279
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
280
|
+
tx.object(existingReceipt.id),
|
|
281
|
+
tx.object(receipt.objectId),
|
|
282
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_POOL),
|
|
283
|
+
],
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
// Get user rewards
|
|
287
|
+
airdropCoin = tx.moveCall({
|
|
288
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::get_user_rewards`,
|
|
289
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE, coins_js_1.coinsList["SUI"].type],
|
|
290
|
+
arguments: [
|
|
291
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
292
|
+
tx.object(existingReceipt.id),
|
|
293
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
294
|
+
],
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
tx.transferObjects([airdropCoin], address);
|
|
298
|
+
return tx;
|
|
299
|
+
}
|
|
300
|
+
async function claimWithdrawAlphaTx(ticketId, address, suiClient) {
|
|
301
|
+
const tx = new transactions_1.Transaction();
|
|
302
|
+
const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);
|
|
303
|
+
if (alphafiReceipt.length === 0) {
|
|
304
|
+
throw new Error("No Alphafi receipt found!");
|
|
305
|
+
}
|
|
306
|
+
let coin = tx.moveCall({
|
|
307
|
+
target: `${(0, constants_js_1.getConf)().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_claim_withdraw`,
|
|
308
|
+
typeArguments: [(0, constants_js_1.getConf)().ALPHA_COIN_TYPE],
|
|
309
|
+
arguments: [
|
|
310
|
+
tx.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
|
|
311
|
+
tx.object(alphafiReceipt[0].id),
|
|
312
|
+
tx.object((0, constants_js_1.getConf)().ALPHAFI_EMBER_POOL),
|
|
313
|
+
tx.pure.id(ticketId),
|
|
314
|
+
tx.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
|
|
315
|
+
],
|
|
316
|
+
});
|
|
317
|
+
tx.transferObjects([coin], address);
|
|
318
|
+
return tx;
|
|
319
|
+
}
|
|
320
|
+
async function getCoinFromWallet(tx, suiClient, address, coinType) {
|
|
321
|
+
if (coinType === "0x2::sui::SUI" ||
|
|
322
|
+
coinType ===
|
|
323
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
324
|
+
return tx.gas;
|
|
325
|
+
}
|
|
326
|
+
let coins = [];
|
|
327
|
+
let currentCursor = null;
|
|
328
|
+
do {
|
|
329
|
+
const response = await suiClient.getCoins({
|
|
330
|
+
owner: address,
|
|
331
|
+
coinType,
|
|
332
|
+
cursor: currentCursor,
|
|
333
|
+
});
|
|
334
|
+
coins = coins.concat(response.data);
|
|
335
|
+
// Check if there's a next page
|
|
336
|
+
if (response.hasNextPage && response.nextCursor) {
|
|
337
|
+
currentCursor = response.nextCursor;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
// No more pages available
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
} while (true);
|
|
344
|
+
let coin;
|
|
345
|
+
[coin] = tx.splitCoins(tx.object(coins[0].coinObjectId), [0]);
|
|
346
|
+
tx.mergeCoins(coin, coins.map((c) => c.coinObjectId));
|
|
347
|
+
return coin;
|
|
348
|
+
}
|
|
349
|
+
function isPositionPresent(alphafiReceipt, poolId) {
|
|
350
|
+
return alphafiReceipt.position_pool_map.some((item) => `0x${item.value.pool_id}` === poolId ||
|
|
351
|
+
item.value.pool_id === poolId ||
|
|
352
|
+
item.value.pool_id === `0x${poolId}`);
|
|
353
|
+
}
|
|
354
|
+
function createAlphaFiReceipt(tx) {
|
|
355
|
+
return tx.moveCall({
|
|
356
|
+
target: `${(0, constants_js_1.getConf)().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::create_alphafi_receipt_v2`,
|
|
357
|
+
arguments: [tx.pure.string((0, constants_js_1.getConf)().ALPHAFI_RECEIPT_IMAGE_URL)],
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
async function getAlphaFiReceipt(address, suiClient) {
|
|
361
|
+
const receipts = await suiClient.getOwnedObjects({
|
|
362
|
+
owner: address,
|
|
363
|
+
filter: {
|
|
364
|
+
StructType: (0, constants_js_1.getConf)().ALPHAFI_RECEIPT_TYPE,
|
|
365
|
+
},
|
|
366
|
+
options: {
|
|
367
|
+
showContent: true,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
return receipts.data.map((receipt) => parseAlphaFiReceipt(receipt.data));
|
|
371
|
+
}
|
|
372
|
+
function parseAlphaFiReceipt(query) {
|
|
373
|
+
return {
|
|
374
|
+
id: query.content.fields.id.id,
|
|
375
|
+
position_pool_map: query.content.fields.position_pool_map.fields.contents.map((item) => ({
|
|
376
|
+
key: item.fields.key,
|
|
377
|
+
value: {
|
|
378
|
+
pool_id: item.fields.value.fields.pool_id,
|
|
379
|
+
partner_cap_id: item.fields.value.fields.partner_cap_id,
|
|
380
|
+
},
|
|
381
|
+
})),
|
|
382
|
+
client_address: query.content.fields.client_address,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=alphaVault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alphaVault.js","sourceRoot":"","sources":["../../../src/transactions/alphaVault.ts"],"names":[],"mappings":";;AASA,wCAyGC;AAED,sDA0CC;AAqHD,wCAwFC;AAED,oDAwBC;AAED,8CAwCC;AAyCD,kDAeC;AAveD,2DAAuD;AACvD,yDAAiD;AACjD,+CAA6C;AAC7C,iDAA+C;AAE/C,wEAA2E;AAC3E,2CAAqC;AAG9B,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,OAAe,EACf,SAAoB;IAEpB,MAAM,EAAE,GAAG,IAAI,0BAAW,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,kBAAQ,CAAC,OAAO,CAAC,CAAC;IAEnC,2CAA2C;IAC3C,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAClC,EAAE,EACF,SAAS,EACT,OAAO,EACP,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CACvB,CAAC;IACF,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpD,wCAAwC;IACxC,EAAE,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpC,eAAe;IACf,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAW,EAAC,OAAO,EAAE,OAA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MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC;QAC/C,KAAK,EAAE,OAAO;QACd,MAAM,EAAE;YACN,UAAU,EAAE,IAAA,sBAAO,GAAE,CAAC,oBAAoB;SAC3C;QACD,OAAO,EAAE;YACP,WAAW,EAAE,IAAI;SAClB;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACnC,mBAAmB,CAAC,OAAO,CAAC,IAAW,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAU;IAC5C,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC9B,iBAAiB,EACf,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CACxD,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YACd,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG;YACpB,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;gBACzC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc;aACxD;SACF,CAAC,CACH;QACH,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc;KACpD,CAAC;AACJ,CAAC","sourcesContent":["import { Transaction } from \"@mysten/sui/transactions\";\nimport { getConf } from \"../common/constants.js\";\nimport { poolInfo } from \"../common/maps.js\";\nimport { coinsList } from \"../common/coins.js\";\nimport { CoinStruct, SuiClient } from \"@mysten/sui/client\";\nimport { getPool, getReceipts } from \"../sui-sdk/functions/getReceipts.js\";\nimport { Decimal } from \"decimal.js\";\nimport { AlphaPoolType } from \"../common/types.js\";\n\nexport async function depositAlphaTx(\n amount: string,\n address: string,\n suiClient: SuiClient,\n): Promise<Transaction> {\n const tx = new Transaction();\n const poolinfo = poolInfo[\"ALPHA\"];\n\n // Fetch ALPHA coins from the user's wallet\n const coin = await getCoinFromWallet(\n tx,\n suiClient,\n address,\n poolinfo.assetTypes[0],\n );\n const [depositCoin] = tx.splitCoins(coin, [amount]);\n\n // Transfer remaining coins back to user\n tx.transferObjects([coin], address);\n\n // Get receipts\n const receipts = await getReceipts(\"ALPHA\", address, true);\n const receipt = receipts.length > 0 ? receipts[0] : undefined;\n const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);\n\n if (alphafiReceipt.length === 0) {\n // Create new AlphaFi receipt\n const alphafiReceiptObj = createAlphaFiReceipt(tx);\n\n // Convert alpha receipt to ember position if alpha receipt exists\n if (receipt) {\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n alphafiReceiptObj,\n tx.object(receipt.objectId),\n tx.object(getConf().ALPHA_POOL),\n ],\n });\n }\n\n // Deposit to ember pool\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_deposit`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n alphafiReceiptObj,\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n depositCoin,\n tx.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n\n tx.moveCall({\n target: `${getConf().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::transfer_receipt_to_new_owner`,\n arguments: [\n alphafiReceiptObj,\n tx.pure.address(address),\n tx.object(getConf().ALPHAFI_RECEIPT_WHITELISTED_ADDRESSES),\n ],\n });\n } else {\n const existingReceipt = alphafiReceipt[0];\n\n // Convert alpha receipt to ember position if needed\n if (receipt) {\n const isPresent = isPositionPresent(\n existingReceipt,\n getConf().ALPHAFI_EMBER_POOL,\n );\n\n if (!isPresent) {\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n tx.object(existingReceipt.id),\n tx.object(receipt.objectId),\n tx.object(getConf().ALPHA_POOL),\n ],\n });\n }\n }\n\n // Deposit to ember pool\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_deposit`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(existingReceipt.id),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n depositCoin,\n tx.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n\n return tx;\n}\n\nexport async function initiateWithdrawAlpha(\n amount: string,\n withdrawMax: boolean,\n address: string,\n suiClient: SuiClient,\n): Promise<Transaction> {\n let xtokens = 0;\n const alphaPool = (await getPool(\"ALPHA\", true)) as AlphaPoolType;\n if (withdrawMax) {\n const alphafiReceipts = await getAlphaFiReceipt(address, suiClient);\n const receipts = await getReceipts(\"ALPHA\", address, true);\n const receipt = receipts.length > 0 ? receipts[0] : undefined;\n if (alphafiReceipts.length === 0 && !receipt) {\n throw new Error(\n `No AlphaFi receipts or receit found for address ${address}`,\n );\n }\n if (alphafiReceipts.length === 0 && receipt) {\n xtokens = Number(receipt.content.fields.xTokenBalance);\n } else {\n let positionUpdate =\n alphaPool.content.fields.recently_updated_alphafi_receipts.fields.contents.find(\n (item) => item.fields.key === alphafiReceipts[0].id,\n );\n xtokens =\n Number(await getAlphaTotalShares(suiClient, alphafiReceipts[0])) -\n (positionUpdate\n ? Number(positionUpdate.fields.value.fields.xtokens_to_remove) -\n Number(positionUpdate.fields.value.fields.xtokens_to_add)\n : 0);\n }\n } else {\n xtokens = new Decimal(amount)\n .div(\n new Decimal(\n alphaPool.content.fields.current_exchange_rate.fields.value,\n ).div(1e18),\n )\n .ceil()\n .toNumber();\n }\n return initiateWithdrawAlphaTx(xtokens.toString(), address, suiClient);\n}\n\nasync function getAlphaTotalShares(\n suiClient: SuiClient,\n alphafiReceipt: AlphaFiReceiptType,\n): Promise<string> {\n let entry = alphafiReceipt.position_pool_map.find(\n (item) => item.value.pool_id === poolInfo[\"ALPHA\"].poolId,\n );\n if (!entry) {\n console.error(\"no position for pool id found\");\n return \"0\";\n }\n const position = await suiClient.getObject({\n id: entry.key,\n options: {\n showContent: true,\n },\n });\n return (position.data?.content as any).fields.xtokens.toString();\n}\n\nasync function initiateWithdrawAlphaTx(\n xTokens: string,\n address: string,\n suiClient: SuiClient,\n): Promise<Transaction> {\n const tx = new Transaction();\n\n const receipts = await getReceipts(\"ALPHA\", address, true);\n const receipt = receipts.length > 0 ? receipts[0] : undefined;\n const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);\n if (alphafiReceipt.length === 0) {\n // Create new AlphaFi receipt\n const alphafiReceiptObj = createAlphaFiReceipt(tx);\n\n if (!receipt) {\n throw new Error(\"No alphafi receipt and no alpha receipt found\");\n }\n\n // Convert alpha receipt to ember position\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n alphafiReceiptObj,\n tx.object(receipt.objectId),\n tx.object(getConf().ALPHA_POOL),\n ],\n });\n\n // Initiate withdrawal\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_initiate_withdraw`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n alphafiReceiptObj,\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n tx.pure.u64(xTokens),\n tx.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n\n tx.moveCall({\n target: `${getConf().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::transfer_receipt_to_new_owner`,\n arguments: [\n alphafiReceiptObj,\n tx.pure.address(address),\n tx.object(getConf().ALPHAFI_RECEIPT_WHITELISTED_ADDRESSES),\n ],\n });\n } else {\n const existingReceipt = alphafiReceipt[0];\n const isPresent = isPositionPresent(\n existingReceipt,\n getConf().ALPHAFI_EMBER_POOL,\n );\n\n if (!isPresent && !receipt) {\n throw new Error(\"No position or old alpha receipt found\");\n }\n\n // Convert alpha receipt to ember position if needed\n if (!isPresent && receipt) {\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n tx.object(existingReceipt.id),\n tx.object(receipt.objectId),\n tx.object(getConf().ALPHA_POOL),\n ],\n });\n }\n\n // Initiate withdrawal\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_initiate_withdraw`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(existingReceipt.id),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n tx.pure.u64(xTokens),\n tx.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n\n return tx;\n}\n\nexport async function claimAirdropTx(\n address: string,\n suiClient: SuiClient,\n): Promise<Transaction> {\n const tx = new Transaction();\n let airdropCoin;\n const receipts = await getReceipts(\"ALPHA\", address, true);\n const receipt = receipts.length > 0 ? receipts[0] : undefined;\n const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);\n if (alphafiReceipt.length === 0) {\n // Create new AlphaFi receipt\n const alphafiReceiptObj = createAlphaFiReceipt(tx);\n\n if (!receipt) {\n throw new Error(\"No alphafi receipt and no alpha receipt found\");\n }\n\n // Convert alpha receipt to ember position\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n alphafiReceiptObj,\n tx.object(receipt.objectId),\n tx.object(getConf().ALPHA_POOL),\n ],\n });\n\n // Get user rewards\n airdropCoin = tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::get_user_rewards`,\n typeArguments: [getConf().ALPHA_COIN_TYPE, coinsList[\"SUI\"].type],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n alphafiReceiptObj,\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n ],\n });\n\n tx.moveCall({\n target: `${getConf().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::transfer_receipt_to_new_owner`,\n arguments: [\n alphafiReceiptObj,\n tx.pure.address(address),\n tx.object(getConf().ALPHAFI_RECEIPT_WHITELISTED_ADDRESSES),\n ],\n });\n } else {\n const existingReceipt = alphafiReceipt[0];\n const isPresent = isPositionPresent(\n existingReceipt,\n getConf().ALPHAFI_EMBER_POOL,\n );\n\n if (!isPresent && !receipt) {\n throw new Error(\"No position or old alpha receipt found\");\n }\n\n // Convert alpha receipt to ember position if needed\n if (!isPresent && receipt) {\n tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::migrate_alpha_receipt_to_new_alpha_strategy`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n tx.object(existingReceipt.id),\n tx.object(receipt.objectId),\n tx.object(getConf().ALPHA_POOL),\n ],\n });\n }\n\n // Get user rewards\n airdropCoin = tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::get_user_rewards`,\n typeArguments: [getConf().ALPHA_COIN_TYPE, coinsList[\"SUI\"].type],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(existingReceipt.id),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n ],\n });\n }\n tx.transferObjects([airdropCoin], address);\n return tx;\n}\n\nexport async function claimWithdrawAlphaTx(\n ticketId: string,\n address: string,\n suiClient: SuiClient,\n): Promise<Transaction> {\n const tx = new Transaction();\n const alphafiReceipt = await getAlphaFiReceipt(address, suiClient);\n\n if (alphafiReceipt.length === 0) {\n throw new Error(\"No Alphafi receipt found!\");\n }\n let coin = tx.moveCall({\n target: `${getConf().ALPHA_EMBER_LATEST_PACKAGE_ID}::alphafi_ember_pool::user_claim_withdraw`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n tx.object(getConf().ALPHA_EMBER_VERSION),\n tx.object(alphafiReceipt[0].id),\n tx.object(getConf().ALPHAFI_EMBER_POOL),\n tx.pure.id(ticketId),\n tx.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n tx.transferObjects([coin], address);\n return tx;\n}\n\nexport async function getCoinFromWallet(\n tx: Transaction,\n suiClient: SuiClient,\n address: string,\n coinType: string,\n) {\n if (\n coinType === \"0x2::sui::SUI\" ||\n coinType ===\n \"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI\"\n ) {\n return tx.gas;\n }\n let coins: CoinStruct[] = [];\n let currentCursor: string | null | undefined = null;\n do {\n const response = await suiClient.getCoins({\n owner: address,\n coinType,\n cursor: currentCursor,\n });\n coins = coins.concat(response.data);\n\n // Check if there's a next page\n if (response.hasNextPage && response.nextCursor) {\n currentCursor = response.nextCursor;\n } else {\n // No more pages available\n break;\n }\n } while (true);\n\n let coin;\n [coin] = tx.splitCoins(tx.object(coins[0].coinObjectId), [0]);\n tx.mergeCoins(\n coin,\n coins.map((c) => c.coinObjectId),\n );\n\n return coin;\n}\n\nfunction isPositionPresent(\n alphafiReceipt: {\n position_pool_map: Array<{ key: string; value: { pool_id: string } }>;\n },\n poolId: string,\n): boolean {\n return alphafiReceipt.position_pool_map.some(\n (item) =>\n `0x${item.value.pool_id}` === poolId ||\n item.value.pool_id === poolId ||\n item.value.pool_id === `0x${poolId}`,\n );\n}\n\nfunction createAlphaFiReceipt(tx: Transaction) {\n return tx.moveCall({\n target: `${getConf().ALPHAFI_RECEIPT_PACKAGE_ID}::alphafi_receipt::create_alphafi_receipt_v2`,\n arguments: [tx.pure.string(getConf().ALPHAFI_RECEIPT_IMAGE_URL)],\n });\n}\n\nasync function getAlphaFiReceipt(\n address: string,\n suiClient: SuiClient,\n): Promise<AlphaFiReceiptType[]> {\n const receipts = await suiClient.getOwnedObjects({\n owner: address,\n filter: {\n StructType: getConf().ALPHAFI_RECEIPT_TYPE,\n },\n options: {\n showContent: true,\n },\n });\n return receipts.data.map((receipt) =>\n parseAlphaFiReceipt(receipt.data as any),\n );\n}\n\nexport function parseAlphaFiReceipt(query: any): AlphaFiReceiptType {\n return {\n id: query.content.fields.id.id,\n position_pool_map:\n query.content.fields.position_pool_map.fields.contents.map(\n (item: any) => ({\n key: item.fields.key,\n value: {\n pool_id: item.fields.value.fields.pool_id,\n partner_cap_id: item.fields.value.fields.partner_cap_id,\n },\n }),\n ),\n client_address: query.content.fields.client_address,\n };\n}\n\nexport type AlphaFiReceiptType = {\n id: string;\n position_pool_map: {\n key: string;\n value: {\n pool_id: string;\n partner_cap_id: string;\n };\n }[];\n client_address: string;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alphalend.d.ts","sourceRoot":"","sources":["../../../src/transactions/alphalend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAYvD,OAAO,EAAE,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,wBAQ7B;AACD,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,wBAQ7B;AACD,eAAO,MAAM,eAAe,iBAAiD,CAAC;AAC9E,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,CAqFtB;AAED,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,CAsDtB;AAED,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"alphalend.d.ts","sourceRoot":"","sources":["../../../src/transactions/alphalend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAYvD,OAAO,EAAE,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,wBAQ7B;AACD,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,wBAQ7B;AACD,eAAO,MAAM,eAAe,iBAAiD,CAAC;AAC9E,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,CAqFtB;AAED,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,CAsDtB;AAED,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,CAsFtB;AACD,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,CA6CtB"}
|
|
@@ -163,27 +163,16 @@ async function alphalendSuiStsuiLoopWithdrawTx(xTokens, options) {
|
|
|
163
163
|
const poolName = "ALPHALEND-LOOP-SUI-STSUI";
|
|
164
164
|
const poolData = index_js_1.poolInfo[poolName];
|
|
165
165
|
const receipt = await (0, index_js_1.getReceipts)(poolName, address, true);
|
|
166
|
-
const alphaReceipt = await (0, index_js_1.getReceipts)("ALPHA", address, true);
|
|
167
166
|
await exports.alphalendClient.updatePrices(txb, [
|
|
168
167
|
index_js_1.coinsList["STSUI"].type,
|
|
169
168
|
"0x2::sui::SUI",
|
|
170
169
|
]);
|
|
171
170
|
if (receipt.length > 0) {
|
|
172
|
-
let alpha_receipt
|
|
173
|
-
|
|
174
|
-
[
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
arguments: [],
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
[alpha_receipt] = txb.moveCall({
|
|
182
|
-
target: `0x1::option::some`,
|
|
183
|
-
typeArguments: [alphaReceipt[0].content.type],
|
|
184
|
-
arguments: [txb.object(alphaReceipt[0].objectId)],
|
|
185
|
-
});
|
|
186
|
-
}
|
|
171
|
+
let alpha_receipt = txb.moveCall({
|
|
172
|
+
target: `0x1::option::none`,
|
|
173
|
+
typeArguments: [C.ALPHA_POOL_RECEIPT],
|
|
174
|
+
arguments: [],
|
|
175
|
+
});
|
|
187
176
|
txb.moveCall({
|
|
188
177
|
target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_one_swap`,
|
|
189
178
|
typeArguments: [index_js_1.coinsList["ALPHA"].type],
|
|
@@ -254,25 +243,14 @@ async function alphalendSingleLoopWithdraw(poolName, xTokens, options) {
|
|
|
254
243
|
const txb = new transactions_1.Transaction();
|
|
255
244
|
const poolData = index_js_1.poolInfo[poolName];
|
|
256
245
|
const receipt = await (0, index_js_1.getReceipts)(poolName, address, true);
|
|
257
|
-
const alphaReceipt = await (0, index_js_1.getReceipts)("ALPHA", address, true);
|
|
258
246
|
const coinName = index_js_1.loopingPoolCoinMap[poolName].supplyCoin;
|
|
259
247
|
await exports.alphalendClient.updatePrices(txb, [index_js_1.coinsList[coinName].type]);
|
|
260
248
|
if (receipt.length > 0) {
|
|
261
|
-
let alpha_receipt
|
|
262
|
-
|
|
263
|
-
[
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
arguments: [],
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
[alpha_receipt] = txb.moveCall({
|
|
271
|
-
target: `0x1::option::some`,
|
|
272
|
-
typeArguments: [alphaReceipt[0].content.type],
|
|
273
|
-
arguments: [txb.object(alphaReceipt[0].objectId)],
|
|
274
|
-
});
|
|
275
|
-
}
|
|
249
|
+
let alpha_receipt = txb.moveCall({
|
|
250
|
+
target: `0x1::option::none`,
|
|
251
|
+
typeArguments: [C.ALPHA_POOL_RECEIPT],
|
|
252
|
+
arguments: [],
|
|
253
|
+
});
|
|
276
254
|
await (0, index_js_1.collectAndSwapRewardsSingleLoop)(poolName, txb);
|
|
277
255
|
const [coin] = txb.moveCall({
|
|
278
256
|
target: `${poolData.packageId}::alphafi_alphalend_single_loop_pool::user_withdraw`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alphalend.js","sourceRoot":"","sources":["../../../src/transactions/alphalend.ts"],"names":[],"mappings":";;;AAgBA,0DAWC;AACD,4DAWC;AAED,wEAwFC;AAED,gEA0DC;AAED,0EAoGC;AACD,kEA4DC;AAhWD,2DAAuD;AACvD,0CAUqB;AAErB,0DAAyD;AACzD,6CAA6C;AAEtC,KAAK,UAAU,uBAAuB,CAC3C,QAAkB,EAClB,MAAc,EACd,OAA4B;IAE5B,IAAI,GAAG,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE5B,IAAI,QAAQ,KAAK,0BAA0B,EAAE,CAAC;QAC5C,GAAG,GAAG,MAAM,8BAA8B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AACM,KAAK,UAAU,wBAAwB,CAC5C,QAAkB,EAClB,OAAe,EACf,OAA4B;IAE5B,IAAI,GAAG,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE5B,IAAI,QAAQ,KAAK,0BAA0B,EAAE,CAAC;QAC5C,GAAG,GAAG,MAAM,+BAA+B,CAAC,OAAO,EAA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;QACL,CAAC;QACD,MAAM,IAAA,0CAA+B,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC;YAC1B,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,qDAAqD;YAClF,aAAa,EAAE,CAAC,oBAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;YACzC,SAAS,EAAE;gBACT,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,uBAAuB,CAAC;gBACrC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAC/B,aAAa;gBACb,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;gBACxB,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC3B,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAC/B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC;gBAC/B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC;gBACjC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC;aAC/B;SACF,CAAC,CAAC;QACH,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { Transaction } from \"@mysten/sui/transactions\";\nimport {\n bluefinPoolMap,\n cetusPoolMap,\n coinsList,\n collectAndSwapRewardsSingleLoop,\n getConf,\n getReceipts,\n getSuiClient,\n loopingPoolCoinMap,\n poolInfo,\n} from \"../index.js\";\nimport { PoolName, Receipt } from \"../common/types.js\";\nimport { AlphalendClient } from \"@alphafi/alphalend-sdk\";\nimport { getCoinObject } from \"./bluefin.js\";\n\nexport async function alphalendLoopingDeposit(\n poolName: PoolName,\n amount: string,\n options: { address: string },\n) {\n let txb = new Transaction();\n\n if (poolName === \"ALPHALEND-LOOP-SUI-STSUI\") {\n txb = await alphalendSuiStsuiLoopDepositTx(amount, options);\n }\n return txb;\n}\nexport async function alphalendLoopingWithdraw(\n poolName: PoolName,\n xTokens: string,\n options: { address: string },\n) {\n let txb = new Transaction();\n\n if (poolName === \"ALPHALEND-LOOP-SUI-STSUI\") {\n txb = await alphalendSuiStsuiLoopWithdrawTx(xTokens, options);\n }\n return txb;\n}\nexport const alphalendClient = new AlphalendClient(\"mainnet\", getSuiClient());\nexport async function alphalendSuiStsuiLoopDepositTx(\n amount: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolName = \"ALPHALEND-LOOP-SUI-STSUI\";\n const poolData = poolInfo[poolName];\n\n await alphalendClient.updatePrices(txb, [\n coinsList[\"STSUI\"].type,\n \"0x2::sui::SUI\",\n ]);\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n let someReceipt: any;\n if (receipt.length == 0) {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [poolData.receiptType],\n arguments: [],\n });\n } else {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [receipt[0].content.type],\n arguments: [txb.object(receipt[0].objectId)],\n });\n }\n const [depositCoin] = txb.splitCoins(txb.gas, [amount]);\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_one_swap`,\n typeArguments: [coinsList[\"ALPHA\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(bluefinPoolMap[`ALPHA-STSUI`]),\n txb.object(C.BLUEFIN_GLOBAL_CONFIG),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_no_swap_v2`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_two_swaps_v2`,\n typeArguments: [coinsList[\"BLUE\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(cetusPoolMap[`BLUE-SUI`]),\n txb.object(C.CETUS_GLOBAL_CONFIG_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::user_deposit_v3`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(C.VERSION),\n someReceipt,\n txb.object(poolData.poolId),\n depositCoin,\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n\n return txb;\n}\n\nexport async function alphalendSingleLoopDeposit(\n poolName: PoolName,\n amount: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolData = poolInfo[poolName];\n\n const coinName = loopingPoolCoinMap[poolName].supplyCoin;\n\n await alphalendClient.updatePrices(txb, [coinsList[coinName].type]);\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n let someReceipt: any;\n if (receipt.length == 0) {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [poolData.receiptType],\n arguments: [],\n });\n } else {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [receipt[0].content.type],\n arguments: [txb.object(receipt[0].objectId)],\n });\n }\n let totalCoin: any;\n if (coinName === \"SUI\") {\n totalCoin = txb.gas;\n } else {\n totalCoin = await getCoinObject(coinsList[coinName].type, address, txb);\n }\n const [depositCoin] = txb.splitCoins(totalCoin, [amount]);\n await collectAndSwapRewardsSingleLoop(poolName, txb);\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_alphalend_single_loop_pool::user_deposit`,\n typeArguments: [coinsList[coinName].type],\n arguments: [\n txb.object(C.ALPHA_ALPHALEND_VERSION),\n txb.object(C.VERSION),\n someReceipt,\n txb.object(poolData.poolId),\n depositCoin,\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.transferObjects([totalCoin], address);\n return txb;\n}\n\nexport async function alphalendSuiStsuiLoopWithdrawTx(\n xTokens: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolName = \"ALPHALEND-LOOP-SUI-STSUI\";\n const poolData = poolInfo[poolName];\n\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n const alphaReceipt: Receipt[] = await getReceipts(\"ALPHA\", address, true);\n\n await alphalendClient.updatePrices(txb, [\n coinsList[\"STSUI\"].type,\n \"0x2::sui::SUI\",\n ]);\n if (receipt.length > 0) {\n let alpha_receipt: any;\n if (alphaReceipt.length == 0) {\n [alpha_receipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [C.ALPHA_POOL_RECEIPT],\n arguments: [],\n });\n } else {\n [alpha_receipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [alphaReceipt[0].content.type],\n arguments: [txb.object(alphaReceipt[0].objectId)],\n });\n }\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_one_swap`,\n typeArguments: [coinsList[\"ALPHA\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(bluefinPoolMap[`ALPHA-STSUI`]),\n txb.object(C.BLUEFIN_GLOBAL_CONFIG),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_no_swap_v2`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_two_swaps_v2`,\n typeArguments: [coinsList[\"BLUE\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(cetusPoolMap[`BLUE-SUI`]),\n txb.object(C.CETUS_GLOBAL_CONFIG_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n const [stsui_coin] = txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::user_withdraw_v3`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(C.VERSION),\n txb.object(receipt[0].objectId),\n alpha_receipt,\n txb.object(C.ALPHA_POOL),\n txb.object(poolData.poolId),\n txb.pure.u64(xTokens),\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `0x2::transfer::public_transfer`,\n typeArguments: [`0x2::coin::Coin<${coinsList[\"SUI\"].type}>`],\n arguments: [stsui_coin, txb.pure.address(address)],\n });\n } else {\n throw new Error(`No ALPHALEND-LOOP-SUI-STSUI Receipt`);\n }\n\n return txb;\n}\nexport async function alphalendSingleLoopWithdraw(\n poolName: PoolName,\n xTokens: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolData = poolInfo[poolName];\n\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n const alphaReceipt: Receipt[] = await getReceipts(\"ALPHA\", address, true);\n\n const coinName = loopingPoolCoinMap[poolName].supplyCoin;\n\n await alphalendClient.updatePrices(txb, [coinsList[coinName].type]);\n if (receipt.length > 0) {\n let alpha_receipt: any;\n if (alphaReceipt.length == 0) {\n [alpha_receipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [C.ALPHA_POOL_RECEIPT],\n arguments: [],\n });\n } else {\n [alpha_receipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [alphaReceipt[0].content.type],\n arguments: [txb.object(alphaReceipt[0].objectId)],\n });\n }\n await collectAndSwapRewardsSingleLoop(poolName, txb);\n const [coin] = txb.moveCall({\n target: `${poolData.packageId}::alphafi_alphalend_single_loop_pool::user_withdraw`,\n typeArguments: [coinsList[coinName].type],\n arguments: [\n txb.object(C.ALPHA_ALPHALEND_VERSION),\n txb.object(C.VERSION),\n txb.object(receipt[0].objectId),\n alpha_receipt,\n txb.object(C.ALPHA_POOL),\n txb.object(poolData.poolId),\n txb.pure.u64(xTokens),\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.transferObjects([coin], address);\n } else {\n throw new Error(`No ALPHALEND-LOOP-SUI-STSUI Receipt`);\n }\n\n return txb;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"alphalend.js","sourceRoot":"","sources":["../../../src/transactions/alphalend.ts"],"names":[],"mappings":";;;AAgBA,0DAWC;AACD,4DAWC;AAED,wEAwFC;AAED,gEA0DC;AAED,0EAyFC;AACD,kEAiDC;AA1UD,2DAAuD;AACvD,0CAUqB;AAErB,0DAAyD;AACzD,6CAA6C;AAEtC,KAAK,UAAU,uBAAuB,CAC3C,QAAkB,EAClB,MAAc,EACd,OAA4B;IAE5B,IAAI,GAAG,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE5B,IAAI,QAAQ,KAAK,0BAA0B,EAAE,CAAC;QAC5C,GAAG,GAAG,MAAM,8BAA8B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AACM,KAAK,UAAU,wBAAwB,CAC5C,QAAkB,EAClB,OAAe,EACf,OAA4B;IAE5B,IAAI,GAAG,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE5B,IAAI,QAAQ,KAAK,0BAA0B,EAAE,CAAC;QAC5C,GAAG,GAAG,MAAM,+BAA+B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AACY,QAAA,eAAe,GAAG,IAAI,+BAAe,CAAC,SAAS,EAAE,IAAA,uBAAY,GAAE,CAAC,CAAC;AACvE,KAAK,UAAU,8BAA8B,CAClD,MAAc,EACd,OAA4B;IAE5B,MAAM,CAAC,GAAG,IAAA,kBAAO,GAAE,CAAC;IACpB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,0BAAW,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,0BAA0B,CAAC;IA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AG,QAAQ,CAAC,SAAS,qDAAqD;YAClF,aAAa,EAAE,CAAC,oBAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;YACzC,SAAS,EAAE;gBACT,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,uBAAuB,CAAC;gBACrC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAC/B,aAAa;gBACb,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;gBACxB,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC3B,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAC/B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC;gBAC/B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC;gBACjC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC;aAC/B;SACF,CAAC,CAAC;QACH,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { Transaction } from \"@mysten/sui/transactions\";\nimport {\n bluefinPoolMap,\n cetusPoolMap,\n coinsList,\n collectAndSwapRewardsSingleLoop,\n getConf,\n getReceipts,\n getSuiClient,\n loopingPoolCoinMap,\n poolInfo,\n} from \"../index.js\";\nimport { PoolName, Receipt } from \"../common/types.js\";\nimport { AlphalendClient } from \"@alphafi/alphalend-sdk\";\nimport { getCoinObject } from \"./bluefin.js\";\n\nexport async function alphalendLoopingDeposit(\n poolName: PoolName,\n amount: string,\n options: { address: string },\n) {\n let txb = new Transaction();\n\n if (poolName === \"ALPHALEND-LOOP-SUI-STSUI\") {\n txb = await alphalendSuiStsuiLoopDepositTx(amount, options);\n }\n return txb;\n}\nexport async function alphalendLoopingWithdraw(\n poolName: PoolName,\n xTokens: string,\n options: { address: string },\n) {\n let txb = new Transaction();\n\n if (poolName === \"ALPHALEND-LOOP-SUI-STSUI\") {\n txb = await alphalendSuiStsuiLoopWithdrawTx(xTokens, options);\n }\n return txb;\n}\nexport const alphalendClient = new AlphalendClient(\"mainnet\", getSuiClient());\nexport async function alphalendSuiStsuiLoopDepositTx(\n amount: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolName = \"ALPHALEND-LOOP-SUI-STSUI\";\n const poolData = poolInfo[poolName];\n\n await alphalendClient.updatePrices(txb, [\n coinsList[\"STSUI\"].type,\n \"0x2::sui::SUI\",\n ]);\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n let someReceipt: any;\n if (receipt.length == 0) {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [poolData.receiptType],\n arguments: [],\n });\n } else {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [receipt[0].content.type],\n arguments: [txb.object(receipt[0].objectId)],\n });\n }\n const [depositCoin] = txb.splitCoins(txb.gas, [amount]);\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_one_swap`,\n typeArguments: [coinsList[\"ALPHA\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(bluefinPoolMap[`ALPHA-STSUI`]),\n txb.object(C.BLUEFIN_GLOBAL_CONFIG),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_no_swap_v2`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_two_swaps_v2`,\n typeArguments: [coinsList[\"BLUE\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(cetusPoolMap[`BLUE-SUI`]),\n txb.object(C.CETUS_GLOBAL_CONFIG_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::user_deposit_v3`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(C.VERSION),\n someReceipt,\n txb.object(poolData.poolId),\n depositCoin,\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n\n return txb;\n}\n\nexport async function alphalendSingleLoopDeposit(\n poolName: PoolName,\n amount: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolData = poolInfo[poolName];\n\n const coinName = loopingPoolCoinMap[poolName].supplyCoin;\n\n await alphalendClient.updatePrices(txb, [coinsList[coinName].type]);\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n let someReceipt: any;\n if (receipt.length == 0) {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [poolData.receiptType],\n arguments: [],\n });\n } else {\n [someReceipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [receipt[0].content.type],\n arguments: [txb.object(receipt[0].objectId)],\n });\n }\n let totalCoin: any;\n if (coinName === \"SUI\") {\n totalCoin = txb.gas;\n } else {\n totalCoin = await getCoinObject(coinsList[coinName].type, address, txb);\n }\n const [depositCoin] = txb.splitCoins(totalCoin, [amount]);\n await collectAndSwapRewardsSingleLoop(poolName, txb);\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_alphalend_single_loop_pool::user_deposit`,\n typeArguments: [coinsList[coinName].type],\n arguments: [\n txb.object(C.ALPHA_ALPHALEND_VERSION),\n txb.object(C.VERSION),\n someReceipt,\n txb.object(poolData.poolId),\n depositCoin,\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.transferObjects([totalCoin], address);\n return txb;\n}\n\nexport async function alphalendSuiStsuiLoopWithdrawTx(\n xTokens: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolName = \"ALPHALEND-LOOP-SUI-STSUI\";\n const poolData = poolInfo[poolName];\n\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n await alphalendClient.updatePrices(txb, [\n coinsList[\"STSUI\"].type,\n \"0x2::sui::SUI\",\n ]);\n if (receipt.length > 0) {\n let alpha_receipt = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [C.ALPHA_POOL_RECEIPT],\n arguments: [],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_one_swap`,\n typeArguments: [coinsList[\"ALPHA\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(bluefinPoolMap[`ALPHA-STSUI`]),\n txb.object(C.BLUEFIN_GLOBAL_CONFIG),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_no_swap_v2`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::collect_v3_rewards_with_two_swaps_v2`,\n typeArguments: [coinsList[\"BLUE\"].type],\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(poolData.investorId),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(cetusPoolMap[`BLUE-SUI`]),\n txb.object(C.CETUS_GLOBAL_CONFIG_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n const [stsui_coin] = txb.moveCall({\n target: `${poolData.packageId}::alphafi_navi_sui_stsui_pool::user_withdraw_v3`,\n arguments: [\n txb.object(C.ALPHA_5_VERSION),\n txb.object(C.VERSION),\n txb.object(receipt[0].objectId),\n alpha_receipt,\n txb.object(C.ALPHA_POOL),\n txb.object(poolData.poolId),\n txb.pure.u64(xTokens),\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.LST_INFO),\n txb.object(C.SUI_SYSTEM_STATE),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `0x2::transfer::public_transfer`,\n typeArguments: [`0x2::coin::Coin<${coinsList[\"SUI\"].type}>`],\n arguments: [stsui_coin, txb.pure.address(address)],\n });\n } else {\n throw new Error(`No ALPHALEND-LOOP-SUI-STSUI Receipt`);\n }\n\n return txb;\n}\nexport async function alphalendSingleLoopWithdraw(\n poolName: PoolName,\n xTokens: string,\n options: { address: string },\n): Promise<Transaction> {\n const C = getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolData = poolInfo[poolName];\n\n const receipt: Receipt[] = await getReceipts(\n poolName as PoolName,\n address,\n true,\n );\n\n const coinName = loopingPoolCoinMap[poolName].supplyCoin;\n\n await alphalendClient.updatePrices(txb, [coinsList[coinName].type]);\n if (receipt.length > 0) {\n let alpha_receipt = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [C.ALPHA_POOL_RECEIPT],\n arguments: [],\n });\n await collectAndSwapRewardsSingleLoop(poolName, txb);\n const [coin] = txb.moveCall({\n target: `${poolData.packageId}::alphafi_alphalend_single_loop_pool::user_withdraw`,\n typeArguments: [coinsList[coinName].type],\n arguments: [\n txb.object(C.ALPHA_ALPHALEND_VERSION),\n txb.object(C.VERSION),\n txb.object(receipt[0].objectId),\n alpha_receipt,\n txb.object(C.ALPHA_POOL),\n txb.object(poolData.poolId),\n txb.pure.u64(xTokens),\n txb.object(poolData.investorId),\n txb.object(C.ALPHA_DISTRIBUTOR),\n txb.object(C.LENDING_PROTOCOL_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.transferObjects([coin], address);\n } else {\n throw new Error(`No ALPHALEND-LOOP-SUI-STSUI Receipt`);\n }\n\n return txb;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../src/transactions/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAalC,OAAO,EAAE,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AASvD,eAAO,MAAM,yBAAyB,GACpC,QAAQ,MAAM,EACd,UAAU,QAAQ,EAClB,WAAW,OAAO,EAClB,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAC5B,cAAa,WAAW,GAAG,SAAqB,KAC/C,OAAO,CAAC,WAAW,CAmLrB,CAAC;AAEF,eAA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