@alphafi/alphafi-sdk 0.0.35 → 0.0.37
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/README.md +15 -0
- package/dist/cjs/common/coins.d.ts +1 -1
- package/dist/cjs/common/coins.d.ts.map +1 -1
- package/dist/cjs/common/coins.js +15 -11
- package/dist/cjs/common/coins.js.map +1 -1
- package/dist/cjs/common/constants.d.ts +436 -32
- package/dist/cjs/common/constants.d.ts.map +1 -1
- package/dist/cjs/common/constants.js +488 -56
- package/dist/cjs/common/constants.js.map +1 -1
- package/dist/cjs/common/maps.d.ts +46 -28
- package/dist/cjs/common/maps.d.ts.map +1 -1
- package/dist/cjs/common/maps.js +358 -227
- package/dist/cjs/common/maps.js.map +1 -1
- package/dist/cjs/common/types.d.ts +59 -47
- package/dist/cjs/common/types.d.ts.map +1 -1
- package/dist/cjs/common/types.js.map +1 -1
- package/dist/cjs/getAllVaults.d.ts.map +1 -1
- package/dist/cjs/getAllVaults.js +5 -2
- package/dist/cjs/getAllVaults.js.map +1 -1
- package/dist/cjs/getVaultBalances.d.ts +2 -1
- package/dist/cjs/getVaultBalances.d.ts.map +1 -1
- package/dist/cjs/getVaultBalances.js +15 -1
- package/dist/cjs/getVaultBalances.js.map +1 -1
- package/dist/cjs/graphql/getMultiReceipts.d.ts.map +1 -1
- package/dist/cjs/graphql/getMultiReceipts.js +4 -0
- package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
- package/dist/cjs/index.d.ts +7 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +20 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAfterTransactionEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAfterTransactionEvents.js +2 -2
- package/dist/cjs/sui-sdk/events/fetchAfterTransactionEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js +2 -2
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchRebalanceEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchRebalanceEvents.js +5 -7
- package/dist/cjs/sui-sdk/events/fetchRebalanceEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/functions/fetchUserVaultBalances.d.ts +1 -1
- package/dist/cjs/sui-sdk/functions/fetchUserVaultBalances.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/functions/fetchUserVaultBalances.js +11 -20
- package/dist/cjs/sui-sdk/functions/fetchUserVaultBalances.js.map +1 -1
- package/dist/cjs/sui-sdk/functions/fetchUserVaults.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/functions/fetchUserVaults.js +12 -9
- package/dist/cjs/sui-sdk/functions/fetchUserVaults.js.map +1 -1
- package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.d.ts +8 -23
- package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js +157 -141
- package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
- package/dist/cjs/sui-sdk/functions/getReceipts.d.ts +15 -10
- package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/functions/getReceipts.js +274 -190
- package/dist/cjs/sui-sdk/functions/getReceipts.js.map +1 -1
- package/dist/cjs/transactions/alpha.d.ts +4 -0
- package/dist/cjs/transactions/alpha.d.ts.map +1 -0
- package/dist/cjs/transactions/alpha.js +104 -0
- package/dist/cjs/transactions/alpha.js.map +1 -0
- package/dist/cjs/transactions/bluefin.d.ts +15 -0
- package/dist/cjs/transactions/bluefin.d.ts.map +1 -0
- package/dist/cjs/transactions/bluefin.js +457 -0
- package/dist/cjs/transactions/bluefin.js.map +1 -0
- package/dist/cjs/transactions/bucket.d.ts +8 -0
- package/dist/cjs/transactions/bucket.d.ts.map +1 -0
- package/dist/cjs/transactions/bucket.js +131 -0
- package/dist/cjs/transactions/bucket.js.map +1 -0
- package/dist/cjs/transactions/cetus.d.ts +24 -0
- package/dist/cjs/transactions/cetus.d.ts.map +1 -0
- package/dist/cjs/transactions/cetus.js +554 -0
- package/dist/cjs/transactions/cetus.js.map +1 -0
- package/dist/cjs/transactions/collect_rewards.d.ts +3 -0
- package/dist/cjs/transactions/collect_rewards.d.ts.map +1 -0
- package/dist/cjs/transactions/collect_rewards.js +332 -0
- package/dist/cjs/transactions/collect_rewards.js.map +1 -0
- package/dist/cjs/transactions/deposit.d.ts +5 -0
- package/dist/cjs/transactions/deposit.d.ts.map +1 -0
- package/dist/cjs/transactions/deposit.js +57 -0
- package/dist/cjs/transactions/deposit.js.map +1 -0
- package/dist/cjs/transactions/navi.d.ts +9 -0
- package/dist/cjs/transactions/navi.d.ts.map +1 -0
- package/dist/cjs/transactions/navi.js +618 -0
- package/dist/cjs/transactions/navi.js.map +1 -0
- package/dist/cjs/transactions/withdraw.d.ts +5 -0
- package/dist/cjs/transactions/withdraw.d.ts.map +1 -0
- package/dist/cjs/transactions/withdraw.js +52 -0
- package/dist/cjs/transactions/withdraw.js.map +1 -0
- package/dist/cjs/transactions/zapDeposit.d.ts +1 -0
- package/dist/cjs/transactions/zapDeposit.d.ts.map +1 -0
- package/dist/cjs/transactions/zapDeposit.js +730 -0
- package/dist/cjs/transactions/zapDeposit.js.map +1 -0
- package/dist/cjs/utils/clmm/prices.js +9 -9
- package/dist/cjs/utils/clmm/prices.js.map +1 -1
- package/dist/cjs/utils/getHoldersFromTransactionsUtils.d.ts.map +1 -1
- package/dist/cjs/utils/getHoldersFromTransactionsUtils.js +7 -7
- package/dist/cjs/utils/getHoldersFromTransactionsUtils.js.map +1 -1
- package/dist/cjs/utils/hop.js +3 -3
- package/dist/cjs/utils/hop.js.map +1 -1
- package/dist/cjs/utils/prices.d.ts +2 -0
- package/dist/cjs/utils/prices.d.ts.map +1 -1
- package/dist/cjs/utils/prices.js +39 -0
- package/dist/cjs/utils/prices.js.map +1 -1
- package/dist/cjs/utils/userHoldings.d.ts.map +1 -1
- package/dist/cjs/utils/userHoldings.js +18 -18
- package/dist/cjs/utils/userHoldings.js.map +1 -1
- package/dist/esm/common/coins.d.ts +1 -1
- package/dist/esm/common/coins.d.ts.map +1 -1
- package/dist/esm/common/coins.js +14 -10
- package/dist/esm/common/coins.js.map +1 -1
- package/dist/esm/common/constants.d.ts +436 -32
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +488 -56
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/common/maps.d.ts +46 -28
- package/dist/esm/common/maps.d.ts.map +1 -1
- package/dist/esm/common/maps.js +355 -226
- package/dist/esm/common/maps.js.map +1 -1
- package/dist/esm/common/types.d.ts +59 -47
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/common/types.js.map +1 -1
- package/dist/esm/getAllVaults.d.ts.map +1 -1
- package/dist/esm/getAllVaults.js +5 -2
- package/dist/esm/getAllVaults.js.map +1 -1
- package/dist/esm/getVaultBalances.d.ts +2 -1
- package/dist/esm/getVaultBalances.d.ts.map +1 -1
- package/dist/esm/getVaultBalances.js +14 -1
- package/dist/esm/getVaultBalances.js.map +1 -1
- package/dist/esm/graphql/getMultiReceipts.d.ts.map +1 -1
- package/dist/esm/graphql/getMultiReceipts.js +4 -0
- package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
- package/dist/esm/index.d.ts +7 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAfterTransactionEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAfterTransactionEvents.js +4 -4
- package/dist/esm/sui-sdk/events/fetchAfterTransactionEvents.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js +4 -4
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchRebalanceEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchRebalanceEvents.js +7 -9
- package/dist/esm/sui-sdk/events/fetchRebalanceEvents.js.map +1 -1
- package/dist/esm/sui-sdk/functions/fetchUserVaultBalances.d.ts +1 -1
- package/dist/esm/sui-sdk/functions/fetchUserVaultBalances.d.ts.map +1 -1
- package/dist/esm/sui-sdk/functions/fetchUserVaultBalances.js +11 -20
- package/dist/esm/sui-sdk/functions/fetchUserVaultBalances.js.map +1 -1
- package/dist/esm/sui-sdk/functions/fetchUserVaults.d.ts.map +1 -1
- package/dist/esm/sui-sdk/functions/fetchUserVaults.js +13 -10
- package/dist/esm/sui-sdk/functions/fetchUserVaults.js.map +1 -1
- package/dist/esm/sui-sdk/functions/getPortfolioAmounts.d.ts +8 -23
- package/dist/esm/sui-sdk/functions/getPortfolioAmounts.d.ts.map +1 -1
- package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js +158 -144
- package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
- package/dist/esm/sui-sdk/functions/getReceipts.d.ts +15 -10
- package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/esm/sui-sdk/functions/getReceipts.js +266 -186
- package/dist/esm/sui-sdk/functions/getReceipts.js.map +1 -1
- package/dist/esm/transactions/alpha.d.ts +4 -0
- package/dist/esm/transactions/alpha.d.ts.map +1 -0
- package/dist/esm/transactions/alpha.js +99 -0
- package/dist/esm/transactions/alpha.js.map +1 -0
- package/dist/esm/transactions/bluefin.d.ts +15 -0
- package/dist/esm/transactions/bluefin.d.ts.map +1 -0
- package/dist/esm/transactions/bluefin.js +450 -0
- package/dist/esm/transactions/bluefin.js.map +1 -0
- package/dist/esm/transactions/bucket.d.ts +8 -0
- package/dist/esm/transactions/bucket.d.ts.map +1 -0
- package/dist/esm/transactions/bucket.js +127 -0
- package/dist/esm/transactions/bucket.js.map +1 -0
- package/dist/esm/transactions/cetus.d.ts +24 -0
- package/dist/esm/transactions/cetus.d.ts.map +1 -0
- package/dist/esm/transactions/cetus.js +541 -0
- package/dist/esm/transactions/cetus.js.map +1 -0
- package/dist/esm/transactions/collect_rewards.d.ts +3 -0
- package/dist/esm/transactions/collect_rewards.d.ts.map +1 -0
- package/dist/esm/transactions/collect_rewards.js +329 -0
- package/dist/esm/transactions/collect_rewards.js.map +1 -0
- package/dist/esm/transactions/deposit.d.ts +5 -0
- package/dist/esm/transactions/deposit.d.ts.map +1 -0
- package/dist/esm/transactions/deposit.js +53 -0
- package/dist/esm/transactions/deposit.js.map +1 -0
- package/dist/esm/transactions/navi.d.ts +9 -0
- package/dist/esm/transactions/navi.d.ts.map +1 -0
- package/dist/esm/transactions/navi.js +614 -0
- package/dist/esm/transactions/navi.js.map +1 -0
- package/dist/esm/transactions/withdraw.d.ts +5 -0
- package/dist/esm/transactions/withdraw.d.ts.map +1 -0
- package/dist/esm/transactions/withdraw.js +49 -0
- package/dist/esm/transactions/withdraw.js.map +1 -0
- package/dist/esm/transactions/zapDeposit.d.ts +2 -0
- package/dist/esm/transactions/zapDeposit.d.ts.map +1 -0
- package/dist/esm/transactions/zapDeposit.js +730 -0
- package/dist/esm/transactions/zapDeposit.js.map +1 -0
- package/dist/esm/utils/clmm/prices.js +10 -10
- package/dist/esm/utils/clmm/prices.js.map +1 -1
- package/dist/esm/utils/getHoldersFromTransactionsUtils.d.ts.map +1 -1
- package/dist/esm/utils/getHoldersFromTransactionsUtils.js +9 -9
- package/dist/esm/utils/getHoldersFromTransactionsUtils.js.map +1 -1
- package/dist/esm/utils/hop.js +4 -4
- package/dist/esm/utils/hop.js.map +1 -1
- package/dist/esm/utils/prices.d.ts +2 -0
- package/dist/esm/utils/prices.d.ts.map +1 -1
- package/dist/esm/utils/prices.js +37 -0
- package/dist/esm/utils/prices.js.map +1 -1
- package/dist/esm/utils/userHoldings.d.ts.map +1 -1
- package/dist/esm/utils/userHoldings.js +20 -20
- package/dist/esm/utils/userHoldings.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucket.js","sourceRoot":"","sources":["../../../src/transactions/bucket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,SAAS,EACT,OAAO,EACP,WAAW,EACX,YAAY,EACZ,QAAQ,EAGR,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,OAA4B;IAE5B,MAAM,CAAC,GAAG,MAAM,OAAO,EAAE,CAAC;IAC1B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEzC,MAAM,OAAO,GAAc,MAAM,WAAW,CAC1C,aAAyB,EACzB,OAAO,EACP,IAAI,CACL,CAAC;IACF,IAAI,KAAK,GAAiB,EAAE,CAAC;IAE7B,IAAI,aAAa,GAA8B,IAAI,CAAC;IAEpD,GAAG,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC;YACxC,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI;YACpE,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QAEH,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEpC,+BAA+B;QAC/B,IAAI,QAAQ,CAAC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3B,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,eAAe,CAAC;gBAC7B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;gBACtB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;gBACnB,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;gBACpC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAsB,CAAC;gBACpC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC;aAC/B;SACF,CAAC,CAAC;QACH,GAAG,CAAC,QAAQ,CAAC;YACX,MAAM,EAAE,gCAAgC;YACxC,aAAa,EAAE,CAAC,mBAAmB,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC;YAC7D,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,MAAM,aAAa,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { CoinStruct } from \"@mysten/sui/client\";\nimport { Transaction } from \"@mysten/sui/transactions\";\nimport {\n cetusPoolMap,\n coinsList,\n getConf,\n getReceipts,\n getSuiClient,\n poolInfo,\n PoolName,\n Receipt,\n singleAssetPoolCoinMap,\n} from \"../index.js\";\n\nexport async function bucketDepositTx(\n amount: number,\n options: { address: string },\n): Promise<Transaction> {\n const C = await getConf();\n const suiClient = getSuiClient();\n const address = options.address;\n const txb = new Transaction();\n const poolData = poolInfo[\"BUCKET-BUCK\"];\n\n const receipt: Receipt[] = await getReceipts(\n \"BUCKET-BUCK\" as PoolName,\n address,\n true,\n );\n let coins: CoinStruct[] = [];\n\n let currentCursor: string | null | undefined = null;\n\n do {\n const response = await suiClient.getCoins({\n owner: address,\n coinType: coinsList[singleAssetPoolCoinMap[\"BUCKET-BUCK\"].coin].type,\n cursor: currentCursor,\n });\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 // console.log(\"No more receipts available.\");\n break;\n }\n } while (true);\n\n if (coins.length >= 1) {\n const [coin] = txb.splitCoins(txb.object(coins[0].coinObjectId), [0]);\n txb.mergeCoins(\n coin,\n coins.map((c) => c.coinObjectId),\n );\n const [depositCoin] = txb.splitCoins(coin, [amount]);\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\n txb.moveCall({\n target: `${poolData.packageId}::alphafi_bucket_pool_v1::user_deposit`,\n arguments: [\n txb.object(C.ALPHA_3_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.BUCKET_PROTOCOL),\n txb.object(C.FOUNTAIN),\n txb.object(C.FLASK),\n txb.object(cetusPoolMap[\"USDC-SUI\"]),\n txb.object(C.CETUS_GLOBAL_CONFIG_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.transferObjects([coin], address);\n } else {\n throw new Error(\"No coin\");\n }\n return txb;\n}\n\nexport async function bucketWithdrawTx(\n xtokens: number,\n options: { address: string },\n): Promise<Transaction> {\n const C = await getConf();\n const address = options.address;\n const txb = new Transaction();\n const poolData = poolInfo[\"BUCKET-BUCK\"];\n\n const receipt: Receipt[] = await getReceipts(\n \"BUCKET-BUCK\" as PoolName,\n address,\n true,\n );\n\n const alphaReceipt: Receipt[] = await getReceipts(\"ALPHA\", address, true);\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\n const [buck] = txb.moveCall({\n target: `${poolData.packageId}::alphafi_bucket_pool_v1::user_withdraw`,\n arguments: [\n txb.object(C.ALPHA_3_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.BUCKET_PROTOCOL),\n txb.object(C.FOUNTAIN),\n txb.object(C.FLASK),\n txb.object(cetusPoolMap[\"USDC-SUI\"]),\n txb.object(C.CETUS_GLOBAL_CONFIG_ID),\n txb.object(C.CLOCK_PACKAGE_ID),\n ],\n });\n txb.moveCall({\n target: `0x2::transfer::public_transfer`,\n typeArguments: [`0x2::coin::Coin<${coinsList[\"BUCK\"].type}>`],\n arguments: [buck, txb.pure.address(address)],\n });\n } else {\n throw new Error(`No ${\"BUCKET-BUCK\"} Receipt`);\n }\n\n return txb;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { PoolName } from "../index.js";
|
|
3
|
+
export declare const depositCetusAlphaSuiTxb: (amount: string, poolName: PoolName, isAmountA: boolean, options: {
|
|
4
|
+
address: string;
|
|
5
|
+
}, transaction?: Transaction | undefined) => Promise<Transaction>;
|
|
6
|
+
export declare const depositCetusSuiTxb: (amount: string, poolName: PoolName, isAmountA: boolean, options: {
|
|
7
|
+
address: string;
|
|
8
|
+
}, transaction?: Transaction | undefined) => Promise<Transaction>;
|
|
9
|
+
export declare const depositCetusTxb: (amount: string, poolName: PoolName, isAmountA: boolean, options: {
|
|
10
|
+
address: string;
|
|
11
|
+
}, transaction?: Transaction | undefined) => Promise<Transaction>;
|
|
12
|
+
export declare const withdrawCetusAlphaSuiTxb: (amount: string | number, poolName: string, options: {
|
|
13
|
+
address: string;
|
|
14
|
+
}) => Promise<Transaction>;
|
|
15
|
+
export declare const withdrawCetusSuiTxb: (amount: string | number, poolName: string, options: {
|
|
16
|
+
address: string;
|
|
17
|
+
}) => Promise<Transaction>;
|
|
18
|
+
export declare const withdrawCetusTxb: (amount: string | number, poolName: string, options: {
|
|
19
|
+
address: string;
|
|
20
|
+
}) => Promise<Transaction>;
|
|
21
|
+
export declare function getLiquidity(poolName: PoolName, a2b: boolean, amount: string): Promise<import("@cetusprotocol/cetus-sui-clmm-sdk").LiquidityInput | undefined>;
|
|
22
|
+
export declare function getAmounts(poolName: PoolName, a2b: boolean, amount: string): Promise<[string, string] | undefined>;
|
|
23
|
+
export declare function getCoinAmountsFromLiquidity(poolName: PoolName, liquidity: string): Promise<[string, string]>;
|
|
24
|
+
//# sourceMappingURL=cetus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cetus.d.ts","sourceRoot":"","sources":["../../../src/transactions/cetus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,OAAO,EAaL,QAAQ,EAET,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,uBAAuB,WAC1B,MAAM,YACJ,QAAQ,aACP,OAAO,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,gBACf,WAAW,GAAG,SAAS,KACnC,OAA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ocol/cetus-sui-clmm-sdk";
|
|
3
|
+
import BN from "bn.js";
|
|
4
|
+
import { cetusPoolMap, coinsList, doubleAssetPoolCoinMap, getConf, getInvestor, getParentPool, getReceipts, getSuiClient, poolInfo, } from "../index.js";
|
|
5
|
+
export const depositCetusAlphaSuiTxb = async (amount, poolName, isAmountA, options, transaction = undefined) => {
|
|
6
|
+
const suiClient = getSuiClient();
|
|
7
|
+
const address = options.address;
|
|
8
|
+
let txb;
|
|
9
|
+
if (transaction)
|
|
10
|
+
txb = transaction;
|
|
11
|
+
else
|
|
12
|
+
txb = new Transaction();
|
|
13
|
+
poolName = poolName.toUpperCase();
|
|
14
|
+
const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
15
|
+
const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
16
|
+
const receipt = await getReceipts(poolName, address, true);
|
|
17
|
+
let coins1 = [];
|
|
18
|
+
let currentCursor = null;
|
|
19
|
+
do {
|
|
20
|
+
const response = await suiClient.getCoins({
|
|
21
|
+
owner: address,
|
|
22
|
+
coinType: coinsList[pool1].type,
|
|
23
|
+
cursor: currentCursor,
|
|
24
|
+
});
|
|
25
|
+
coins1 = coins1.concat(response.data);
|
|
26
|
+
// Check if there's a next page
|
|
27
|
+
if (response.hasNextPage && response.nextCursor) {
|
|
28
|
+
currentCursor = response.nextCursor;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// No more pages available
|
|
32
|
+
// console.log("No more receipts available.");
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
} while (true);
|
|
36
|
+
const amounts = await getAmounts(poolName, isAmountA, amount);
|
|
37
|
+
if (amounts) {
|
|
38
|
+
const amount1 = amounts[0];
|
|
39
|
+
const amount2 = amounts[1];
|
|
40
|
+
let coin1;
|
|
41
|
+
if (coins1.length >= 1) {
|
|
42
|
+
//coin1
|
|
43
|
+
[coin1] = txb.splitCoins(txb.object(coins1[0].coinObjectId), [0]);
|
|
44
|
+
txb.mergeCoins(coin1, coins1.map((c) => c.coinObjectId));
|
|
45
|
+
const [depositCoinA] = txb.splitCoins(coin1, [amount1]);
|
|
46
|
+
//coin2
|
|
47
|
+
const [depositCoinB] = txb.splitCoins(txb.gas, [amount2]);
|
|
48
|
+
const poolinfo = poolInfo[poolName];
|
|
49
|
+
let someReceipt;
|
|
50
|
+
if (receipt.length == 0) {
|
|
51
|
+
[someReceipt] = txb.moveCall({
|
|
52
|
+
target: `0x1::option::none`,
|
|
53
|
+
typeArguments: [poolinfo.receiptType],
|
|
54
|
+
arguments: [],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
[someReceipt] = txb.moveCall({
|
|
59
|
+
target: `0x1::option::some`,
|
|
60
|
+
typeArguments: [receipt[0].content.type],
|
|
61
|
+
arguments: [txb.object(receipt[0].objectId)],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
txb.moveCall({
|
|
65
|
+
target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
|
|
66
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
67
|
+
arguments: [
|
|
68
|
+
txb.object(getConf().VERSION),
|
|
69
|
+
someReceipt,
|
|
70
|
+
txb.object(poolinfo.poolId),
|
|
71
|
+
depositCoinA,
|
|
72
|
+
depositCoinB,
|
|
73
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
74
|
+
txb.object(poolinfo.investorId),
|
|
75
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
76
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
77
|
+
txb.object(cetusPoolMap["CETUS-SUI"]),
|
|
78
|
+
txb.object(cetusPoolMap[poolName]),
|
|
79
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
txb.transferObjects([coin1], address);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new Error(`No ${pool1} or ${pool2} Coins`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return txb;
|
|
89
|
+
};
|
|
90
|
+
export const depositCetusSuiTxb = async (amount, poolName, isAmountA, options, transaction = undefined) => {
|
|
91
|
+
const suiClient = getSuiClient();
|
|
92
|
+
const address = options.address;
|
|
93
|
+
let txb;
|
|
94
|
+
if (transaction)
|
|
95
|
+
txb = transaction;
|
|
96
|
+
else
|
|
97
|
+
txb = new Transaction();
|
|
98
|
+
poolName = poolName.toUpperCase();
|
|
99
|
+
const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
100
|
+
const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
101
|
+
const receipt = await getReceipts(poolName, address, true);
|
|
102
|
+
let coins1 = [];
|
|
103
|
+
let currentCursor = null;
|
|
104
|
+
do {
|
|
105
|
+
const response = await suiClient.getCoins({
|
|
106
|
+
owner: address,
|
|
107
|
+
coinType: coinsList[pool1].type,
|
|
108
|
+
cursor: currentCursor,
|
|
109
|
+
});
|
|
110
|
+
coins1 = coins1.concat(response.data);
|
|
111
|
+
// Check if there's a next page
|
|
112
|
+
if (response.hasNextPage && response.nextCursor) {
|
|
113
|
+
currentCursor = response.nextCursor;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// No more pages available
|
|
117
|
+
// console.log("No more receipts available.");
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
} while (true);
|
|
121
|
+
const amounts = await getAmounts(poolName, isAmountA, amount);
|
|
122
|
+
if (amounts) {
|
|
123
|
+
const amount1 = amounts[0];
|
|
124
|
+
const amount2 = amounts[1];
|
|
125
|
+
let coin1;
|
|
126
|
+
if (coins1.length >= 1) {
|
|
127
|
+
//coin1
|
|
128
|
+
[coin1] = txb.splitCoins(txb.object(coins1[0].coinObjectId), [0]);
|
|
129
|
+
txb.mergeCoins(coin1, coins1.map((c) => c.coinObjectId));
|
|
130
|
+
const [depositCoinA] = txb.splitCoins(coin1, [amount1]);
|
|
131
|
+
//coin2
|
|
132
|
+
const [depositCoinB] = txb.splitCoins(txb.gas, [amount2]);
|
|
133
|
+
const poolinfo = poolInfo[poolName];
|
|
134
|
+
let someReceipt;
|
|
135
|
+
if (receipt.length == 0) {
|
|
136
|
+
[someReceipt] = txb.moveCall({
|
|
137
|
+
target: `0x1::option::none`,
|
|
138
|
+
typeArguments: [poolinfo.receiptType],
|
|
139
|
+
arguments: [],
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
[someReceipt] = txb.moveCall({
|
|
144
|
+
target: `0x1::option::some`,
|
|
145
|
+
typeArguments: [receipt[0].content.type],
|
|
146
|
+
arguments: [txb.object(receipt[0].objectId)],
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
txb.moveCall({
|
|
150
|
+
target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
|
|
151
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
152
|
+
arguments: [
|
|
153
|
+
txb.object(getConf().ALPHA_2_VERSION),
|
|
154
|
+
txb.object(getConf().VERSION),
|
|
155
|
+
someReceipt,
|
|
156
|
+
txb.object(poolinfo.poolId),
|
|
157
|
+
depositCoinA,
|
|
158
|
+
depositCoinB,
|
|
159
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
160
|
+
txb.object(poolinfo.investorId),
|
|
161
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
162
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
163
|
+
txb.object(cetusPoolMap[poolName]),
|
|
164
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
txb.transferObjects([coin1], address);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
throw new Error(`No ${pool1} or ${pool2} Coins`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return txb;
|
|
174
|
+
};
|
|
175
|
+
export const depositCetusTxb = async (amount, poolName, isAmountA, options, transaction = undefined) => {
|
|
176
|
+
const suiClient = getSuiClient();
|
|
177
|
+
const address = options.address;
|
|
178
|
+
let txb;
|
|
179
|
+
if (transaction)
|
|
180
|
+
txb = transaction;
|
|
181
|
+
else
|
|
182
|
+
txb = new Transaction();
|
|
183
|
+
poolName = poolName.toUpperCase();
|
|
184
|
+
const poolinfo = poolInfo[poolName];
|
|
185
|
+
const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
186
|
+
const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
187
|
+
const receipt = await getReceipts(poolName, address, true);
|
|
188
|
+
let coins1 = [];
|
|
189
|
+
let coins2 = [];
|
|
190
|
+
let currentCursor = null;
|
|
191
|
+
do {
|
|
192
|
+
const response = await suiClient.getCoins({
|
|
193
|
+
owner: address,
|
|
194
|
+
coinType: coinsList[pool1].type,
|
|
195
|
+
cursor: currentCursor,
|
|
196
|
+
});
|
|
197
|
+
coins1 = coins1.concat(response.data);
|
|
198
|
+
// Check if there's a next page
|
|
199
|
+
if (response.hasNextPage && response.nextCursor) {
|
|
200
|
+
currentCursor = response.nextCursor;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// No more pages available
|
|
204
|
+
// console.log("No more receipts available.");
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
} while (true);
|
|
208
|
+
currentCursor = null;
|
|
209
|
+
do {
|
|
210
|
+
const response = await suiClient.getCoins({
|
|
211
|
+
owner: address,
|
|
212
|
+
coinType: coinsList[pool2].type,
|
|
213
|
+
cursor: currentCursor,
|
|
214
|
+
});
|
|
215
|
+
coins2 = coins2.concat(response.data);
|
|
216
|
+
// Check if there's a next page
|
|
217
|
+
if (response.hasNextPage && response.nextCursor) {
|
|
218
|
+
currentCursor = response.nextCursor;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
// No more pages available
|
|
222
|
+
// console.log("No more receipts available.");
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
} while (true);
|
|
226
|
+
const amounts = await getAmounts(poolName, isAmountA, amount);
|
|
227
|
+
if (amounts) {
|
|
228
|
+
const amount1 = amounts[0];
|
|
229
|
+
const amount2 = amounts[1];
|
|
230
|
+
let coin1;
|
|
231
|
+
let coin2;
|
|
232
|
+
if (coins1.length >= 1 && coins2.length >= 1) {
|
|
233
|
+
//coin1
|
|
234
|
+
[coin1] = txb.splitCoins(txb.object(coins1[0].coinObjectId), [0]);
|
|
235
|
+
txb.mergeCoins(coin1, coins1.map((c) => c.coinObjectId));
|
|
236
|
+
const [depositCoinA] = txb.splitCoins(coin1, [amount1]);
|
|
237
|
+
//coin2
|
|
238
|
+
[coin2] = txb.splitCoins(txb.object(coins2[0].coinObjectId), [0]);
|
|
239
|
+
txb.mergeCoins(coin2, coins2.map((c) => c.coinObjectId));
|
|
240
|
+
const [depositCoinB] = txb.splitCoins(coin2, [amount2]);
|
|
241
|
+
let someReceipt;
|
|
242
|
+
if (receipt.length == 0) {
|
|
243
|
+
[someReceipt] = txb.moveCall({
|
|
244
|
+
target: `0x1::option::none`,
|
|
245
|
+
typeArguments: [poolinfo.receiptType],
|
|
246
|
+
arguments: [],
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
[someReceipt] = txb.moveCall({
|
|
251
|
+
target: `0x1::option::some`,
|
|
252
|
+
typeArguments: [receipt[0].content.type],
|
|
253
|
+
arguments: [txb.object(receipt[0].objectId)],
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
if (poolName == "WUSDC-WBTC" ||
|
|
257
|
+
poolName == "USDC-USDT" ||
|
|
258
|
+
poolName == "USDC-WUSDC" ||
|
|
259
|
+
poolName == "USDC-ETH") {
|
|
260
|
+
txb.moveCall({
|
|
261
|
+
target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool_base_a::user_deposit`,
|
|
262
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
263
|
+
arguments: [
|
|
264
|
+
txb.object(getConf().VERSION),
|
|
265
|
+
someReceipt,
|
|
266
|
+
txb.object(poolinfo.poolId),
|
|
267
|
+
depositCoinA,
|
|
268
|
+
depositCoinB,
|
|
269
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
270
|
+
txb.object(poolinfo.investorId),
|
|
271
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
272
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
273
|
+
txb.object(cetusPoolMap[`${pool1}-SUI`]),
|
|
274
|
+
txb.object(cetusPoolMap["CETUS-SUI"]),
|
|
275
|
+
txb.object(cetusPoolMap[poolName]),
|
|
276
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
277
|
+
],
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
txb.moveCall({
|
|
282
|
+
target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool::user_deposit`,
|
|
283
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
284
|
+
arguments: [
|
|
285
|
+
txb.object(getConf().VERSION),
|
|
286
|
+
someReceipt,
|
|
287
|
+
txb.object(poolinfo.poolId),
|
|
288
|
+
depositCoinA,
|
|
289
|
+
depositCoinB,
|
|
290
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
291
|
+
txb.object(poolinfo.investorId),
|
|
292
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
293
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
294
|
+
txb.object(cetusPoolMap[`${pool2}-SUI`]),
|
|
295
|
+
txb.object(cetusPoolMap["CETUS-SUI"]),
|
|
296
|
+
txb.object(cetusPoolMap[poolName]),
|
|
297
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
298
|
+
],
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
txb.transferObjects([coin1], address);
|
|
302
|
+
txb.transferObjects([coin2], address);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
throw new Error(`No ${pool1} or ${pool2} Coins`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return txb;
|
|
309
|
+
};
|
|
310
|
+
export const withdrawCetusAlphaSuiTxb = async (amount, poolName, options) => {
|
|
311
|
+
const address = options.address;
|
|
312
|
+
const txb = new Transaction();
|
|
313
|
+
const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
314
|
+
const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
315
|
+
const receipt = await getReceipts(poolName, address, true);
|
|
316
|
+
const alphaReceipt = await getReceipts("ALPHA", address, true);
|
|
317
|
+
if (receipt.length > 0) {
|
|
318
|
+
let alpha_receipt;
|
|
319
|
+
if (alphaReceipt.length == 0) {
|
|
320
|
+
[alpha_receipt] = txb.moveCall({
|
|
321
|
+
target: `0x1::option::none`,
|
|
322
|
+
typeArguments: [getConf().ALPHA_POOL_RECEIPT],
|
|
323
|
+
arguments: [],
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
[alpha_receipt] = txb.moveCall({
|
|
328
|
+
target: `0x1::option::some`,
|
|
329
|
+
typeArguments: [alphaReceipt[0].content.type],
|
|
330
|
+
arguments: [txb.object(alphaReceipt[0].objectId)],
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
const poolinfo = poolInfo[poolName];
|
|
334
|
+
txb.moveCall({
|
|
335
|
+
target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_withdraw`,
|
|
336
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
337
|
+
arguments: [
|
|
338
|
+
txb.object(getConf().VERSION),
|
|
339
|
+
txb.object(receipt[0].objectId),
|
|
340
|
+
alpha_receipt,
|
|
341
|
+
txb.object(getConf().ALPHA_POOL),
|
|
342
|
+
txb.object(poolinfo.poolId),
|
|
343
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
344
|
+
txb.object(poolinfo.investorId),
|
|
345
|
+
txb.pure.u128(amount),
|
|
346
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
347
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
348
|
+
txb.object(cetusPoolMap["CETUS-SUI"]),
|
|
349
|
+
txb.object(cetusPoolMap[poolName]),
|
|
350
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
351
|
+
],
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
throw new Error("No receipt found!");
|
|
356
|
+
}
|
|
357
|
+
return txb;
|
|
358
|
+
};
|
|
359
|
+
export const withdrawCetusSuiTxb = async (amount, poolName, options) => {
|
|
360
|
+
const address = options.address;
|
|
361
|
+
const txb = new Transaction();
|
|
362
|
+
const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
363
|
+
const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
364
|
+
const receipt = await getReceipts(poolName, address, true);
|
|
365
|
+
const alphaReceipt = await getReceipts("ALPHA", address, true);
|
|
366
|
+
if (receipt.length > 0) {
|
|
367
|
+
let alpha_receipt;
|
|
368
|
+
if (alphaReceipt.length == 0) {
|
|
369
|
+
[alpha_receipt] = txb.moveCall({
|
|
370
|
+
target: `0x1::option::none`,
|
|
371
|
+
typeArguments: [getConf().ALPHA_POOL_RECEIPT],
|
|
372
|
+
arguments: [],
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
[alpha_receipt] = txb.moveCall({
|
|
377
|
+
target: `0x1::option::some`,
|
|
378
|
+
typeArguments: [alphaReceipt[0].content.type],
|
|
379
|
+
arguments: [txb.object(alphaReceipt[0].objectId)],
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
const poolinfo = poolInfo[poolName];
|
|
383
|
+
txb.moveCall({
|
|
384
|
+
target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_withdraw`,
|
|
385
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
386
|
+
arguments: [
|
|
387
|
+
txb.object(getConf().ALPHA_2_VERSION),
|
|
388
|
+
txb.object(getConf().VERSION),
|
|
389
|
+
txb.object(receipt[0].objectId),
|
|
390
|
+
alpha_receipt,
|
|
391
|
+
txb.object(getConf().ALPHA_POOL),
|
|
392
|
+
txb.object(poolinfo.poolId),
|
|
393
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
394
|
+
txb.object(poolinfo.investorId),
|
|
395
|
+
txb.pure.u128(amount),
|
|
396
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
397
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
398
|
+
txb.object(cetusPoolMap[poolName]),
|
|
399
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
400
|
+
],
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
throw new Error("No receipt found!");
|
|
405
|
+
}
|
|
406
|
+
return txb;
|
|
407
|
+
};
|
|
408
|
+
export const withdrawCetusTxb = async (amount, poolName, options) => {
|
|
409
|
+
const address = options.address;
|
|
410
|
+
const txb = new Transaction();
|
|
411
|
+
const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
|
|
412
|
+
const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
|
|
413
|
+
const receipt = await getReceipts(poolName, address, true);
|
|
414
|
+
const alphaReceipt = await getReceipts("ALPHA", address, true);
|
|
415
|
+
if (receipt.length > 0) {
|
|
416
|
+
let alpha_receipt;
|
|
417
|
+
if (alphaReceipt.length == 0) {
|
|
418
|
+
[alpha_receipt] = txb.moveCall({
|
|
419
|
+
target: `0x1::option::none`,
|
|
420
|
+
typeArguments: [getConf().ALPHA_POOL_RECEIPT],
|
|
421
|
+
arguments: [],
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
[alpha_receipt] = txb.moveCall({
|
|
426
|
+
target: `0x1::option::some`,
|
|
427
|
+
typeArguments: [alphaReceipt[0].content.type],
|
|
428
|
+
arguments: [txb.object(alphaReceipt[0].objectId)],
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
const poolinfo = poolInfo[poolName];
|
|
432
|
+
if (poolName == "WUSDC-WBTC" ||
|
|
433
|
+
poolName == "USDC-USDT" ||
|
|
434
|
+
poolName == "USDC-WUSDC" ||
|
|
435
|
+
poolName == "USDC-ETH") {
|
|
436
|
+
txb.moveCall({
|
|
437
|
+
target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool_base_a::user_withdraw`,
|
|
438
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
439
|
+
arguments: [
|
|
440
|
+
txb.object(getConf().VERSION),
|
|
441
|
+
txb.object(receipt[0].objectId),
|
|
442
|
+
alpha_receipt,
|
|
443
|
+
txb.object(getConf().ALPHA_POOL),
|
|
444
|
+
txb.object(poolinfo.poolId),
|
|
445
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
446
|
+
txb.object(poolinfo.investorId),
|
|
447
|
+
txb.pure.u128(amount),
|
|
448
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
449
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
450
|
+
txb.object(cetusPoolMap[`${pool1}-SUI`]),
|
|
451
|
+
txb.object(cetusPoolMap["CETUS-SUI"]),
|
|
452
|
+
txb.object(cetusPoolMap[poolName]),
|
|
453
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
454
|
+
],
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
txb.moveCall({
|
|
459
|
+
target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool::user_withdraw`,
|
|
460
|
+
typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
|
|
461
|
+
arguments: [
|
|
462
|
+
txb.object(getConf().VERSION),
|
|
463
|
+
txb.object(receipt[0].objectId),
|
|
464
|
+
alpha_receipt,
|
|
465
|
+
txb.object(getConf().ALPHA_POOL),
|
|
466
|
+
txb.object(poolinfo.poolId),
|
|
467
|
+
txb.object(getConf().ALPHA_DISTRIBUTOR),
|
|
468
|
+
txb.object(poolinfo.investorId),
|
|
469
|
+
txb.pure.u128(amount),
|
|
470
|
+
txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
|
|
471
|
+
txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
|
|
472
|
+
txb.object(cetusPoolMap[`${pool2}-SUI`]),
|
|
473
|
+
txb.object(cetusPoolMap["CETUS-SUI"]),
|
|
474
|
+
txb.object(cetusPoolMap[poolName]),
|
|
475
|
+
txb.object(getConf().CLOCK_PACKAGE_ID),
|
|
476
|
+
],
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
throw new Error("No receipt found!");
|
|
482
|
+
}
|
|
483
|
+
return txb;
|
|
484
|
+
};
|
|
485
|
+
export async function getLiquidity(poolName, a2b, amount) {
|
|
486
|
+
const cetusInvestor = (await getInvestor(poolName, true));
|
|
487
|
+
const cetus_pool = await getParentPool(poolName, true);
|
|
488
|
+
if (cetusInvestor && cetus_pool) {
|
|
489
|
+
//TODO
|
|
490
|
+
//check if you calculate lower_tick, upper_tick like this only
|
|
491
|
+
const upper_bound = 443636;
|
|
492
|
+
let lower_tick = Number(cetusInvestor.content.fields.lower_tick);
|
|
493
|
+
let upper_tick = Number(cetusInvestor.content.fields.upper_tick);
|
|
494
|
+
if (lower_tick > upper_bound) {
|
|
495
|
+
lower_tick = -~(lower_tick - 1);
|
|
496
|
+
}
|
|
497
|
+
if (upper_tick > upper_bound) {
|
|
498
|
+
upper_tick = -~(upper_tick - 1);
|
|
499
|
+
}
|
|
500
|
+
// AlphaFi Mascot
|
|
501
|
+
//
|
|
502
|
+
// a
|
|
503
|
+
// ~~|~~
|
|
504
|
+
// / \
|
|
505
|
+
//
|
|
506
|
+
/////////////////
|
|
507
|
+
const current_sqrt_price = new BN(cetus_pool.content.fields.current_sqrt_price);
|
|
508
|
+
const liquidity = ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts(lower_tick, upper_tick, new BN(`${Math.floor(parseFloat(amount))}`), a2b, false, 0.5, current_sqrt_price);
|
|
509
|
+
return liquidity;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
export async function getAmounts(poolName, a2b, amount) {
|
|
513
|
+
const liquidity = await getLiquidity(poolName, a2b, amount);
|
|
514
|
+
if (liquidity) {
|
|
515
|
+
const numA = liquidity.coinAmountA.toString();
|
|
516
|
+
const numB = liquidity.coinAmountB.toString();
|
|
517
|
+
return [numA, numB];
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
export async function getCoinAmountsFromLiquidity(poolName, liquidity) {
|
|
521
|
+
const clmmPool = await getParentPool(poolName, true);
|
|
522
|
+
const investor = (await getInvestor(poolName, true));
|
|
523
|
+
const upper_bound = 443636;
|
|
524
|
+
let lower_tick = Number(investor.content.fields.lower_tick);
|
|
525
|
+
let upper_tick = Number(investor.content.fields.upper_tick);
|
|
526
|
+
if (lower_tick > upper_bound) {
|
|
527
|
+
lower_tick = -~(lower_tick - 1);
|
|
528
|
+
}
|
|
529
|
+
if (upper_tick > upper_bound) {
|
|
530
|
+
upper_tick = -~(upper_tick - 1);
|
|
531
|
+
}
|
|
532
|
+
if (clmmPool) {
|
|
533
|
+
const liquidityInt = Math.floor(parseFloat(liquidity));
|
|
534
|
+
const coin_amounts = ClmmPoolUtil.getCoinAmountFromLiquidity(new BN(`${liquidityInt}`), new BN(clmmPool.content.fields.current_sqrt_price), TickMath.tickIndexToSqrtPriceX64(lower_tick), TickMath.tickIndexToSqrtPriceX64(upper_tick), true);
|
|
535
|
+
return [coin_amounts.coinA.toString(), coin_amounts.coinB.toString()];
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
return ["0", "0"];
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
//# sourceMappingURL=cetus.js.map
|