@t2000/sdk 0.16.30 → 0.17.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/README.md +4 -1
- package/dist/adapters/index.cjs +32 -13
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +32 -13
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +46 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -73,8 +73,16 @@ declare const SUPPORTED_ASSETS: {
|
|
|
73
73
|
readonly symbol: "ETH";
|
|
74
74
|
readonly displayName: "Ethereum";
|
|
75
75
|
};
|
|
76
|
+
readonly GOLD: {
|
|
77
|
+
readonly type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM";
|
|
78
|
+
readonly decimals: 9;
|
|
79
|
+
readonly symbol: "GOLD";
|
|
80
|
+
readonly displayName: "Gold";
|
|
81
|
+
};
|
|
76
82
|
};
|
|
77
83
|
type SupportedAsset = keyof typeof SUPPORTED_ASSETS;
|
|
84
|
+
type StableAsset = Exclude<SupportedAsset, 'SUI' | 'BTC' | 'ETH' | 'GOLD'>;
|
|
85
|
+
declare const STABLE_ASSETS: readonly StableAsset[];
|
|
78
86
|
declare const DEFAULT_NETWORK: "mainnet";
|
|
79
87
|
declare const INVESTMENT_ASSETS: {
|
|
80
88
|
readonly SUI: {
|
|
@@ -95,6 +103,12 @@ declare const INVESTMENT_ASSETS: {
|
|
|
95
103
|
readonly symbol: "ETH";
|
|
96
104
|
readonly displayName: "Ethereum";
|
|
97
105
|
};
|
|
106
|
+
readonly GOLD: {
|
|
107
|
+
readonly type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM";
|
|
108
|
+
readonly decimals: 9;
|
|
109
|
+
readonly symbol: "GOLD";
|
|
110
|
+
readonly displayName: "Gold";
|
|
111
|
+
};
|
|
98
112
|
};
|
|
99
113
|
type InvestmentAsset = keyof typeof INVESTMENT_ASSETS;
|
|
100
114
|
declare const DEFAULT_STRATEGIES: {
|
|
@@ -127,6 +141,26 @@ declare const DEFAULT_STRATEGIES: {
|
|
|
127
141
|
readonly description: "Sui-weighted portfolio";
|
|
128
142
|
readonly custom: false;
|
|
129
143
|
};
|
|
144
|
+
readonly 'all-weather': {
|
|
145
|
+
readonly name: "All-Weather Portfolio";
|
|
146
|
+
readonly allocations: {
|
|
147
|
+
readonly BTC: 30;
|
|
148
|
+
readonly ETH: 20;
|
|
149
|
+
readonly SUI: 20;
|
|
150
|
+
readonly GOLD: 30;
|
|
151
|
+
};
|
|
152
|
+
readonly description: "Crypto and commodities";
|
|
153
|
+
readonly custom: false;
|
|
154
|
+
};
|
|
155
|
+
readonly 'safe-haven': {
|
|
156
|
+
readonly name: "Safe Haven";
|
|
157
|
+
readonly allocations: {
|
|
158
|
+
readonly BTC: 50;
|
|
159
|
+
readonly GOLD: 50;
|
|
160
|
+
};
|
|
161
|
+
readonly description: "Store-of-value assets";
|
|
162
|
+
readonly custom: false;
|
|
163
|
+
};
|
|
130
164
|
};
|
|
131
165
|
declare const PERPS_MARKETS: readonly ["SUI-PERP"];
|
|
132
166
|
type PerpsMarket = (typeof PERPS_MARKETS)[number];
|
|
@@ -609,4 +643,4 @@ interface GasStatusResponse {
|
|
|
609
643
|
}
|
|
610
644
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
611
645
|
|
|
612
|
-
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
646
|
+
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -73,8 +73,16 @@ declare const SUPPORTED_ASSETS: {
|
|
|
73
73
|
readonly symbol: "ETH";
|
|
74
74
|
readonly displayName: "Ethereum";
|
|
75
75
|
};
|
|
76
|
+
readonly GOLD: {
|
|
77
|
+
readonly type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM";
|
|
78
|
+
readonly decimals: 9;
|
|
79
|
+
readonly symbol: "GOLD";
|
|
80
|
+
readonly displayName: "Gold";
|
|
81
|
+
};
|
|
76
82
|
};
|
|
77
83
|
type SupportedAsset = keyof typeof SUPPORTED_ASSETS;
|
|
84
|
+
type StableAsset = Exclude<SupportedAsset, 'SUI' | 'BTC' | 'ETH' | 'GOLD'>;
|
|
85
|
+
declare const STABLE_ASSETS: readonly StableAsset[];
|
|
78
86
|
declare const DEFAULT_NETWORK: "mainnet";
|
|
79
87
|
declare const INVESTMENT_ASSETS: {
|
|
80
88
|
readonly SUI: {
|
|
@@ -95,6 +103,12 @@ declare const INVESTMENT_ASSETS: {
|
|
|
95
103
|
readonly symbol: "ETH";
|
|
96
104
|
readonly displayName: "Ethereum";
|
|
97
105
|
};
|
|
106
|
+
readonly GOLD: {
|
|
107
|
+
readonly type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM";
|
|
108
|
+
readonly decimals: 9;
|
|
109
|
+
readonly symbol: "GOLD";
|
|
110
|
+
readonly displayName: "Gold";
|
|
111
|
+
};
|
|
98
112
|
};
|
|
99
113
|
type InvestmentAsset = keyof typeof INVESTMENT_ASSETS;
|
|
100
114
|
declare const DEFAULT_STRATEGIES: {
|
|
@@ -127,6 +141,26 @@ declare const DEFAULT_STRATEGIES: {
|
|
|
127
141
|
readonly description: "Sui-weighted portfolio";
|
|
128
142
|
readonly custom: false;
|
|
129
143
|
};
|
|
144
|
+
readonly 'all-weather': {
|
|
145
|
+
readonly name: "All-Weather Portfolio";
|
|
146
|
+
readonly allocations: {
|
|
147
|
+
readonly BTC: 30;
|
|
148
|
+
readonly ETH: 20;
|
|
149
|
+
readonly SUI: 20;
|
|
150
|
+
readonly GOLD: 30;
|
|
151
|
+
};
|
|
152
|
+
readonly description: "Crypto and commodities";
|
|
153
|
+
readonly custom: false;
|
|
154
|
+
};
|
|
155
|
+
readonly 'safe-haven': {
|
|
156
|
+
readonly name: "Safe Haven";
|
|
157
|
+
readonly allocations: {
|
|
158
|
+
readonly BTC: 50;
|
|
159
|
+
readonly GOLD: 50;
|
|
160
|
+
};
|
|
161
|
+
readonly description: "Store-of-value assets";
|
|
162
|
+
readonly custom: false;
|
|
163
|
+
};
|
|
130
164
|
};
|
|
131
165
|
declare const PERPS_MARKETS: readonly ["SUI-PERP"];
|
|
132
166
|
type PerpsMarket = (typeof PERPS_MARKETS)[number];
|
|
@@ -609,4 +643,4 @@ interface GasStatusResponse {
|
|
|
609
643
|
}
|
|
610
644
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
611
645
|
|
|
612
|
-
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
646
|
+
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
package/dist/index.js
CHANGED
|
@@ -68,6 +68,12 @@ var SUPPORTED_ASSETS = {
|
|
|
68
68
|
decimals: 8,
|
|
69
69
|
symbol: "ETH",
|
|
70
70
|
displayName: "Ethereum"
|
|
71
|
+
},
|
|
72
|
+
GOLD: {
|
|
73
|
+
type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM",
|
|
74
|
+
decimals: 9,
|
|
75
|
+
symbol: "GOLD",
|
|
76
|
+
displayName: "Gold"
|
|
71
77
|
}
|
|
72
78
|
};
|
|
73
79
|
var STABLE_ASSETS = ["USDC", "USDT", "USDe", "USDsui"];
|
|
@@ -83,7 +89,8 @@ var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35
|
|
|
83
89
|
var INVESTMENT_ASSETS = {
|
|
84
90
|
SUI: SUPPORTED_ASSETS.SUI,
|
|
85
91
|
BTC: SUPPORTED_ASSETS.BTC,
|
|
86
|
-
ETH: SUPPORTED_ASSETS.ETH
|
|
92
|
+
ETH: SUPPORTED_ASSETS.ETH,
|
|
93
|
+
GOLD: SUPPORTED_ASSETS.GOLD
|
|
87
94
|
};
|
|
88
95
|
var DEFAULT_STRATEGIES = {
|
|
89
96
|
bluechip: {
|
|
@@ -103,6 +110,18 @@ var DEFAULT_STRATEGIES = {
|
|
|
103
110
|
allocations: { BTC: 20, ETH: 20, SUI: 60 },
|
|
104
111
|
description: "Sui-weighted portfolio",
|
|
105
112
|
custom: false
|
|
113
|
+
},
|
|
114
|
+
"all-weather": {
|
|
115
|
+
name: "All-Weather Portfolio",
|
|
116
|
+
allocations: { BTC: 30, ETH: 20, SUI: 20, GOLD: 30 },
|
|
117
|
+
description: "Crypto and commodities",
|
|
118
|
+
custom: false
|
|
119
|
+
},
|
|
120
|
+
"safe-haven": {
|
|
121
|
+
name: "Safe Haven",
|
|
122
|
+
allocations: { BTC: 50, GOLD: 50 },
|
|
123
|
+
description: "Store-of-value assets",
|
|
124
|
+
custom: false
|
|
106
125
|
}
|
|
107
126
|
};
|
|
108
127
|
var PERPS_MARKETS = ["SUI-PERP"];
|
|
@@ -349,6 +368,7 @@ function formatSui(amount) {
|
|
|
349
368
|
}
|
|
350
369
|
function formatAssetAmount(amount, asset) {
|
|
351
370
|
if (asset === "BTC") return amount.toFixed(8);
|
|
371
|
+
if (asset === "GOLD") return amount.toFixed(6);
|
|
352
372
|
if (asset === "ETH") return amount.toFixed(6);
|
|
353
373
|
return amount.toFixed(4);
|
|
354
374
|
}
|
|
@@ -569,7 +589,9 @@ SUPPORTED_ASSETS.USDC.type;
|
|
|
569
589
|
var RATE_DECIMALS = 27;
|
|
570
590
|
var LTV_DECIMALS = 27;
|
|
571
591
|
var MIN_HEALTH_FACTOR = 1.5;
|
|
572
|
-
|
|
592
|
+
function withdrawDustBuffer(decimals) {
|
|
593
|
+
return 1e3 / 10 ** decimals;
|
|
594
|
+
}
|
|
573
595
|
var CLOCK = "0x06";
|
|
574
596
|
var SUI_SYSTEM_STATE = "0x05";
|
|
575
597
|
var NAVI_BALANCE_DECIMALS = 9;
|
|
@@ -692,6 +714,16 @@ function rateToApy(rawRate) {
|
|
|
692
714
|
if (!rawRate || rawRate === "0") return 0;
|
|
693
715
|
return Number(BigInt(rawRate)) / 10 ** RATE_DECIMALS * 100;
|
|
694
716
|
}
|
|
717
|
+
function poolSaveApy(pool) {
|
|
718
|
+
const incentive = parseFloat(pool.supplyIncentiveApyInfo?.apy ?? "0");
|
|
719
|
+
if (incentive > 0) return incentive;
|
|
720
|
+
return rateToApy(pool.currentSupplyRate);
|
|
721
|
+
}
|
|
722
|
+
function poolBorrowApy(pool) {
|
|
723
|
+
const incentive = parseFloat(pool.borrowIncentiveApyInfo?.apy ?? "0");
|
|
724
|
+
if (incentive > 0) return incentive;
|
|
725
|
+
return rateToApy(pool.currentBorrowRate);
|
|
726
|
+
}
|
|
695
727
|
function parseLtv(rawLtv) {
|
|
696
728
|
if (!rawLtv || rawLtv === "0") return 0.75;
|
|
697
729
|
return Number(BigInt(rawLtv)) / 10 ** LTV_DECIMALS;
|
|
@@ -801,7 +833,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
801
833
|
]);
|
|
802
834
|
const assetState = states.find((s) => s.assetId === pool.id);
|
|
803
835
|
const deposited = assetState ? compoundBalance(assetState.supplyBalance, pool.currentSupplyIndex, pool) : 0;
|
|
804
|
-
const effectiveAmount = Math.min(amount, Math.max(0, deposited -
|
|
836
|
+
const effectiveAmount = Math.min(amount, Math.max(0, deposited - withdrawDustBuffer(assetInfo.decimals)));
|
|
805
837
|
if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
|
|
806
838
|
const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
|
|
807
839
|
if (rawAmount <= 0) {
|
|
@@ -844,7 +876,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
844
876
|
]);
|
|
845
877
|
const assetState = states.find((s) => s.assetId === pool.id);
|
|
846
878
|
const deposited = assetState ? compoundBalance(assetState.supplyBalance, pool.currentSupplyIndex, pool) : 0;
|
|
847
|
-
const effectiveAmount = Math.min(amount, Math.max(0, deposited -
|
|
879
|
+
const effectiveAmount = Math.min(amount, Math.max(0, deposited - withdrawDustBuffer(assetInfo.decimals)));
|
|
848
880
|
if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
|
|
849
881
|
const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
|
|
850
882
|
if (rawAmount <= 0) {
|
|
@@ -1073,7 +1105,7 @@ async function getHealthFactor(client, addressOrKeypair) {
|
|
|
1073
1105
|
liquidationThreshold: liqThreshold
|
|
1074
1106
|
};
|
|
1075
1107
|
}
|
|
1076
|
-
var NAVI_SUPPORTED_ASSETS = [...STABLE_ASSETS, "SUI", "ETH"];
|
|
1108
|
+
var NAVI_SUPPORTED_ASSETS = [...STABLE_ASSETS, "SUI", "ETH", "GOLD"];
|
|
1077
1109
|
async function getRates(client) {
|
|
1078
1110
|
try {
|
|
1079
1111
|
const pools = await getPools();
|
|
@@ -1082,10 +1114,10 @@ async function getRates(client) {
|
|
|
1082
1114
|
const targetType = SUPPORTED_ASSETS[asset].type;
|
|
1083
1115
|
const pool = pools.find((p) => matchesCoinType(p.suiCoinType || p.coinType || "", targetType));
|
|
1084
1116
|
if (!pool) continue;
|
|
1085
|
-
let saveApy =
|
|
1086
|
-
let borrowApy =
|
|
1087
|
-
if (saveApy <= 0 || saveApy >
|
|
1088
|
-
if (borrowApy <= 0 || borrowApy >
|
|
1117
|
+
let saveApy = poolSaveApy(pool);
|
|
1118
|
+
let borrowApy = poolBorrowApy(pool);
|
|
1119
|
+
if (saveApy <= 0 || saveApy > 200) saveApy = 0;
|
|
1120
|
+
if (borrowApy <= 0 || borrowApy > 200) borrowApy = 0;
|
|
1089
1121
|
result[asset] = { saveApy, borrowApy };
|
|
1090
1122
|
}
|
|
1091
1123
|
if (!result.USDC) result.USDC = { saveApy: 4, borrowApy: 6 };
|
|
@@ -1110,7 +1142,7 @@ async function getPositions(client, addressOrKeypair) {
|
|
|
1110
1142
|
asset: symbol,
|
|
1111
1143
|
type: "save",
|
|
1112
1144
|
amount: supplyBal,
|
|
1113
|
-
apy:
|
|
1145
|
+
apy: poolSaveApy(pool)
|
|
1114
1146
|
});
|
|
1115
1147
|
}
|
|
1116
1148
|
if (borrowBal > 1e-4) {
|
|
@@ -1119,7 +1151,7 @@ async function getPositions(client, addressOrKeypair) {
|
|
|
1119
1151
|
asset: symbol,
|
|
1120
1152
|
type: "borrow",
|
|
1121
1153
|
amount: borrowBal,
|
|
1122
|
-
apy:
|
|
1154
|
+
apy: poolBorrowApy(pool)
|
|
1123
1155
|
});
|
|
1124
1156
|
}
|
|
1125
1157
|
}
|
|
@@ -1527,7 +1559,7 @@ var NaviAdapter = class {
|
|
|
1527
1559
|
name = "NAVI Protocol";
|
|
1528
1560
|
version = "1.0.0";
|
|
1529
1561
|
capabilities = ["save", "withdraw", "borrow", "repay"];
|
|
1530
|
-
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH"];
|
|
1562
|
+
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH", "GOLD"];
|
|
1531
1563
|
supportsSameAssetBorrow = true;
|
|
1532
1564
|
client;
|
|
1533
1565
|
async init(client) {
|
|
@@ -1934,7 +1966,7 @@ var SuilendAdapter = class {
|
|
|
1934
1966
|
name = "Suilend";
|
|
1935
1967
|
version = "2.0.0";
|
|
1936
1968
|
capabilities = ["save", "withdraw", "borrow", "repay"];
|
|
1937
|
-
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH", "BTC"];
|
|
1969
|
+
supportedAssets = [...STABLE_ASSETS, "SUI", "ETH", "BTC", "GOLD"];
|
|
1938
1970
|
supportsSameAssetBorrow = false;
|
|
1939
1971
|
client;
|
|
1940
1972
|
publishedAt = null;
|
|
@@ -5371,6 +5403,6 @@ var allDescriptors = [
|
|
|
5371
5403
|
descriptor
|
|
5372
5404
|
];
|
|
5373
5405
|
|
|
5374
|
-
export { AutoInvestManager, BPS_DENOMINATOR, CLOCK_ID, CetusAdapter, ContactManager, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, GAS_RESERVE_MIN, INVESTMENT_ASSETS, MIST_PER_SUI, NaviAdapter, OUTBOUND_OPS, PERPS_MARKETS, PortfolioManager, ProtocolRegistry, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, StrategyManager, SuilendAdapter, T2000, T2000Error, USDC_DECIMALS, addCollectFeeToTx, allDescriptors, calculateFee, descriptor3 as cetusDescriptor, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, getSentinelInfo, keypairFromPrivateKey, listSentinels, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, descriptor2 as naviDescriptor, rawToStable, rawToUsdc, requestAttack, saveKey, attack as sentinelAttack, descriptor as sentinelDescriptor, settleAttack, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, submitPrompt, suiToMist, descriptor4 as suilendDescriptor, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
5406
|
+
export { AutoInvestManager, BPS_DENOMINATOR, CLOCK_ID, CetusAdapter, ContactManager, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, GAS_RESERVE_MIN, INVESTMENT_ASSETS, MIST_PER_SUI, NaviAdapter, OUTBOUND_OPS, PERPS_MARKETS, PortfolioManager, ProtocolRegistry, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, StrategyManager, SuilendAdapter, T2000, T2000Error, USDC_DECIMALS, addCollectFeeToTx, allDescriptors, calculateFee, descriptor3 as cetusDescriptor, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, getSentinelInfo, keypairFromPrivateKey, listSentinels, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, descriptor2 as naviDescriptor, rawToStable, rawToUsdc, requestAttack, saveKey, attack as sentinelAttack, descriptor as sentinelDescriptor, settleAttack, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, submitPrompt, suiToMist, descriptor4 as suilendDescriptor, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
5375
5407
|
//# sourceMappingURL=index.js.map
|
|
5376
5408
|
//# sourceMappingURL=index.js.map
|