@t2000/sdk 0.17.16 → 0.17.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/index.cjs +18 -45
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +18 -45
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-xQEri-Eu.d.cts → index-DdtOBw42.d.cts} +3 -0
- package/dist/{index-xQEri-Eu.d.ts → index-DdtOBw42.d.ts} +3 -0
- package/dist/index.cjs +103 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +103 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-
|
|
2
|
-
export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-
|
|
1
|
+
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-DdtOBw42.cjs';
|
|
2
|
+
export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-DdtOBw42.cjs';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
@@ -463,6 +463,7 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
463
463
|
}): Promise<InvestEarnResult>;
|
|
464
464
|
getPendingRewards(): Promise<PendingReward[]>;
|
|
465
465
|
claimRewards(): Promise<ClaimRewardsResult>;
|
|
466
|
+
private swapRewardTokensToUsdc;
|
|
466
467
|
investStrategy(params: {
|
|
467
468
|
strategy: string;
|
|
468
469
|
usdAmount: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-
|
|
2
|
-
export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-
|
|
1
|
+
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-DdtOBw42.js';
|
|
2
|
+
export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-DdtOBw42.js';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
@@ -463,6 +463,7 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
463
463
|
}): Promise<InvestEarnResult>;
|
|
464
464
|
getPendingRewards(): Promise<PendingReward[]>;
|
|
465
465
|
claimRewards(): Promise<ClaimRewardsResult>;
|
|
466
|
+
private swapRewardTokensToUsdc;
|
|
466
467
|
investStrategy(params: {
|
|
467
468
|
strategy: string;
|
|
468
469
|
usdAmount: number;
|
package/dist/index.js
CHANGED
|
@@ -1244,15 +1244,13 @@ function stripPrefix(coinType) {
|
|
|
1244
1244
|
return coinType.replace(/^0x0*/, "");
|
|
1245
1245
|
}
|
|
1246
1246
|
async function getPendingRewards(client, address) {
|
|
1247
|
-
const [pools, states
|
|
1247
|
+
const [pools, states] = await Promise.all([
|
|
1248
1248
|
getPools(),
|
|
1249
|
-
getUserState(client, address)
|
|
1250
|
-
getIncentiveRules(client)
|
|
1249
|
+
getUserState(client, address)
|
|
1251
1250
|
]);
|
|
1252
1251
|
const rewards = [];
|
|
1253
1252
|
const deposited = states.filter((s) => s.supplyBalance > 0n);
|
|
1254
1253
|
if (deposited.length === 0) return rewards;
|
|
1255
|
-
const rewardTotals = /* @__PURE__ */ new Map();
|
|
1256
1254
|
for (const state of deposited) {
|
|
1257
1255
|
const pool = pools.find((p) => p.id === state.assetId);
|
|
1258
1256
|
if (!pool) continue;
|
|
@@ -1261,20 +1259,14 @@ async function getPendingRewards(client, address) {
|
|
|
1261
1259
|
const rewardCoins = pool.supplyIncentiveApyInfo?.rewardCoin;
|
|
1262
1260
|
if (!Array.isArray(rewardCoins) || rewardCoins.length === 0) continue;
|
|
1263
1261
|
const rewardType = rewardCoins[0];
|
|
1264
|
-
const
|
|
1265
|
-
const price = pool.token?.price ?? 0;
|
|
1266
|
-
const depositUsd = supplyBal * price;
|
|
1267
|
-
const annualRewardUsd = depositUsd * (boostedApr / 100);
|
|
1268
|
-
const estimatedUsd = annualRewardUsd / 365;
|
|
1269
|
-
rewardTotals.set(rewardType, (rewardTotals.get(rewardType) ?? 0) + estimatedUsd);
|
|
1270
|
-
}
|
|
1271
|
-
for (const [coinType, dailyUsd] of rewardTotals) {
|
|
1262
|
+
const assetSymbol = resolvePoolSymbol(pool);
|
|
1272
1263
|
rewards.push({
|
|
1273
1264
|
protocol: "navi",
|
|
1274
|
-
|
|
1275
|
-
|
|
1265
|
+
asset: assetSymbol,
|
|
1266
|
+
coinType: rewardType,
|
|
1267
|
+
symbol: REWARD_SYMBOLS[rewardType] ?? rewardType.split("::").pop() ?? "UNKNOWN",
|
|
1276
1268
|
amount: 0,
|
|
1277
|
-
estimatedValueUsd:
|
|
1269
|
+
estimatedValueUsd: 0
|
|
1278
1270
|
});
|
|
1279
1271
|
}
|
|
1280
1272
|
return rewards;
|
|
@@ -1335,6 +1327,7 @@ async function addClaimRewardsToTx(tx, client, address) {
|
|
|
1335
1327
|
tx.transferObjects([coin], address);
|
|
1336
1328
|
claimed.push({
|
|
1337
1329
|
protocol: "navi",
|
|
1330
|
+
asset: assets.join(", "),
|
|
1338
1331
|
coinType: rewardType,
|
|
1339
1332
|
symbol: REWARD_SYMBOLS[rewardType] ?? "UNKNOWN",
|
|
1340
1333
|
amount: 0,
|
|
@@ -1904,6 +1897,45 @@ async function addSwapToTx(params) {
|
|
|
1904
1897
|
toDecimals: toInfo.decimals
|
|
1905
1898
|
};
|
|
1906
1899
|
}
|
|
1900
|
+
async function buildRawSwapTx(params) {
|
|
1901
|
+
const { client, address, fromCoinType, toCoinType, amount, toDecimals, maxSlippageBps = 500 } = params;
|
|
1902
|
+
const aggClient = createAggregatorClient(client, address);
|
|
1903
|
+
const _origLog = console.log;
|
|
1904
|
+
console.log = () => {
|
|
1905
|
+
};
|
|
1906
|
+
let result;
|
|
1907
|
+
try {
|
|
1908
|
+
result = await aggClient.findRouters({
|
|
1909
|
+
from: fromCoinType,
|
|
1910
|
+
target: toCoinType,
|
|
1911
|
+
amount,
|
|
1912
|
+
byAmountIn: true
|
|
1913
|
+
});
|
|
1914
|
+
} finally {
|
|
1915
|
+
console.log = _origLog;
|
|
1916
|
+
}
|
|
1917
|
+
if (!result || result.insufficientLiquidity) {
|
|
1918
|
+
throw new T2000Error("ASSET_NOT_SUPPORTED", `No swap route for reward token \u2192 USDC`);
|
|
1919
|
+
}
|
|
1920
|
+
const tx = new Transaction();
|
|
1921
|
+
const slippage = maxSlippageBps / 1e4;
|
|
1922
|
+
console.log = () => {
|
|
1923
|
+
};
|
|
1924
|
+
try {
|
|
1925
|
+
await aggClient.fastRouterSwap({
|
|
1926
|
+
router: result,
|
|
1927
|
+
txb: tx,
|
|
1928
|
+
slippage
|
|
1929
|
+
});
|
|
1930
|
+
} finally {
|
|
1931
|
+
console.log = _origLog;
|
|
1932
|
+
}
|
|
1933
|
+
return {
|
|
1934
|
+
tx,
|
|
1935
|
+
estimatedOut: Number(result.amountOut.toString()),
|
|
1936
|
+
toDecimals
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
1907
1939
|
async function getPoolPrice(client) {
|
|
1908
1940
|
try {
|
|
1909
1941
|
const pool = await client.getObject({
|
|
@@ -2695,45 +2727,24 @@ var SuilendAdapter = class {
|
|
|
2695
2727
|
this.fetchObligation(caps[0].obligationId)
|
|
2696
2728
|
]);
|
|
2697
2729
|
const rewards = [];
|
|
2698
|
-
const rewardEstimates = /* @__PURE__ */ new Map();
|
|
2699
2730
|
for (const dep of obligation.deposits) {
|
|
2700
2731
|
const reserve = reserves[dep.reserveIdx];
|
|
2701
2732
|
if (!reserve) continue;
|
|
2702
|
-
const ratio = cTokenRatio(reserve);
|
|
2703
|
-
const amount = dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals;
|
|
2704
|
-
const price = reserve.price;
|
|
2705
|
-
const depositUsd = amount * price;
|
|
2706
2733
|
for (const rw of reserve.depositPoolRewards) {
|
|
2707
2734
|
if (!this.isClaimableReward(rw.coinType)) continue;
|
|
2708
|
-
const rewardReserve = reserves.find((r) => {
|
|
2709
|
-
try {
|
|
2710
|
-
return normalizeStructTag(r.coinType) === normalizeStructTag(rw.coinType);
|
|
2711
|
-
} catch {
|
|
2712
|
-
return false;
|
|
2713
|
-
}
|
|
2714
|
-
});
|
|
2715
|
-
const rewardPrice = rewardReserve?.price ?? 0;
|
|
2716
|
-
const rewardDecimals = rewardReserve?.mintDecimals ?? 9;
|
|
2717
2735
|
const durationMs = rw.endTimeMs - rw.startTimeMs;
|
|
2718
2736
|
if (durationMs <= 0) continue;
|
|
2719
|
-
const
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2737
|
+
const assetSymbol = this.resolveSymbol(reserve.coinType);
|
|
2738
|
+
rewards.push({
|
|
2739
|
+
protocol: "suilend",
|
|
2740
|
+
asset: assetSymbol,
|
|
2741
|
+
coinType: rw.coinType,
|
|
2742
|
+
symbol: rw.coinType.includes("spring_sui") ? "sSUI" : rw.coinType.includes("deep::") ? "DEEP" : rw.coinType.split("::").pop() ?? "UNKNOWN",
|
|
2743
|
+
amount: 0,
|
|
2744
|
+
estimatedValueUsd: 0
|
|
2745
|
+
});
|
|
2725
2746
|
}
|
|
2726
2747
|
}
|
|
2727
|
-
for (const [coinType, dailyUsd] of rewardEstimates) {
|
|
2728
|
-
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2729
|
-
rewards.push({
|
|
2730
|
-
protocol: "suilend",
|
|
2731
|
-
coinType,
|
|
2732
|
-
symbol,
|
|
2733
|
-
amount: 0,
|
|
2734
|
-
estimatedValueUsd: dailyUsd
|
|
2735
|
-
});
|
|
2736
|
-
}
|
|
2737
2748
|
return rewards;
|
|
2738
2749
|
}
|
|
2739
2750
|
async addClaimRewardsToTx(tx, address) {
|
|
@@ -2776,6 +2787,7 @@ var SuilendAdapter = class {
|
|
|
2776
2787
|
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2777
2788
|
claimed.push({
|
|
2778
2789
|
protocol: "suilend",
|
|
2790
|
+
asset: "",
|
|
2779
2791
|
coinType,
|
|
2780
2792
|
symbol,
|
|
2781
2793
|
amount: 0,
|
|
@@ -3679,6 +3691,11 @@ var AutoInvestManager = class {
|
|
|
3679
3691
|
}
|
|
3680
3692
|
};
|
|
3681
3693
|
var LOW_LIQUIDITY_ASSETS = /* @__PURE__ */ new Set(["GOLD"]);
|
|
3694
|
+
var REWARD_TOKEN_DECIMALS = {
|
|
3695
|
+
"0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT": 9,
|
|
3696
|
+
"0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP": 6,
|
|
3697
|
+
"0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI": 9
|
|
3698
|
+
};
|
|
3682
3699
|
function defaultSlippage(asset) {
|
|
3683
3700
|
return LOW_LIQUIDITY_ASSETS.has(asset) ? 0.05 : 0.03;
|
|
3684
3701
|
}
|
|
@@ -4880,7 +4897,7 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
4880
4897
|
this.enforcer.assertNotLocked();
|
|
4881
4898
|
const adapters = this.registry.listLending().filter((a) => a.addClaimRewardsToTx);
|
|
4882
4899
|
if (adapters.length === 0) {
|
|
4883
|
-
return { success: true, tx: "", rewards: [], totalValueUsd: 0, gasCost: 0, gasMethod: "none" };
|
|
4900
|
+
return { success: true, tx: "", rewards: [], totalValueUsd: 0, usdcReceived: 0, gasCost: 0, gasMethod: "none" };
|
|
4884
4901
|
}
|
|
4885
4902
|
const tx = new Transaction();
|
|
4886
4903
|
tx.setSender(this._address);
|
|
@@ -4893,18 +4910,52 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
4893
4910
|
}
|
|
4894
4911
|
}
|
|
4895
4912
|
if (allRewards.length === 0) {
|
|
4896
|
-
return { success: true, tx: "", rewards: [], totalValueUsd: 0, gasCost: 0, gasMethod: "none" };
|
|
4913
|
+
return { success: true, tx: "", rewards: [], totalValueUsd: 0, usdcReceived: 0, gasCost: 0, gasMethod: "none" };
|
|
4897
4914
|
}
|
|
4898
|
-
const
|
|
4915
|
+
const claimResult = await executeWithGas(this.client, this.keypair, async () => tx);
|
|
4916
|
+
await this.client.waitForTransaction({ digest: claimResult.digest });
|
|
4917
|
+
const usdcReceived = await this.swapRewardTokensToUsdc(allRewards);
|
|
4899
4918
|
return {
|
|
4900
4919
|
success: true,
|
|
4901
|
-
tx:
|
|
4920
|
+
tx: claimResult.digest,
|
|
4902
4921
|
rewards: allRewards,
|
|
4903
|
-
totalValueUsd:
|
|
4904
|
-
|
|
4905
|
-
|
|
4922
|
+
totalValueUsd: usdcReceived,
|
|
4923
|
+
usdcReceived,
|
|
4924
|
+
gasCost: claimResult.gasCostSui,
|
|
4925
|
+
gasMethod: claimResult.gasMethod
|
|
4906
4926
|
};
|
|
4907
4927
|
}
|
|
4928
|
+
async swapRewardTokensToUsdc(rewards) {
|
|
4929
|
+
const uniqueTokens = [...new Set(rewards.map((r) => r.coinType))];
|
|
4930
|
+
const usdcType = SUPPORTED_ASSETS.USDC.type;
|
|
4931
|
+
const usdcDecimals = SUPPORTED_ASSETS.USDC.decimals;
|
|
4932
|
+
let totalUsdc = 0;
|
|
4933
|
+
for (const coinType of uniqueTokens) {
|
|
4934
|
+
try {
|
|
4935
|
+
const balResult = await this.client.getBalance({
|
|
4936
|
+
owner: this._address,
|
|
4937
|
+
coinType
|
|
4938
|
+
});
|
|
4939
|
+
const rawBalance = BigInt(balResult.totalBalance);
|
|
4940
|
+
if (rawBalance <= 0n) continue;
|
|
4941
|
+
const decimals = REWARD_TOKEN_DECIMALS[coinType] ?? 9;
|
|
4942
|
+
const swapResult = await buildRawSwapTx({
|
|
4943
|
+
client: this.client,
|
|
4944
|
+
address: this._address,
|
|
4945
|
+
fromCoinType: coinType,
|
|
4946
|
+
fromDecimals: decimals,
|
|
4947
|
+
toCoinType: usdcType,
|
|
4948
|
+
toDecimals: usdcDecimals,
|
|
4949
|
+
amount: rawBalance
|
|
4950
|
+
});
|
|
4951
|
+
const gasResult = await executeWithGas(this.client, this.keypair, async () => swapResult.tx);
|
|
4952
|
+
await this.client.waitForTransaction({ digest: gasResult.digest });
|
|
4953
|
+
totalUsdc += swapResult.estimatedOut / 10 ** usdcDecimals;
|
|
4954
|
+
} catch {
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
return totalUsdc;
|
|
4958
|
+
}
|
|
4908
4959
|
// -- Strategies --
|
|
4909
4960
|
async investStrategy(params) {
|
|
4910
4961
|
this.enforcer.assertNotLocked();
|