@t2000/sdk 0.28.9 → 0.31.1
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/descriptors.d.cts +1 -1
- package/dist/adapters/descriptors.d.ts +1 -1
- package/dist/adapters/index.d.cts +3 -3
- package/dist/adapters/index.d.ts +3 -3
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/{descriptors-Be4FAgN5.d.cts → descriptors-DkKhitk_.d.cts} +1 -1
- package/dist/{descriptors-Be4FAgN5.d.ts → descriptors-DkKhitk_.d.ts} +1 -1
- package/dist/index.cjs +128 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -7
- package/dist/index.d.ts +16 -7
- package/dist/index.js +129 -2
- package/dist/index.js.map +1 -1
- package/dist/{token-registry-CX_RDDO_.d.ts → token-registry-BDUX2-5v.d.ts} +1 -1
- package/dist/{token-registry-BYEXDwjs.d.cts → token-registry-Dh-awSh7.d.cts} +1 -1
- package/dist/{types-D9NstGUu.d.cts → types-Clhh7dHT.d.cts} +10 -1
- package/dist/{types-D9NstGUu.d.ts → types-Clhh7dHT.d.ts} +10 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { T as T2000Error, am as SafeguardEnforcer, w as TransactionSigner, Z as ZkLoginProof, s as SupportedAsset, an as AllowanceFeature } from './token-registry-
|
|
5
|
-
export { ao as ALLOWANCE_FEATURES, A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, ap as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as CoinMeta, D as DEFAULT_NETWORK, d as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, F as FeeOperation, G as GAS_RESERVE_MIN, e as GasExecutionResult, f as GasRequestType, g as GasSponsorResponse, h as GasStatusResponse, I as IKA_TYPE, K as KeypairSigner, L as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aq as OPERATION_ASSETS, O as OUTBOUND_OPS, ar as Operation, P as ProtocolFeeInfo, S as STABLE_ASSETS, j as SUI_DECIMALS, k as SUI_TYPE, l as SUPPORTED_ASSETS, m as SafeguardConfig, n as SafeguardError, o as SafeguardErrorDetails, p as SafeguardRule, q as SimulationResult, r as StableAsset, t as T2000ErrorCode, u as T2000ErrorData, v as TOKEN_MAP, x as TxMetadata, U as USDC_DECIMALS, y as USDC_TYPE, z as USDE_TYPE, H as USDSUI_TYPE, J as USDT_TYPE, W as WAL_TYPE, Q as WBTC_TYPE, R as ZkLoginSigner, V as addCollectFeeToTx, as as assertAllowedAsset, X as calculateFee, Y as executeAutoTopUp, _ as executeWithGas, $ as formatAssetAmount, a0 as formatSui, a1 as formatUsd, a2 as getDecimals, a3 as getDecimalsForCoinType, a4 as getGasStatus, a5 as getTier, at as isAllowedAsset, a6 as isSupported, a7 as isTier1, a8 as isTier2, a9 as mapMoveAbortCode, aa as mapWalletError, ab as mistToSui, ac as rawToStable, ad as rawToUsdc, ae as resolveSymbol, af as resolveTokenType, ag as shouldAutoTopUp, au as simulateTransaction, ah as stableToRaw, ai as suiToMist, av as throwIfSimulationFailed, aj as truncateAddress, ak as usdcToRaw, al as validateAddress } from './token-registry-
|
|
6
|
-
import { L as LendingAdapter, a as LendingRates } from './descriptors-
|
|
7
|
-
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo,
|
|
8
|
-
import { j as T2000Options, P as PayOptions, d as PayResult, k as StakeVSuiResult, U as UnstakeVSuiResult, l as SwapResult, m as SwapQuoteResult, i as SendResult, B as BalanceResponse, T as TransactionRecord, D as DepositInfo, n as PaymentRequest, S as SaveResult, W as WithdrawResult, c as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult,
|
|
9
|
-
export {
|
|
4
|
+
import { T as T2000Error, am as SafeguardEnforcer, w as TransactionSigner, Z as ZkLoginProof, s as SupportedAsset, an as AllowanceFeature } from './token-registry-Dh-awSh7.cjs';
|
|
5
|
+
export { ao as ALLOWANCE_FEATURES, A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, ap as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as CoinMeta, D as DEFAULT_NETWORK, d as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, F as FeeOperation, G as GAS_RESERVE_MIN, e as GasExecutionResult, f as GasRequestType, g as GasSponsorResponse, h as GasStatusResponse, I as IKA_TYPE, K as KeypairSigner, L as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aq as OPERATION_ASSETS, O as OUTBOUND_OPS, ar as Operation, P as ProtocolFeeInfo, S as STABLE_ASSETS, j as SUI_DECIMALS, k as SUI_TYPE, l as SUPPORTED_ASSETS, m as SafeguardConfig, n as SafeguardError, o as SafeguardErrorDetails, p as SafeguardRule, q as SimulationResult, r as StableAsset, t as T2000ErrorCode, u as T2000ErrorData, v as TOKEN_MAP, x as TxMetadata, U as USDC_DECIMALS, y as USDC_TYPE, z as USDE_TYPE, H as USDSUI_TYPE, J as USDT_TYPE, W as WAL_TYPE, Q as WBTC_TYPE, R as ZkLoginSigner, V as addCollectFeeToTx, as as assertAllowedAsset, X as calculateFee, Y as executeAutoTopUp, _ as executeWithGas, $ as formatAssetAmount, a0 as formatSui, a1 as formatUsd, a2 as getDecimals, a3 as getDecimalsForCoinType, a4 as getGasStatus, a5 as getTier, at as isAllowedAsset, a6 as isSupported, a7 as isTier1, a8 as isTier2, a9 as mapMoveAbortCode, aa as mapWalletError, ab as mistToSui, ac as rawToStable, ad as rawToUsdc, ae as resolveSymbol, af as resolveTokenType, ag as shouldAutoTopUp, au as simulateTransaction, ah as stableToRaw, ai as suiToMist, av as throwIfSimulationFailed, aj as truncateAddress, ak as usdcToRaw, al as validateAddress } from './token-registry-Dh-awSh7.cjs';
|
|
6
|
+
import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-DkKhitk_.cjs';
|
|
7
|
+
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from './descriptors-DkKhitk_.cjs';
|
|
8
|
+
import { j as T2000Options, P as PayOptions, d as PayResult, k as StakeVSuiResult, U as UnstakeVSuiResult, l as SwapResult, m as SwapQuoteResult, i as SendResult, B as BalanceResponse, T as TransactionRecord, D as DepositInfo, n as PaymentRequest, S as SaveResult, W as WithdrawResult, c as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, o as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, p as AllowanceInfo, q as FinancialSummary } from './types-Clhh7dHT.cjs';
|
|
9
|
+
export { r as AllowanceCreateResult, s as AllowanceDeductResult, t as AllowanceDepositResult, u as AllowanceWithdrawResult, A as AssetRates, G as GasMethod, b as GasReserve, v as HFAlertLevel, f as PositionEntry } from './types-Clhh7dHT.cjs';
|
|
10
10
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
11
11
|
import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
12
12
|
export { NaviAdapter, ProtocolRegistry } from './adapters/index.cjs';
|
|
@@ -180,6 +180,14 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
180
180
|
healthFactor(): Promise<HealthFactorResult>;
|
|
181
181
|
getPendingRewards(): Promise<PendingReward[]>;
|
|
182
182
|
claimRewards(): Promise<ClaimRewardsResult>;
|
|
183
|
+
/**
|
|
184
|
+
* Claim pending rewards, swap non-USDC tokens to USDC via Cetus, and deposit into NAVI.
|
|
185
|
+
* Multi-step: claim (transfers to wallet) -> swap each reward token to USDC -> deposit USDC.
|
|
186
|
+
* Minimum threshold: skips if total rewards < $0.10 (gas not worth it).
|
|
187
|
+
*/
|
|
188
|
+
compoundRewards(options?: {
|
|
189
|
+
minValueUsd?: number;
|
|
190
|
+
}): Promise<CompoundRewardsResult>;
|
|
183
191
|
positions(): Promise<PositionsResult>;
|
|
184
192
|
rates(): Promise<RatesResult>;
|
|
185
193
|
allRates(asset?: string): Promise<{
|
|
@@ -271,6 +279,7 @@ interface FinancialSummaryOptions {
|
|
|
271
279
|
declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: string, options?: FinancialSummaryOptions): Promise<FinancialSummary>;
|
|
272
280
|
|
|
273
281
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
282
|
+
declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
274
283
|
|
|
275
284
|
declare function getSwapQuote(params: {
|
|
276
285
|
walletAddress: string;
|
|
@@ -386,4 +395,4 @@ declare function buildScopedIntent(adminKeypair: Ed25519Keypair, params: BuildIn
|
|
|
386
395
|
*/
|
|
387
396
|
declare function verifyScopedIntent(intent: ScopedIntent, adminPublicKeyBytes: Uint8Array): Promise<boolean>;
|
|
388
397
|
|
|
389
|
-
export { AllowanceFeature, AllowanceInfo, BalanceResponse, BorrowResult, type BuildIntentParams, ClaimRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, RepayResult, SafeguardEnforcer, SaveResult, type ScopedIntent, type ScopedIntentPayload, SendResult, StakeVSuiResult, SupportedAsset, SwapQuoteResult, SwapResult, type SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStats, WithdrawResult, ZkLoginProof, addDepositAllowanceTx, buildAdminDepositAllowanceTx, buildCreateAllowanceTx, buildDeductAllowanceTx, buildDepositAllowanceTx, buildScopedIntent, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, buildWithdrawAllowanceTx, buildWithdrawAmountAllowanceTx, exportPrivateKey, findSwapRoute, generateKeypair, getAddress, getAllowance, getAllowanceBalance, getFinancialSummary, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, solveHashcash, verifyScopedIntent, walletExists };
|
|
398
|
+
export { AllowanceFeature, AllowanceInfo, BalanceResponse, BorrowResult, type BuildIntentParams, ClaimRewardsResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, RepayResult, SafeguardEnforcer, SaveResult, type ScopedIntent, type ScopedIntentPayload, SendResult, StakeVSuiResult, SupportedAsset, SwapQuoteResult, SwapResult, type SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStats, WithdrawResult, ZkLoginProof, addDepositAllowanceTx, buildAdminDepositAllowanceTx, buildCreateAllowanceTx, buildDeductAllowanceTx, buildDepositAllowanceTx, buildScopedIntent, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, buildWithdrawAllowanceTx, buildWithdrawAmountAllowanceTx, exportPrivateKey, findSwapRoute, generateKeypair, getAddress, getAllowance, getAllowanceBalance, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, solveHashcash, verifyScopedIntent, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { T as T2000Error, am as SafeguardEnforcer, w as TransactionSigner, Z as ZkLoginProof, s as SupportedAsset, an as AllowanceFeature } from './token-registry-
|
|
5
|
-
export { ao as ALLOWANCE_FEATURES, A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, ap as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as CoinMeta, D as DEFAULT_NETWORK, d as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, F as FeeOperation, G as GAS_RESERVE_MIN, e as GasExecutionResult, f as GasRequestType, g as GasSponsorResponse, h as GasStatusResponse, I as IKA_TYPE, K as KeypairSigner, L as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aq as OPERATION_ASSETS, O as OUTBOUND_OPS, ar as Operation, P as ProtocolFeeInfo, S as STABLE_ASSETS, j as SUI_DECIMALS, k as SUI_TYPE, l as SUPPORTED_ASSETS, m as SafeguardConfig, n as SafeguardError, o as SafeguardErrorDetails, p as SafeguardRule, q as SimulationResult, r as StableAsset, t as T2000ErrorCode, u as T2000ErrorData, v as TOKEN_MAP, x as TxMetadata, U as USDC_DECIMALS, y as USDC_TYPE, z as USDE_TYPE, H as USDSUI_TYPE, J as USDT_TYPE, W as WAL_TYPE, Q as WBTC_TYPE, R as ZkLoginSigner, V as addCollectFeeToTx, as as assertAllowedAsset, X as calculateFee, Y as executeAutoTopUp, _ as executeWithGas, $ as formatAssetAmount, a0 as formatSui, a1 as formatUsd, a2 as getDecimals, a3 as getDecimalsForCoinType, a4 as getGasStatus, a5 as getTier, at as isAllowedAsset, a6 as isSupported, a7 as isTier1, a8 as isTier2, a9 as mapMoveAbortCode, aa as mapWalletError, ab as mistToSui, ac as rawToStable, ad as rawToUsdc, ae as resolveSymbol, af as resolveTokenType, ag as shouldAutoTopUp, au as simulateTransaction, ah as stableToRaw, ai as suiToMist, av as throwIfSimulationFailed, aj as truncateAddress, ak as usdcToRaw, al as validateAddress } from './token-registry-
|
|
6
|
-
import { L as LendingAdapter, a as LendingRates } from './descriptors-
|
|
7
|
-
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo,
|
|
8
|
-
import { j as T2000Options, P as PayOptions, d as PayResult, k as StakeVSuiResult, U as UnstakeVSuiResult, l as SwapResult, m as SwapQuoteResult, i as SendResult, B as BalanceResponse, T as TransactionRecord, D as DepositInfo, n as PaymentRequest, S as SaveResult, W as WithdrawResult, c as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult,
|
|
9
|
-
export {
|
|
4
|
+
import { T as T2000Error, am as SafeguardEnforcer, w as TransactionSigner, Z as ZkLoginProof, s as SupportedAsset, an as AllowanceFeature } from './token-registry-BDUX2-5v.js';
|
|
5
|
+
export { ao as ALLOWANCE_FEATURES, A as ALL_NAVI_ASSETS, a as AutoTopUpResult, B as BPS_DENOMINATOR, ap as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as CoinMeta, D as DEFAULT_NETWORK, d as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, F as FeeOperation, G as GAS_RESERVE_MIN, e as GasExecutionResult, f as GasRequestType, g as GasSponsorResponse, h as GasStatusResponse, I as IKA_TYPE, K as KeypairSigner, L as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aq as OPERATION_ASSETS, O as OUTBOUND_OPS, ar as Operation, P as ProtocolFeeInfo, S as STABLE_ASSETS, j as SUI_DECIMALS, k as SUI_TYPE, l as SUPPORTED_ASSETS, m as SafeguardConfig, n as SafeguardError, o as SafeguardErrorDetails, p as SafeguardRule, q as SimulationResult, r as StableAsset, t as T2000ErrorCode, u as T2000ErrorData, v as TOKEN_MAP, x as TxMetadata, U as USDC_DECIMALS, y as USDC_TYPE, z as USDE_TYPE, H as USDSUI_TYPE, J as USDT_TYPE, W as WAL_TYPE, Q as WBTC_TYPE, R as ZkLoginSigner, V as addCollectFeeToTx, as as assertAllowedAsset, X as calculateFee, Y as executeAutoTopUp, _ as executeWithGas, $ as formatAssetAmount, a0 as formatSui, a1 as formatUsd, a2 as getDecimals, a3 as getDecimalsForCoinType, a4 as getGasStatus, a5 as getTier, at as isAllowedAsset, a6 as isSupported, a7 as isTier1, a8 as isTier2, a9 as mapMoveAbortCode, aa as mapWalletError, ab as mistToSui, ac as rawToStable, ad as rawToUsdc, ae as resolveSymbol, af as resolveTokenType, ag as shouldAutoTopUp, au as simulateTransaction, ah as stableToRaw, ai as suiToMist, av as throwIfSimulationFailed, aj as truncateAddress, ak as usdcToRaw, al as validateAddress } from './token-registry-BDUX2-5v.js';
|
|
6
|
+
import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-DkKhitk_.js';
|
|
7
|
+
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from './descriptors-DkKhitk_.js';
|
|
8
|
+
import { j as T2000Options, P as PayOptions, d as PayResult, k as StakeVSuiResult, U as UnstakeVSuiResult, l as SwapResult, m as SwapQuoteResult, i as SendResult, B as BalanceResponse, T as TransactionRecord, D as DepositInfo, n as PaymentRequest, S as SaveResult, W as WithdrawResult, c as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, o as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, p as AllowanceInfo, q as FinancialSummary } from './types-Clhh7dHT.js';
|
|
9
|
+
export { r as AllowanceCreateResult, s as AllowanceDeductResult, t as AllowanceDepositResult, u as AllowanceWithdrawResult, A as AssetRates, G as GasMethod, b as GasReserve, v as HFAlertLevel, f as PositionEntry } from './types-Clhh7dHT.js';
|
|
10
10
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
11
11
|
import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
12
12
|
export { NaviAdapter, ProtocolRegistry } from './adapters/index.js';
|
|
@@ -180,6 +180,14 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
180
180
|
healthFactor(): Promise<HealthFactorResult>;
|
|
181
181
|
getPendingRewards(): Promise<PendingReward[]>;
|
|
182
182
|
claimRewards(): Promise<ClaimRewardsResult>;
|
|
183
|
+
/**
|
|
184
|
+
* Claim pending rewards, swap non-USDC tokens to USDC via Cetus, and deposit into NAVI.
|
|
185
|
+
* Multi-step: claim (transfers to wallet) -> swap each reward token to USDC -> deposit USDC.
|
|
186
|
+
* Minimum threshold: skips if total rewards < $0.10 (gas not worth it).
|
|
187
|
+
*/
|
|
188
|
+
compoundRewards(options?: {
|
|
189
|
+
minValueUsd?: number;
|
|
190
|
+
}): Promise<CompoundRewardsResult>;
|
|
183
191
|
positions(): Promise<PositionsResult>;
|
|
184
192
|
rates(): Promise<RatesResult>;
|
|
185
193
|
allRates(asset?: string): Promise<{
|
|
@@ -271,6 +279,7 @@ interface FinancialSummaryOptions {
|
|
|
271
279
|
declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: string, options?: FinancialSummaryOptions): Promise<FinancialSummary>;
|
|
272
280
|
|
|
273
281
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
282
|
+
declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
274
283
|
|
|
275
284
|
declare function getSwapQuote(params: {
|
|
276
285
|
walletAddress: string;
|
|
@@ -386,4 +395,4 @@ declare function buildScopedIntent(adminKeypair: Ed25519Keypair, params: BuildIn
|
|
|
386
395
|
*/
|
|
387
396
|
declare function verifyScopedIntent(intent: ScopedIntent, adminPublicKeyBytes: Uint8Array): Promise<boolean>;
|
|
388
397
|
|
|
389
|
-
export { AllowanceFeature, AllowanceInfo, BalanceResponse, BorrowResult, type BuildIntentParams, ClaimRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, RepayResult, SafeguardEnforcer, SaveResult, type ScopedIntent, type ScopedIntentPayload, SendResult, StakeVSuiResult, SupportedAsset, SwapQuoteResult, SwapResult, type SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStats, WithdrawResult, ZkLoginProof, addDepositAllowanceTx, buildAdminDepositAllowanceTx, buildCreateAllowanceTx, buildDeductAllowanceTx, buildDepositAllowanceTx, buildScopedIntent, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, buildWithdrawAllowanceTx, buildWithdrawAmountAllowanceTx, exportPrivateKey, findSwapRoute, generateKeypair, getAddress, getAllowance, getAllowanceBalance, getFinancialSummary, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, solveHashcash, verifyScopedIntent, walletExists };
|
|
398
|
+
export { AllowanceFeature, AllowanceInfo, BalanceResponse, BorrowResult, type BuildIntentParams, ClaimRewardsResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, RepayResult, SafeguardEnforcer, SaveResult, type ScopedIntent, type ScopedIntentPayload, SendResult, StakeVSuiResult, SupportedAsset, SwapQuoteResult, SwapResult, type SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStats, WithdrawResult, ZkLoginProof, addDepositAllowanceTx, buildAdminDepositAllowanceTx, buildCreateAllowanceTx, buildDeductAllowanceTx, buildDepositAllowanceTx, buildScopedIntent, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, buildWithdrawAllowanceTx, buildWithdrawAmountAllowanceTx, exportPrivateKey, findSwapRoute, generateKeypair, getAddress, getAllowance, getAllowanceBalance, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, solveHashcash, verifyScopedIntent, walletExists };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createHash, randomBytes, createCipheriv, createDecipheriv, scryptSync }
|
|
|
9
9
|
import { access, mkdir, writeFile, readFile } from 'fs/promises';
|
|
10
10
|
import { join, dirname, resolve } from 'path';
|
|
11
11
|
import { homedir } from 'os';
|
|
12
|
-
import { getPools, getLendingPositions, getHealthFactor as getHealthFactor$1, depositCoinPTB, withdrawCoinPTB, borrowCoinPTB, repayCoinPTB,
|
|
12
|
+
import { getPools, getUserAvailableLendingRewards, summaryLendingRewards, getLendingPositions, getHealthFactor as getHealthFactor$1, depositCoinPTB, withdrawCoinPTB, borrowCoinPTB, repayCoinPTB, claimLendingRewardsPTB, updateOraclePriceBeforeUserOperationPTB } from '@naviprotocol/lending';
|
|
13
13
|
import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
14
14
|
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
@@ -3145,6 +3145,133 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
3145
3145
|
gasMethod: claimResult.gasMethod
|
|
3146
3146
|
};
|
|
3147
3147
|
}
|
|
3148
|
+
/**
|
|
3149
|
+
* Claim pending rewards, swap non-USDC tokens to USDC via Cetus, and deposit into NAVI.
|
|
3150
|
+
* Multi-step: claim (transfers to wallet) -> swap each reward token to USDC -> deposit USDC.
|
|
3151
|
+
* Minimum threshold: skips if total rewards < $0.10 (gas not worth it).
|
|
3152
|
+
*/
|
|
3153
|
+
async compoundRewards(options = {}) {
|
|
3154
|
+
this.enforcer.assertNotLocked();
|
|
3155
|
+
const minValue = options.minValueUsd ?? 0.1;
|
|
3156
|
+
const USDC_TYPE3 = SUPPORTED_ASSETS.USDC.type;
|
|
3157
|
+
const USDC_DEC = SUPPORTED_ASSETS.USDC.decimals;
|
|
3158
|
+
const pending = await this.getPendingRewards();
|
|
3159
|
+
const nonTrivial = pending.filter((r) => r.amount > 0);
|
|
3160
|
+
if (nonTrivial.length === 0) {
|
|
3161
|
+
return {
|
|
3162
|
+
success: true,
|
|
3163
|
+
claimTx: "",
|
|
3164
|
+
swapTxs: [],
|
|
3165
|
+
depositTx: "",
|
|
3166
|
+
rewards: pending,
|
|
3167
|
+
totalCompoundedUsdc: 0,
|
|
3168
|
+
totalGasCost: 0
|
|
3169
|
+
};
|
|
3170
|
+
}
|
|
3171
|
+
const totalPendingUsd = pending.reduce((s, r) => s + r.estimatedValueUsd, 0);
|
|
3172
|
+
if (totalPendingUsd > 0 && totalPendingUsd < minValue) {
|
|
3173
|
+
return {
|
|
3174
|
+
success: true,
|
|
3175
|
+
claimTx: "",
|
|
3176
|
+
swapTxs: [],
|
|
3177
|
+
depositTx: "",
|
|
3178
|
+
rewards: pending,
|
|
3179
|
+
totalCompoundedUsdc: 0,
|
|
3180
|
+
totalGasCost: 0
|
|
3181
|
+
};
|
|
3182
|
+
}
|
|
3183
|
+
const preUsdcCoins = await this._fetchCoins(USDC_TYPE3);
|
|
3184
|
+
const preUsdcRaw = preUsdcCoins.reduce((s, c) => s + BigInt(c.balance), 0n);
|
|
3185
|
+
const claimResult = await this.claimRewards();
|
|
3186
|
+
if (!claimResult.tx) {
|
|
3187
|
+
return {
|
|
3188
|
+
success: false,
|
|
3189
|
+
claimTx: "",
|
|
3190
|
+
swapTxs: [],
|
|
3191
|
+
depositTx: "",
|
|
3192
|
+
rewards: pending,
|
|
3193
|
+
totalCompoundedUsdc: 0,
|
|
3194
|
+
totalGasCost: 0
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3197
|
+
const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
3198
|
+
const swapTxs = [];
|
|
3199
|
+
let totalGasCost = claimResult.gasCost;
|
|
3200
|
+
for (const reward of nonTrivial) {
|
|
3201
|
+
if (!reward.coinType) continue;
|
|
3202
|
+
if (reward.coinType === USDC_TYPE3) continue;
|
|
3203
|
+
try {
|
|
3204
|
+
const decimals = getDecimalsForCoinType(reward.coinType) ?? 9;
|
|
3205
|
+
const rawAmount = BigInt(Math.floor(reward.amount * 10 ** decimals));
|
|
3206
|
+
if (rawAmount <= 0n) continue;
|
|
3207
|
+
const coins = await this._fetchCoins(reward.coinType);
|
|
3208
|
+
if (coins.length === 0) continue;
|
|
3209
|
+
const route = await findSwapRoute2({
|
|
3210
|
+
walletAddress: this._address,
|
|
3211
|
+
from: reward.coinType,
|
|
3212
|
+
to: USDC_TYPE3,
|
|
3213
|
+
amount: rawAmount,
|
|
3214
|
+
byAmountIn: true
|
|
3215
|
+
});
|
|
3216
|
+
if (!route || route.insufficientLiquidity) continue;
|
|
3217
|
+
const swapResult = await executeWithGas(this.client, this._signer, async () => {
|
|
3218
|
+
const tx = new Transaction();
|
|
3219
|
+
tx.setSender(this._address);
|
|
3220
|
+
const freshCoins = await this._fetchCoins(reward.coinType);
|
|
3221
|
+
if (freshCoins.length === 0) return tx;
|
|
3222
|
+
const merged = this._mergeCoinsInTx(tx, freshCoins);
|
|
3223
|
+
const [inputCoin] = tx.splitCoins(merged, [rawAmount]);
|
|
3224
|
+
const outputCoin = await buildSwapTx2({
|
|
3225
|
+
walletAddress: this._address,
|
|
3226
|
+
route,
|
|
3227
|
+
tx,
|
|
3228
|
+
inputCoin,
|
|
3229
|
+
slippage: 0.01
|
|
3230
|
+
});
|
|
3231
|
+
tx.transferObjects([outputCoin], this._address);
|
|
3232
|
+
return tx;
|
|
3233
|
+
});
|
|
3234
|
+
swapTxs.push(swapResult.digest);
|
|
3235
|
+
totalGasCost += swapResult.gasCostSui;
|
|
3236
|
+
} catch (err) {
|
|
3237
|
+
console.warn(`[compound] Failed to swap ${reward.symbol}:`, err instanceof Error ? err.message : err);
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
const postUsdcCoins = await this._fetchCoins(USDC_TYPE3);
|
|
3241
|
+
const postUsdcRaw = postUsdcCoins.reduce((s, c) => s + BigInt(c.balance), 0n);
|
|
3242
|
+
const gainedRaw = postUsdcRaw > preUsdcRaw ? postUsdcRaw - preUsdcRaw : 0n;
|
|
3243
|
+
const depositUsdc = Number(gainedRaw) / 10 ** USDC_DEC;
|
|
3244
|
+
let depositTx = "";
|
|
3245
|
+
if (gainedRaw > 0n) {
|
|
3246
|
+
try {
|
|
3247
|
+
const adapter = await this.resolveLending(void 0, "USDC", "save");
|
|
3248
|
+
const depositResult = await executeWithGas(this.client, this._signer, async () => {
|
|
3249
|
+
const tx = new Transaction();
|
|
3250
|
+
tx.setSender(this._address);
|
|
3251
|
+
const coins = await this._fetchCoins(USDC_TYPE3);
|
|
3252
|
+
if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", "No USDC coins after swap");
|
|
3253
|
+
const merged = this._mergeCoinsInTx(tx, coins);
|
|
3254
|
+
const [inputCoin] = tx.splitCoins(merged, [gainedRaw]);
|
|
3255
|
+
await adapter.addSaveToTx(tx, this._address, inputCoin, "USDC", { collectFee: false });
|
|
3256
|
+
return tx;
|
|
3257
|
+
});
|
|
3258
|
+
depositTx = depositResult.digest;
|
|
3259
|
+
totalGasCost += depositResult.gasCostSui;
|
|
3260
|
+
} catch (err) {
|
|
3261
|
+
console.warn("[compound] NAVI deposit failed:", err instanceof Error ? err.message : err);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
const hasSubstantiveResult = swapTxs.length > 0 || depositTx !== "";
|
|
3265
|
+
return {
|
|
3266
|
+
success: hasSubstantiveResult,
|
|
3267
|
+
claimTx: claimResult.tx,
|
|
3268
|
+
swapTxs,
|
|
3269
|
+
depositTx,
|
|
3270
|
+
rewards: nonTrivial,
|
|
3271
|
+
totalCompoundedUsdc: depositUsdc,
|
|
3272
|
+
totalGasCost
|
|
3273
|
+
};
|
|
3274
|
+
}
|
|
3148
3275
|
// -- Info --
|
|
3149
3276
|
async positions() {
|
|
3150
3277
|
const allPositions = await this.registry.allPositions(this._address);
|
|
@@ -3647,6 +3774,6 @@ function canonicalIntentBytes(payload) {
|
|
|
3647
3774
|
return new TextEncoder().encode(JSON.stringify(sorted));
|
|
3648
3775
|
}
|
|
3649
3776
|
|
|
3650
|
-
export { ALLOWANCE_FEATURES, ALL_NAVI_ASSETS, BPS_DENOMINATOR, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, IKA_TYPE, KeypairSigner, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, ProtocolRegistry, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, T2000, T2000Error, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, addCollectFeeToTx, addDepositAllowanceTx, allDescriptors, assertAllowedAsset, buildAdminDepositAllowanceTx, buildCreateAllowanceTx, buildDeductAllowanceTx, buildDepositAllowanceTx, buildScopedIntent, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, buildWithdrawAllowanceTx, buildWithdrawAmountAllowanceTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, findSwapRoute, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getAllowance, getAllowanceBalance, getDecimals, getDecimalsForCoinType, getFinancialSummary, getGasStatus, getRates, getSwapQuote, getTier, getVoloStats, isAllowedAsset, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, rawToStable, rawToUsdc, resolveSymbol, resolveTokenType, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, verifyScopedIntent, walletExists };
|
|
3777
|
+
export { ALLOWANCE_FEATURES, ALL_NAVI_ASSETS, BPS_DENOMINATOR, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, IKA_TYPE, KeypairSigner, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, ProtocolRegistry, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, T2000, T2000Error, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, addCollectFeeToTx, addDepositAllowanceTx, allDescriptors, assertAllowedAsset, buildAdminDepositAllowanceTx, buildCreateAllowanceTx, buildDeductAllowanceTx, buildDepositAllowanceTx, buildScopedIntent, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, buildWithdrawAllowanceTx, buildWithdrawAmountAllowanceTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, findSwapRoute, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getAllowance, getAllowanceBalance, getDecimals, getDecimalsForCoinType, getFinancialSummary, getGasStatus, getPendingRewards, getRates, getSwapQuote, getTier, getVoloStats, isAllowedAsset, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, rawToStable, rawToUsdc, resolveSymbol, resolveTokenType, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, verifyScopedIntent, walletExists };
|
|
3651
3778
|
//# sourceMappingURL=index.js.map
|
|
3652
3779
|
//# sourceMappingURL=index.js.map
|