@t2000/sdk 0.17.29 → 0.18.0
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.d.cts +1 -1
- package/dist/adapters/index.d.ts +4 -10
- package/dist/adapters/index.js +2107 -15
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-DdtOBw42.d.ts → index-Co0lp99l.d.cts} +23 -1
- package/dist/{index-DdtOBw42.d.cts → index-Co0lp99l.d.ts} +23 -1
- package/dist/index.cjs +102 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +654 -30
- package/dist/index.js +6154 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/adapters/cetus.d.ts +0 -29
- package/dist/adapters/cetus.d.ts.map +0 -1
- package/dist/adapters/cetus.js +0 -74
- package/dist/adapters/cetus.js.map +0 -1
- package/dist/adapters/cetus.test.d.ts +0 -2
- package/dist/adapters/cetus.test.d.ts.map +0 -1
- package/dist/adapters/cetus.test.js +0 -57
- package/dist/adapters/cetus.test.js.map +0 -1
- package/dist/adapters/compliance.test.d.ts +0 -8
- package/dist/adapters/compliance.test.d.ts.map +0 -1
- package/dist/adapters/compliance.test.js +0 -202
- package/dist/adapters/compliance.test.js.map +0 -1
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/navi.d.ts +0 -41
- package/dist/adapters/navi.d.ts.map +0 -1
- package/dist/adapters/navi.js +0 -102
- package/dist/adapters/navi.js.map +0 -1
- package/dist/adapters/navi.test.d.ts +0 -2
- package/dist/adapters/navi.test.d.ts.map +0 -1
- package/dist/adapters/navi.test.js +0 -164
- package/dist/adapters/navi.test.js.map +0 -1
- package/dist/adapters/registry.d.ts +0 -47
- package/dist/adapters/registry.d.ts.map +0 -1
- package/dist/adapters/registry.js +0 -162
- package/dist/adapters/registry.js.map +0 -1
- package/dist/adapters/registry.test.d.ts +0 -2
- package/dist/adapters/registry.test.d.ts.map +0 -1
- package/dist/adapters/registry.test.js +0 -197
- package/dist/adapters/registry.test.js.map +0 -1
- package/dist/adapters/suilend.d.ts +0 -71
- package/dist/adapters/suilend.d.ts.map +0 -1
- package/dist/adapters/suilend.js +0 -826
- package/dist/adapters/suilend.js.map +0 -1
- package/dist/adapters/suilend.test.d.ts +0 -2
- package/dist/adapters/suilend.test.d.ts.map +0 -1
- package/dist/adapters/suilend.test.js +0 -294
- package/dist/adapters/suilend.test.js.map +0 -1
- package/dist/adapters/types.d.ts +0 -160
- package/dist/adapters/types.d.ts.map +0 -1
- package/dist/adapters/types.js +0 -2
- package/dist/adapters/types.js.map +0 -1
- package/dist/auto-invest.d.ts +0 -23
- package/dist/auto-invest.d.ts.map +0 -1
- package/dist/auto-invest.js +0 -131
- package/dist/auto-invest.js.map +0 -1
- package/dist/auto-invest.test.d.ts +0 -2
- package/dist/auto-invest.test.d.ts.map +0 -1
- package/dist/auto-invest.test.js +0 -220
- package/dist/auto-invest.test.js.map +0 -1
- package/dist/constants.d.ts +0 -177
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -135
- package/dist/constants.js.map +0 -1
- package/dist/contacts.d.ts +0 -25
- package/dist/contacts.d.ts.map +0 -1
- package/dist/contacts.js +0 -83
- package/dist/contacts.js.map +0 -1
- package/dist/contacts.test.d.ts +0 -2
- package/dist/contacts.test.d.ts.map +0 -1
- package/dist/contacts.test.js +0 -164
- package/dist/contacts.test.js.map +0 -1
- package/dist/errors.d.ts +0 -26
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -81
- package/dist/errors.js.map +0 -1
- package/dist/errors.test.d.ts +0 -2
- package/dist/errors.test.d.ts.map +0 -1
- package/dist/errors.test.js +0 -48
- package/dist/errors.test.js.map +0 -1
- package/dist/gas/autoTopUp.d.ts +0 -18
- package/dist/gas/autoTopUp.d.ts.map +0 -1
- package/dist/gas/autoTopUp.js +0 -55
- package/dist/gas/autoTopUp.js.map +0 -1
- package/dist/gas/autoTopUp.test.d.ts +0 -2
- package/dist/gas/autoTopUp.test.d.ts.map +0 -1
- package/dist/gas/autoTopUp.test.js +0 -59
- package/dist/gas/autoTopUp.test.js.map +0 -1
- package/dist/gas/gasStation.d.ts +0 -23
- package/dist/gas/gasStation.d.ts.map +0 -1
- package/dist/gas/gasStation.js +0 -58
- package/dist/gas/gasStation.js.map +0 -1
- package/dist/gas/index.d.ts +0 -4
- package/dist/gas/index.d.ts.map +0 -1
- package/dist/gas/index.js +0 -4
- package/dist/gas/index.js.map +0 -1
- package/dist/gas/manager.d.ts +0 -24
- package/dist/gas/manager.d.ts.map +0 -1
- package/dist/gas/manager.js +0 -142
- package/dist/gas/manager.js.map +0 -1
- package/dist/gas/manager.test.d.ts +0 -2
- package/dist/gas/manager.test.d.ts.map +0 -1
- package/dist/gas/manager.test.js +0 -220
- package/dist/gas/manager.test.js.map +0 -1
- package/dist/gas/serialization.test.d.ts +0 -2
- package/dist/gas/serialization.test.d.ts.map +0 -1
- package/dist/gas/serialization.test.js +0 -47
- package/dist/gas/serialization.test.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/invest.test.d.ts +0 -2
- package/dist/invest.test.d.ts.map +0 -1
- package/dist/invest.test.js +0 -256
- package/dist/invest.test.js.map +0 -1
- package/dist/portfolio.d.ts +0 -39
- package/dist/portfolio.d.ts.map +0 -1
- package/dist/portfolio.js +0 -201
- package/dist/portfolio.js.map +0 -1
- package/dist/portfolio.test.d.ts +0 -2
- package/dist/portfolio.test.d.ts.map +0 -1
- package/dist/portfolio.test.js +0 -301
- package/dist/portfolio.test.js.map +0 -1
- package/dist/protocols/cetus.d.ts +0 -73
- package/dist/protocols/cetus.d.ts.map +0 -1
- package/dist/protocols/cetus.js +0 -267
- package/dist/protocols/cetus.js.map +0 -1
- package/dist/protocols/cetus.test.d.ts +0 -2
- package/dist/protocols/cetus.test.d.ts.map +0 -1
- package/dist/protocols/cetus.test.js +0 -325
- package/dist/protocols/cetus.test.js.map +0 -1
- package/dist/protocols/navi.d.ts +0 -59
- package/dist/protocols/navi.d.ts.map +0 -1
- package/dist/protocols/navi.js +0 -945
- package/dist/protocols/navi.js.map +0 -1
- package/dist/protocols/navi.test.d.ts +0 -2
- package/dist/protocols/navi.test.d.ts.map +0 -1
- package/dist/protocols/navi.test.js +0 -339
- package/dist/protocols/navi.test.js.map +0 -1
- package/dist/protocols/protocolFee.d.ts +0 -17
- package/dist/protocols/protocolFee.d.ts.map +0 -1
- package/dist/protocols/protocolFee.js +0 -62
- package/dist/protocols/protocolFee.js.map +0 -1
- package/dist/protocols/protocolFee.test.d.ts +0 -2
- package/dist/protocols/protocolFee.test.d.ts.map +0 -1
- package/dist/protocols/protocolFee.test.js +0 -137
- package/dist/protocols/protocolFee.test.js.map +0 -1
- package/dist/protocols/sentinel.d.ts +0 -18
- package/dist/protocols/sentinel.d.ts.map +0 -1
- package/dist/protocols/sentinel.js +0 -188
- package/dist/protocols/sentinel.js.map +0 -1
- package/dist/protocols/sentinel.test.d.ts +0 -2
- package/dist/protocols/sentinel.test.d.ts.map +0 -1
- package/dist/protocols/sentinel.test.js +0 -199
- package/dist/protocols/sentinel.test.js.map +0 -1
- package/dist/protocols/yieldTracker.d.ts +0 -6
- package/dist/protocols/yieldTracker.d.ts.map +0 -1
- package/dist/protocols/yieldTracker.js +0 -29
- package/dist/protocols/yieldTracker.js.map +0 -1
- package/dist/safeguards/enforcer.d.ts +0 -18
- package/dist/safeguards/enforcer.d.ts.map +0 -1
- package/dist/safeguards/enforcer.js +0 -130
- package/dist/safeguards/enforcer.js.map +0 -1
- package/dist/safeguards/enforcer.test.d.ts +0 -2
- package/dist/safeguards/enforcer.test.d.ts.map +0 -1
- package/dist/safeguards/enforcer.test.js +0 -212
- package/dist/safeguards/enforcer.test.js.map +0 -1
- package/dist/safeguards/errors.d.ts +0 -24
- package/dist/safeguards/errors.d.ts.map +0 -1
- package/dist/safeguards/errors.js +0 -31
- package/dist/safeguards/errors.js.map +0 -1
- package/dist/safeguards/index.d.ts +0 -6
- package/dist/safeguards/index.d.ts.map +0 -1
- package/dist/safeguards/index.js +0 -4
- package/dist/safeguards/index.js.map +0 -1
- package/dist/safeguards/types.d.ts +0 -16
- package/dist/safeguards/types.d.ts.map +0 -1
- package/dist/safeguards/types.js +0 -13
- package/dist/safeguards/types.js.map +0 -1
- package/dist/strategy.d.ts +0 -22
- package/dist/strategy.d.ts.map +0 -1
- package/dist/strategy.js +0 -113
- package/dist/strategy.js.map +0 -1
- package/dist/strategy.test.d.ts +0 -2
- package/dist/strategy.test.d.ts.map +0 -1
- package/dist/strategy.test.js +0 -212
- package/dist/strategy.test.js.map +0 -1
- package/dist/t2000.d.ts +0 -219
- package/dist/t2000.d.ts.map +0 -1
- package/dist/t2000.integration.test.d.ts +0 -2
- package/dist/t2000.integration.test.d.ts.map +0 -1
- package/dist/t2000.integration.test.js +0 -954
- package/dist/t2000.integration.test.js.map +0 -1
- package/dist/t2000.js +0 -2416
- package/dist/t2000.js.map +0 -1
- package/dist/types.d.ts +0 -419
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/format.d.ts +0 -22
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js +0 -71
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/format.test.d.ts +0 -2
- package/dist/utils/format.test.d.ts.map +0 -1
- package/dist/utils/format.test.js +0 -187
- package/dist/utils/format.test.js.map +0 -1
- package/dist/utils/hashcash.d.ts +0 -2
- package/dist/utils/hashcash.d.ts.map +0 -1
- package/dist/utils/hashcash.js +0 -27
- package/dist/utils/hashcash.js.map +0 -1
- package/dist/utils/hashcash.test.d.ts +0 -2
- package/dist/utils/hashcash.test.d.ts.map +0 -1
- package/dist/utils/hashcash.test.js +0 -40
- package/dist/utils/hashcash.test.js.map +0 -1
- package/dist/utils/retry.d.ts +0 -9
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/retry.js +0 -47
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/simulate.d.ts +0 -15
- package/dist/utils/simulate.d.ts.map +0 -1
- package/dist/utils/simulate.js +0 -75
- package/dist/utils/simulate.js.map +0 -1
- package/dist/utils/simulate.test.d.ts +0 -2
- package/dist/utils/simulate.test.d.ts.map +0 -1
- package/dist/utils/simulate.test.js +0 -80
- package/dist/utils/simulate.test.js.map +0 -1
- package/dist/utils/sui.d.ts +0 -6
- package/dist/utils/sui.d.ts.map +0 -1
- package/dist/utils/sui.js +0 -28
- package/dist/utils/sui.js.map +0 -1
- package/dist/utils/sui.test.d.ts +0 -2
- package/dist/utils/sui.test.d.ts.map +0 -1
- package/dist/utils/sui.test.js +0 -58
- package/dist/utils/sui.test.js.map +0 -1
- package/dist/wallet/balance.d.ts +0 -4
- package/dist/wallet/balance.d.ts.map +0 -1
- package/dist/wallet/balance.js +0 -98
- package/dist/wallet/balance.js.map +0 -1
- package/dist/wallet/history.d.ts +0 -4
- package/dist/wallet/history.d.ts.map +0 -1
- package/dist/wallet/history.js +0 -38
- package/dist/wallet/history.js.map +0 -1
- package/dist/wallet/keyManager.d.ts +0 -9
- package/dist/wallet/keyManager.d.ts.map +0 -1
- package/dist/wallet/keyManager.js +0 -113
- package/dist/wallet/keyManager.js.map +0 -1
- package/dist/wallet/keyManager.test.d.ts +0 -2
- package/dist/wallet/keyManager.test.d.ts.map +0 -1
- package/dist/wallet/keyManager.test.js +0 -55
- package/dist/wallet/keyManager.test.js.map +0 -1
- package/dist/wallet/send.d.ts +0 -24
- package/dist/wallet/send.d.ts.map +0 -1
- package/dist/wallet/send.js +0 -95
- package/dist/wallet/send.js.map +0 -1
- package/dist/wallet/send.test.d.ts +0 -2
- package/dist/wallet/send.test.d.ts.map +0 -1
- package/dist/wallet/send.test.js +0 -69
- package/dist/wallet/send.test.js.map +0 -1
|
@@ -260,6 +260,28 @@ interface InvestEarnResult {
|
|
|
260
260
|
gasCost: number;
|
|
261
261
|
gasMethod: GasMethod;
|
|
262
262
|
}
|
|
263
|
+
interface InvestRebalanceMove {
|
|
264
|
+
asset: string;
|
|
265
|
+
fromProtocol: string;
|
|
266
|
+
toProtocol: string;
|
|
267
|
+
amount: number;
|
|
268
|
+
oldApy: number;
|
|
269
|
+
newApy: number;
|
|
270
|
+
txDigests: string[];
|
|
271
|
+
gasCost: number;
|
|
272
|
+
}
|
|
273
|
+
interface InvestRebalanceResult {
|
|
274
|
+
executed: boolean;
|
|
275
|
+
moves: InvestRebalanceMove[];
|
|
276
|
+
totalGasCost: number;
|
|
277
|
+
skipped: Array<{
|
|
278
|
+
asset: string;
|
|
279
|
+
protocol: string;
|
|
280
|
+
apy: number;
|
|
281
|
+
bestApy: number;
|
|
282
|
+
reason: string;
|
|
283
|
+
}>;
|
|
284
|
+
}
|
|
263
285
|
interface StrategyDefinition {
|
|
264
286
|
name: string;
|
|
265
287
|
allocations: Record<string, number>;
|
|
@@ -751,4 +773,4 @@ declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentin
|
|
|
751
773
|
/** All registered protocol descriptors — used by the indexer for event classification */
|
|
752
774
|
declare const allDescriptors: ProtocolDescriptor[];
|
|
753
775
|
|
|
754
|
-
export { type
|
|
776
|
+
export { type ProtocolDescriptor as $, type AutoInvestSchedule as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, type InvestmentTrade as I, type AdapterTxResult as J, type AssetRates as K, type LendingAdapter as L, type MaxWithdrawResult as M, CetusAdapter as N, type GasReserve as O, type PendingReward$1 as P, type HealthInfo as Q, type RepayResult as R, type StrategyDefinition as S, type T2000Options as T, type InvestRebalanceMove as U, NaviAdapter as V, type WithdrawResult as W, type PerpsAdapter as X, type PerpsPosition as Y, type PositionEntry as Z, type PositionSide as _, type AutoInvestStatus as a, ProtocolRegistry as a0, type RebalanceStep as a1, type SentinelVerdict as a2, SuilendAdapter as a3, type SwapQuote as a4, type TradePositionsResult as a5, type TradeResult as a6, allDescriptors as a7, descriptor$2 as a8, getSentinelInfo as a9, listSentinels as aa, descriptor$3 as ab, requestAttack as ac, attack as ad, descriptor as ae, settleAttack as af, submitPrompt as ag, descriptor$1 as ah, type SendResult as b, type TransactionRecord as c, type SwapAdapter as d, type SaveResult as e, type BorrowResult as f, type MaxBorrowResult as g, type SwapResult as h, type InvestResult as i, type InvestEarnResult as j, type InvestRebalanceResult as k, type StrategyBuyResult as l, type StrategySellResult as m, type StrategyRebalanceResult as n, type StrategyStatusResult as o, type AutoInvestRunResult as p, type PortfolioResult as q, type InvestmentPosition as r, type PositionsResult as s, type RatesResult as t, type LendingRates as u, type RebalanceResult as v, type SentinelAgent as w, type SentinelAttackResult as x, type AdapterCapability as y, type AdapterPositions as z };
|
package/dist/index.cjs
CHANGED
|
@@ -4834,7 +4834,16 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
4834
4834
|
if (depositAmount <= 0) {
|
|
4835
4835
|
throw new T2000Error("INSUFFICIENT_BALANCE", `No ${params.asset} available to deposit (wallet: ${walletAmount}, gas reserve: ${gasReserve})`);
|
|
4836
4836
|
}
|
|
4837
|
-
|
|
4837
|
+
let adapter;
|
|
4838
|
+
let rate;
|
|
4839
|
+
if (params.protocol) {
|
|
4840
|
+
const specific = this.registry.getLending(params.protocol);
|
|
4841
|
+
if (!specific) throw new T2000Error("PROTOCOL_UNAVAILABLE", `Protocol ${params.protocol} not found`);
|
|
4842
|
+
adapter = specific;
|
|
4843
|
+
rate = await specific.getRates(params.asset);
|
|
4844
|
+
} else {
|
|
4845
|
+
({ adapter, rate } = await this.registry.bestSaveRate(params.asset));
|
|
4846
|
+
}
|
|
4838
4847
|
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
4839
4848
|
const { tx } = await adapter.buildSaveTx(this._address, depositAmount, params.asset);
|
|
4840
4849
|
return tx;
|
|
@@ -4884,6 +4893,98 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
4884
4893
|
gasMethod: gasResult.gasMethod
|
|
4885
4894
|
};
|
|
4886
4895
|
}
|
|
4896
|
+
// -- Invest Rebalance --
|
|
4897
|
+
async investRebalance(opts = {}) {
|
|
4898
|
+
this.enforcer.assertNotLocked();
|
|
4899
|
+
const minDiff = opts.minYieldDiff ?? 0.1;
|
|
4900
|
+
const positions = this.portfolio.getPositions().filter((p) => p.earning && p.earningProtocol);
|
|
4901
|
+
if (positions.length === 0) {
|
|
4902
|
+
return { executed: false, moves: [], totalGasCost: 0, skipped: [] };
|
|
4903
|
+
}
|
|
4904
|
+
const moves = [];
|
|
4905
|
+
const skipped = [];
|
|
4906
|
+
let totalGasCost = 0;
|
|
4907
|
+
for (const pos of positions) {
|
|
4908
|
+
const currentProtocol = pos.earningProtocol;
|
|
4909
|
+
let best;
|
|
4910
|
+
try {
|
|
4911
|
+
best = await this.registry.bestSaveRate(pos.asset);
|
|
4912
|
+
} catch {
|
|
4913
|
+
const currentApy2 = pos.earningApy ?? 0;
|
|
4914
|
+
skipped.push({ asset: pos.asset, protocol: currentProtocol, apy: currentApy2, bestApy: currentApy2, reason: "no_rates" });
|
|
4915
|
+
continue;
|
|
4916
|
+
}
|
|
4917
|
+
let currentApy = pos.earningApy ?? 0;
|
|
4918
|
+
try {
|
|
4919
|
+
const currentAdapter = this.registry.getLending(currentProtocol);
|
|
4920
|
+
if (currentAdapter) {
|
|
4921
|
+
const liveRate = await currentAdapter.getRates(pos.asset);
|
|
4922
|
+
currentApy = liveRate.saveApy;
|
|
4923
|
+
}
|
|
4924
|
+
} catch {
|
|
4925
|
+
}
|
|
4926
|
+
const apyGain = best.rate.saveApy - currentApy;
|
|
4927
|
+
if (best.adapter.id === currentProtocol || apyGain <= 0) {
|
|
4928
|
+
skipped.push({ asset: pos.asset, protocol: currentProtocol, apy: currentApy, bestApy: best.rate.saveApy, reason: "already_best" });
|
|
4929
|
+
continue;
|
|
4930
|
+
}
|
|
4931
|
+
if (apyGain < minDiff) {
|
|
4932
|
+
skipped.push({ asset: pos.asset, protocol: currentProtocol, apy: currentApy, bestApy: best.rate.saveApy, reason: "below_threshold" });
|
|
4933
|
+
continue;
|
|
4934
|
+
}
|
|
4935
|
+
if (opts.dryRun) {
|
|
4936
|
+
moves.push({
|
|
4937
|
+
asset: pos.asset,
|
|
4938
|
+
fromProtocol: this.registry.getLending(currentProtocol)?.name ?? currentProtocol,
|
|
4939
|
+
toProtocol: best.adapter.name,
|
|
4940
|
+
amount: pos.totalAmount,
|
|
4941
|
+
oldApy: currentApy,
|
|
4942
|
+
newApy: best.rate.saveApy,
|
|
4943
|
+
txDigests: [],
|
|
4944
|
+
gasCost: 0
|
|
4945
|
+
});
|
|
4946
|
+
continue;
|
|
4947
|
+
}
|
|
4948
|
+
const txDigests = [];
|
|
4949
|
+
let moveGasCost = 0;
|
|
4950
|
+
const fromAdapter = this.registry.getLending(currentProtocol);
|
|
4951
|
+
if (!fromAdapter) {
|
|
4952
|
+
skipped.push({ asset: pos.asset, protocol: currentProtocol, apy: currentApy, bestApy: best.rate.saveApy, reason: "protocol_unavailable" });
|
|
4953
|
+
continue;
|
|
4954
|
+
}
|
|
4955
|
+
const withdrawResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
4956
|
+
const result = await fromAdapter.buildWithdrawTx(this._address, pos.totalAmount, pos.asset);
|
|
4957
|
+
return result.tx;
|
|
4958
|
+
});
|
|
4959
|
+
txDigests.push(withdrawResult.digest);
|
|
4960
|
+
moveGasCost += withdrawResult.gasCostSui;
|
|
4961
|
+
const depositResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
4962
|
+
const assetInfo = SUPPORTED_ASSETS[pos.asset];
|
|
4963
|
+
const balance = await this.client.getBalance({ owner: this._address, coinType: assetInfo.type });
|
|
4964
|
+
const available = Number(balance.totalBalance) / 10 ** assetInfo.decimals;
|
|
4965
|
+
const gasReserve = pos.asset === "SUI" ? GAS_RESERVE_MIN : 0;
|
|
4966
|
+
const depositAmount = Math.max(0, available - gasReserve);
|
|
4967
|
+
const { tx } = await best.adapter.buildSaveTx(this._address, depositAmount, pos.asset);
|
|
4968
|
+
return tx;
|
|
4969
|
+
});
|
|
4970
|
+
txDigests.push(depositResult.digest);
|
|
4971
|
+
moveGasCost += depositResult.gasCostSui;
|
|
4972
|
+
this.portfolio.recordUnearn(pos.asset);
|
|
4973
|
+
this.portfolio.recordEarn(pos.asset, best.adapter.id, best.rate.saveApy);
|
|
4974
|
+
moves.push({
|
|
4975
|
+
asset: pos.asset,
|
|
4976
|
+
fromProtocol: fromAdapter.name,
|
|
4977
|
+
toProtocol: best.adapter.name,
|
|
4978
|
+
amount: pos.totalAmount,
|
|
4979
|
+
oldApy: currentApy,
|
|
4980
|
+
newApy: best.rate.saveApy,
|
|
4981
|
+
txDigests,
|
|
4982
|
+
gasCost: moveGasCost
|
|
4983
|
+
});
|
|
4984
|
+
totalGasCost += moveGasCost;
|
|
4985
|
+
}
|
|
4986
|
+
return { executed: !opts.dryRun && moves.length > 0, moves, totalGasCost, skipped };
|
|
4987
|
+
}
|
|
4887
4988
|
// -- Claim Rewards --
|
|
4888
4989
|
async getPendingRewards() {
|
|
4889
4990
|
const adapters = this.registry.listLending();
|