@t2000/sdk 1.22.2 → 1.23.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/index.cjs +81 -60
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +81 -60
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +64 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -5
- package/dist/index.d.ts +57 -5
- package/dist/index.js +62 -64
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -794,6 +794,7 @@ declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: st
|
|
|
794
794
|
|
|
795
795
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
796
796
|
declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
797
|
+
declare function addClaimRewardsToTx(tx: Transaction, client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
797
798
|
/**
|
|
798
799
|
* Standalone builder for the `claim_rewards` tool. Wraps the existing
|
|
799
800
|
* `addClaimRewardsToTx` appender into a complete PTB so the SPEC 7
|
|
@@ -817,6 +818,26 @@ declare function buildClaimRewardsTx(client: SuiJsonRpcClient, address: string):
|
|
|
817
818
|
tx: Transaction;
|
|
818
819
|
rewards: PendingReward$1[];
|
|
819
820
|
}>;
|
|
821
|
+
/**
|
|
822
|
+
* Minimal shape we read off the NAVI SDK's `LendingReward` rows. Kept
|
|
823
|
+
* structural rather than imported so the tests don't have to reproduce
|
|
824
|
+
* the full upstream type and the function works for any future caller
|
|
825
|
+
* that has the same fields.
|
|
826
|
+
*/
|
|
827
|
+
interface ClaimableRewardLike {
|
|
828
|
+
userClaimableReward: number | string;
|
|
829
|
+
rewardCoinType: string;
|
|
830
|
+
assetId?: number | string;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Aggregate raw NAVI `claimable` rows into the `PendingReward[]` shape
|
|
834
|
+
* the engine surfaces to the LLM and the UI. Aggregates by reward coin
|
|
835
|
+
* type so a user with rewards from multiple pools (e.g. USDC pool + SUI
|
|
836
|
+
* pool both rewarding vSUI) sees a single "0.0165 vSUI" line rather
|
|
837
|
+
* than three separate dust entries. Filters out non-finite / non-positive
|
|
838
|
+
* amounts so dust noise can't sneak in as "$0.00 REWARD" rows.
|
|
839
|
+
*/
|
|
840
|
+
declare function aggregateClaimableRewards(claimable: ClaimableRewardLike[]): PendingReward$1[];
|
|
820
841
|
|
|
821
842
|
declare function getSwapQuote(params: {
|
|
822
843
|
walletAddress: string;
|
|
@@ -1017,11 +1038,42 @@ declare function buildRevokeLeafTx(suinsClient: SuinsClient, { label }: BuildRev
|
|
|
1017
1038
|
/**
|
|
1018
1039
|
* Convenience: turn a bare label into the full `<label>.audric.sui` path.
|
|
1019
1040
|
*
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
*
|
|
1023
|
-
*
|
|
1041
|
+
* **Use this for ON-CHAIN operations** — SuiNS leaf NFT `name` field, the
|
|
1042
|
+
* `createLeafSubName` / `removeLeafSubName` move calls, and any RPC call
|
|
1043
|
+
* that returns/expects the canonical name string. The `<label>.audric.sui`
|
|
1044
|
+
* form is what the SuiNS protocol writes into the NFT `name` field.
|
|
1045
|
+
*
|
|
1046
|
+
* **Do NOT use this for UI rendering** — that's `displayHandle()`'s job
|
|
1047
|
+
* (S.118 reversal of SPEC 10 D10, see audric-build-tracker). Pre-S.118
|
|
1048
|
+
* we surfaced the full `.sui` form everywhere; we now use the SuiNS V2
|
|
1049
|
+
* `@` form (`alice@audric`) for display because it's shorter, fits the
|
|
1050
|
+
* agent harness mono aesthetic, and matches SuiNS's own V2 standard.
|
|
1051
|
+
*
|
|
1052
|
+
* Both forms resolve to the same address via SuiNS RPC (verified
|
|
1053
|
+
* mainnet 2026-05-08 PF1) — `displayHandle()` is purely a render-layer
|
|
1054
|
+
* choice, not a backend storage change.
|
|
1024
1055
|
*/
|
|
1025
1056
|
declare function fullHandle(label: string): string;
|
|
1057
|
+
/**
|
|
1058
|
+
* SuiNS V2 short-form display alias. `displayHandle('alice')` →
|
|
1059
|
+
* `'alice@audric'`. Use for chat narration, permission cards, receipts,
|
|
1060
|
+
* profile pages, share-to-X copy, OG metadata, and lookup_user output.
|
|
1061
|
+
*
|
|
1062
|
+
* **Why a separate function from `fullHandle`:**
|
|
1063
|
+
* - `fullHandle('alice')` → `'alice.audric.sui'` is the **on-chain**
|
|
1064
|
+
* NFT name field; SuiNS's `createLeafSubName` writes exactly this
|
|
1065
|
+
* string and `suix_resolveNameServiceAddress` accepts it.
|
|
1066
|
+
* - `displayHandle('alice')` → `'alice@audric'` is the **UI** form
|
|
1067
|
+
* that users see and share. SuiNS RPC also accepts this form
|
|
1068
|
+
* (verified mainnet 2026-05-08 PF1 — both forms return the same
|
|
1069
|
+
* address), so we have one storage form (`<label>.audric.sui`) and
|
|
1070
|
+
* two interchangeable input forms (the user can paste either).
|
|
1071
|
+
*
|
|
1072
|
+
* Reverses SPEC 10 D10 ("full handle ALWAYS"). See audric-build-tracker
|
|
1073
|
+
* S.118 for the rationale; see also `audric/apps/web/lib/identity/`
|
|
1074
|
+
* for canonicalization in the input parser (which is a no-op since
|
|
1075
|
+
* SuiNS RPC accepts both — kept available for future-proofing).
|
|
1076
|
+
*/
|
|
1077
|
+
declare function displayHandle(label: string): string;
|
|
1026
1078
|
|
|
1027
|
-
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|
|
1079
|
+
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -794,6 +794,7 @@ declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: st
|
|
|
794
794
|
|
|
795
795
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
796
796
|
declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
797
|
+
declare function addClaimRewardsToTx(tx: Transaction, client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
797
798
|
/**
|
|
798
799
|
* Standalone builder for the `claim_rewards` tool. Wraps the existing
|
|
799
800
|
* `addClaimRewardsToTx` appender into a complete PTB so the SPEC 7
|
|
@@ -817,6 +818,26 @@ declare function buildClaimRewardsTx(client: SuiJsonRpcClient, address: string):
|
|
|
817
818
|
tx: Transaction;
|
|
818
819
|
rewards: PendingReward$1[];
|
|
819
820
|
}>;
|
|
821
|
+
/**
|
|
822
|
+
* Minimal shape we read off the NAVI SDK's `LendingReward` rows. Kept
|
|
823
|
+
* structural rather than imported so the tests don't have to reproduce
|
|
824
|
+
* the full upstream type and the function works for any future caller
|
|
825
|
+
* that has the same fields.
|
|
826
|
+
*/
|
|
827
|
+
interface ClaimableRewardLike {
|
|
828
|
+
userClaimableReward: number | string;
|
|
829
|
+
rewardCoinType: string;
|
|
830
|
+
assetId?: number | string;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Aggregate raw NAVI `claimable` rows into the `PendingReward[]` shape
|
|
834
|
+
* the engine surfaces to the LLM and the UI. Aggregates by reward coin
|
|
835
|
+
* type so a user with rewards from multiple pools (e.g. USDC pool + SUI
|
|
836
|
+
* pool both rewarding vSUI) sees a single "0.0165 vSUI" line rather
|
|
837
|
+
* than three separate dust entries. Filters out non-finite / non-positive
|
|
838
|
+
* amounts so dust noise can't sneak in as "$0.00 REWARD" rows.
|
|
839
|
+
*/
|
|
840
|
+
declare function aggregateClaimableRewards(claimable: ClaimableRewardLike[]): PendingReward$1[];
|
|
820
841
|
|
|
821
842
|
declare function getSwapQuote(params: {
|
|
822
843
|
walletAddress: string;
|
|
@@ -1017,11 +1038,42 @@ declare function buildRevokeLeafTx(suinsClient: SuinsClient, { label }: BuildRev
|
|
|
1017
1038
|
/**
|
|
1018
1039
|
* Convenience: turn a bare label into the full `<label>.audric.sui` path.
|
|
1019
1040
|
*
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
*
|
|
1023
|
-
*
|
|
1041
|
+
* **Use this for ON-CHAIN operations** — SuiNS leaf NFT `name` field, the
|
|
1042
|
+
* `createLeafSubName` / `removeLeafSubName` move calls, and any RPC call
|
|
1043
|
+
* that returns/expects the canonical name string. The `<label>.audric.sui`
|
|
1044
|
+
* form is what the SuiNS protocol writes into the NFT `name` field.
|
|
1045
|
+
*
|
|
1046
|
+
* **Do NOT use this for UI rendering** — that's `displayHandle()`'s job
|
|
1047
|
+
* (S.118 reversal of SPEC 10 D10, see audric-build-tracker). Pre-S.118
|
|
1048
|
+
* we surfaced the full `.sui` form everywhere; we now use the SuiNS V2
|
|
1049
|
+
* `@` form (`alice@audric`) for display because it's shorter, fits the
|
|
1050
|
+
* agent harness mono aesthetic, and matches SuiNS's own V2 standard.
|
|
1051
|
+
*
|
|
1052
|
+
* Both forms resolve to the same address via SuiNS RPC (verified
|
|
1053
|
+
* mainnet 2026-05-08 PF1) — `displayHandle()` is purely a render-layer
|
|
1054
|
+
* choice, not a backend storage change.
|
|
1024
1055
|
*/
|
|
1025
1056
|
declare function fullHandle(label: string): string;
|
|
1057
|
+
/**
|
|
1058
|
+
* SuiNS V2 short-form display alias. `displayHandle('alice')` →
|
|
1059
|
+
* `'alice@audric'`. Use for chat narration, permission cards, receipts,
|
|
1060
|
+
* profile pages, share-to-X copy, OG metadata, and lookup_user output.
|
|
1061
|
+
*
|
|
1062
|
+
* **Why a separate function from `fullHandle`:**
|
|
1063
|
+
* - `fullHandle('alice')` → `'alice.audric.sui'` is the **on-chain**
|
|
1064
|
+
* NFT name field; SuiNS's `createLeafSubName` writes exactly this
|
|
1065
|
+
* string and `suix_resolveNameServiceAddress` accepts it.
|
|
1066
|
+
* - `displayHandle('alice')` → `'alice@audric'` is the **UI** form
|
|
1067
|
+
* that users see and share. SuiNS RPC also accepts this form
|
|
1068
|
+
* (verified mainnet 2026-05-08 PF1 — both forms return the same
|
|
1069
|
+
* address), so we have one storage form (`<label>.audric.sui`) and
|
|
1070
|
+
* two interchangeable input forms (the user can paste either).
|
|
1071
|
+
*
|
|
1072
|
+
* Reverses SPEC 10 D10 ("full handle ALWAYS"). See audric-build-tracker
|
|
1073
|
+
* S.118 for the rationale; see also `audric/apps/web/lib/identity/`
|
|
1074
|
+
* for canonicalization in the input parser (which is a no-op since
|
|
1075
|
+
* SuiNS RPC accepts both — kept available for future-proofing).
|
|
1076
|
+
*/
|
|
1077
|
+
declare function displayHandle(label: string): string;
|
|
1026
1078
|
|
|
1027
|
-
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|
|
1079
|
+
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|
package/dist/index.js
CHANGED
|
@@ -5099,35 +5099,6 @@ async function vt(e, n) {
|
|
|
5099
5099
|
);
|
|
5100
5100
|
return await De(e, t, n);
|
|
5101
5101
|
}
|
|
5102
|
-
function wt(e) {
|
|
5103
|
-
const n = /* @__PURE__ */ new Map();
|
|
5104
|
-
e.forEach((r) => {
|
|
5105
|
-
const t = r.assetId, a = r.option, s = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
|
|
5106
|
-
n.has(s) ? n.get(s).total += r.userClaimableReward : n.set(s, {
|
|
5107
|
-
assetId: t,
|
|
5108
|
-
rewardType: a,
|
|
5109
|
-
coinType: r.rewardCoinType,
|
|
5110
|
-
total: Number(r.userClaimableReward),
|
|
5111
|
-
market: r.market
|
|
5112
|
-
});
|
|
5113
|
-
});
|
|
5114
|
-
const o = /* @__PURE__ */ new Map();
|
|
5115
|
-
for (const { assetId: r, rewardType: t, coinType: a, total: s, market: i } of n.values()) {
|
|
5116
|
-
const c = `${r}-${t}-${i}`;
|
|
5117
|
-
o.has(c) || o.set(c, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
|
|
5118
|
-
const u = o.get(c);
|
|
5119
|
-
u.rewards.set(a, (u.rewards.get(a) || 0) + s);
|
|
5120
|
-
}
|
|
5121
|
-
return Array.from(o.values()).map((r) => ({
|
|
5122
|
-
assetId: r.assetId,
|
|
5123
|
-
rewardType: r.rewardType,
|
|
5124
|
-
market: r.market,
|
|
5125
|
-
rewards: Array.from(r.rewards.entries()).map(([t, a]) => ({
|
|
5126
|
-
coinType: t,
|
|
5127
|
-
available: a.toFixed(6)
|
|
5128
|
-
}))
|
|
5129
|
-
}));
|
|
5130
|
-
}
|
|
5131
5102
|
async function Ct(e, n, o) {
|
|
5132
5103
|
const r = await R({
|
|
5133
5104
|
...o,
|
|
@@ -5305,6 +5276,7 @@ async function Ct(e, n, o) {
|
|
|
5305
5276
|
|
|
5306
5277
|
// src/protocols/navi.ts
|
|
5307
5278
|
init_errors();
|
|
5279
|
+
init_token_registry();
|
|
5308
5280
|
var MIN_HEALTH_FACTOR = 1.5;
|
|
5309
5281
|
function sdkOptions(client) {
|
|
5310
5282
|
return { env: "prod", client, cacheTime: 0, disableCache: true };
|
|
@@ -5663,53 +5635,61 @@ async function maxBorrowAmount(client, address) {
|
|
|
5663
5635
|
return { maxAmount, healthFactorAfter: MIN_HEALTH_FACTOR, currentHF: hf.healthFactor };
|
|
5664
5636
|
}
|
|
5665
5637
|
async function getPendingRewards(client, address) {
|
|
5638
|
+
let rewards;
|
|
5666
5639
|
try {
|
|
5667
|
-
|
|
5640
|
+
rewards = await vt(address, {
|
|
5668
5641
|
...sdkOptions(client),
|
|
5669
5642
|
markets: ["main"]
|
|
5670
5643
|
});
|
|
5671
|
-
|
|
5672
|
-
const
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
result.push({
|
|
5680
|
-
protocol: "navi",
|
|
5681
|
-
asset: String(s.assetId),
|
|
5682
|
-
coinType: rw.coinType,
|
|
5683
|
-
symbol,
|
|
5684
|
-
amount: available,
|
|
5685
|
-
estimatedValueUsd: 0
|
|
5686
|
-
});
|
|
5687
|
-
}
|
|
5688
|
-
}
|
|
5689
|
-
return result;
|
|
5690
|
-
} catch {
|
|
5691
|
-
return [];
|
|
5644
|
+
} catch (err) {
|
|
5645
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
5646
|
+
throw new T2000Error(
|
|
5647
|
+
"PROTOCOL_UNAVAILABLE",
|
|
5648
|
+
`NAVI rewards lookup failed: ${msg}`,
|
|
5649
|
+
{ source: "navi-rewards-read" },
|
|
5650
|
+
true
|
|
5651
|
+
);
|
|
5692
5652
|
}
|
|
5653
|
+
if (!rewards || rewards.length === 0) return [];
|
|
5654
|
+
const claimable = rewards.filter((r) => Number(r.userClaimableReward) > 0);
|
|
5655
|
+
return aggregateClaimableRewards(claimable);
|
|
5693
5656
|
}
|
|
5694
5657
|
async function addClaimRewardsToTx(tx, client, address) {
|
|
5658
|
+
let rewards;
|
|
5695
5659
|
try {
|
|
5696
|
-
|
|
5660
|
+
rewards = await vt(address, {
|
|
5697
5661
|
...sdkOptions(client),
|
|
5698
5662
|
markets: ["main"]
|
|
5699
5663
|
});
|
|
5700
|
-
|
|
5701
|
-
const
|
|
5702
|
-
|
|
5664
|
+
} catch (err) {
|
|
5665
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
5666
|
+
throw new T2000Error(
|
|
5667
|
+
"PROTOCOL_UNAVAILABLE",
|
|
5668
|
+
`NAVI rewards lookup failed: ${msg}`,
|
|
5669
|
+
{ source: "navi-rewards-claim-prelude" },
|
|
5670
|
+
true
|
|
5703
5671
|
);
|
|
5704
|
-
|
|
5672
|
+
}
|
|
5673
|
+
if (!rewards || rewards.length === 0) return [];
|
|
5674
|
+
const claimable = rewards.filter(
|
|
5675
|
+
(r) => Number(r.userClaimableReward) > 0
|
|
5676
|
+
);
|
|
5677
|
+
if (claimable.length === 0) return [];
|
|
5678
|
+
try {
|
|
5705
5679
|
await Ct(tx, claimable, {
|
|
5706
5680
|
env: "prod",
|
|
5707
5681
|
customCoinReceive: { type: "transfer", transfer: address }
|
|
5708
5682
|
});
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5683
|
+
} catch (err) {
|
|
5684
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
5685
|
+
throw new T2000Error(
|
|
5686
|
+
"PROTOCOL_UNAVAILABLE",
|
|
5687
|
+
`NAVI claim PTB build failed: ${msg}`,
|
|
5688
|
+
{ source: "navi-rewards-claim-ptb" },
|
|
5689
|
+
true
|
|
5690
|
+
);
|
|
5712
5691
|
}
|
|
5692
|
+
return aggregateClaimableRewards(claimable);
|
|
5713
5693
|
}
|
|
5714
5694
|
async function buildClaimRewardsTx(client, address) {
|
|
5715
5695
|
const tx = new Transaction();
|
|
@@ -5722,7 +5702,8 @@ function aggregateClaimableRewards(claimable) {
|
|
|
5722
5702
|
for (const c of claimable) {
|
|
5723
5703
|
const coinType = c.rewardCoinType;
|
|
5724
5704
|
if (!coinType) continue;
|
|
5725
|
-
const
|
|
5705
|
+
const meta = getCoinMeta(coinType);
|
|
5706
|
+
const symbol = meta?.symbol ?? coinType.split("::").pop() ?? "REWARD";
|
|
5726
5707
|
const amount = Number(c.userClaimableReward);
|
|
5727
5708
|
if (!Number.isFinite(amount) || amount <= 0) continue;
|
|
5728
5709
|
const existing = aggregated.get(coinType);
|
|
@@ -7173,13 +7154,20 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
7173
7154
|
}
|
|
7174
7155
|
// -- Claim Rewards --
|
|
7175
7156
|
async getPendingRewards() {
|
|
7176
|
-
const adapters = this.registry.listLending();
|
|
7157
|
+
const adapters = this.registry.listLending().filter((a) => a.getPendingRewards);
|
|
7158
|
+
if (adapters.length === 0) return [];
|
|
7177
7159
|
const results = await Promise.allSettled(
|
|
7178
|
-
adapters.
|
|
7160
|
+
adapters.map((a) => a.getPendingRewards(this._address))
|
|
7179
7161
|
);
|
|
7180
7162
|
const all = [];
|
|
7163
|
+
const errors = [];
|
|
7181
7164
|
for (const r of results) {
|
|
7182
7165
|
if (r.status === "fulfilled") all.push(...r.value);
|
|
7166
|
+
else errors.push(r.reason);
|
|
7167
|
+
}
|
|
7168
|
+
if (all.length === 0 && errors.length === adapters.length) {
|
|
7169
|
+
const first = errors[0];
|
|
7170
|
+
throw first instanceof Error ? first : new Error(String(first));
|
|
7183
7171
|
}
|
|
7184
7172
|
return all;
|
|
7185
7173
|
}
|
|
@@ -7192,13 +7180,19 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
7192
7180
|
const tx = new Transaction();
|
|
7193
7181
|
tx.setSender(this._address);
|
|
7194
7182
|
const allRewards = [];
|
|
7183
|
+
const errors = [];
|
|
7195
7184
|
for (const adapter of adapters) {
|
|
7196
7185
|
try {
|
|
7197
7186
|
const claimed = await adapter.addClaimRewardsToTx(tx, this._address);
|
|
7198
7187
|
allRewards.push(...claimed);
|
|
7199
|
-
} catch {
|
|
7188
|
+
} catch (err) {
|
|
7189
|
+
errors.push(err);
|
|
7200
7190
|
}
|
|
7201
7191
|
}
|
|
7192
|
+
if (allRewards.length === 0 && errors.length === adapters.length) {
|
|
7193
|
+
const first = errors[0];
|
|
7194
|
+
throw first instanceof Error ? first : new Error(String(first));
|
|
7195
|
+
}
|
|
7202
7196
|
if (allRewards.length === 0) {
|
|
7203
7197
|
return { success: true, tx: "", rewards: [], totalValueUsd: 0, gasCost: 0 };
|
|
7204
7198
|
}
|
|
@@ -8052,12 +8046,16 @@ function buildRevokeLeafTx(suinsClient, { label }) {
|
|
|
8052
8046
|
function fullHandle(label) {
|
|
8053
8047
|
return `${label}.${AUDRIC_PARENT_NAME}`;
|
|
8054
8048
|
}
|
|
8049
|
+
function displayHandle(label) {
|
|
8050
|
+
const parentDisplay = AUDRIC_PARENT_NAME.replace(/\.sui$/, "");
|
|
8051
|
+
return `${label}@${parentDisplay}`;
|
|
8052
|
+
}
|
|
8055
8053
|
/*! Bundled license information:
|
|
8056
8054
|
|
|
8057
8055
|
@scure/base/index.js:
|
|
8058
8056
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
8059
8057
|
*/
|
|
8060
8058
|
|
|
8061
|
-
export { ALL_NAVI_ASSETS, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, BORROW_FEE_BPS, 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, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVE_FEE_BPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addFeeTransfer, addSendToTx, addStakeVSuiToTx, addSwapToTx, addUnstakeVSuiToTx, allDescriptors, assertAllowedAsset, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, deriveAllowedAddressesFromPtb, exportPrivateKey, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getTier, getVoloStats, isAllowedAsset, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAsset, normalizeCoinType, parseSuiRpcTx, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, saveKey, selectAndSplitCoin, selectSuiCoin, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, walletExists };
|
|
8059
|
+
export { ALL_NAVI_ASSETS, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, BORROW_FEE_BPS, 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, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVE_FEE_BPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addClaimRewardsToTx, addFeeTransfer, addSendToTx, addStakeVSuiToTx, addSwapToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, allDescriptors, assertAllowedAsset, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getTier, getVoloStats, isAllowedAsset, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAsset, normalizeCoinType, parseSuiRpcTx, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, saveKey, selectAndSplitCoin, selectSuiCoin, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, walletExists };
|
|
8062
8060
|
//# sourceMappingURL=index.js.map
|
|
8063
8061
|
//# sourceMappingURL=index.js.map
|