@t2000/sdk 0.18.3 → 0.18.5
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 +16 -3
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +16 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +41 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -210,15 +210,20 @@ var ProtocolRegistry = class {
|
|
|
210
210
|
}
|
|
211
211
|
async allPositions(address) {
|
|
212
212
|
const results = [];
|
|
213
|
+
const errors = [];
|
|
213
214
|
for (const adapter of this.lending.values()) {
|
|
214
215
|
try {
|
|
215
216
|
const positions = await adapter.getPositions(address);
|
|
216
217
|
if (positions.supplies.length > 0 || positions.borrows.length > 0) {
|
|
217
218
|
results.push({ protocol: adapter.name, protocolId: adapter.id, positions });
|
|
218
219
|
}
|
|
219
|
-
} catch {
|
|
220
|
+
} catch (err) {
|
|
221
|
+
errors.push(`${adapter.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
220
222
|
}
|
|
221
223
|
}
|
|
224
|
+
if (results.length === 0 && errors.length > 0) {
|
|
225
|
+
throw new T2000Error("PROTOCOL_UNAVAILABLE", `Protocol queries failed (${errors.length}/${this.lending.size}): ${errors.join("; ")}`);
|
|
226
|
+
}
|
|
222
227
|
return results;
|
|
223
228
|
}
|
|
224
229
|
getLending(id) {
|
|
@@ -817,11 +822,19 @@ async function getRates(client) {
|
|
|
817
822
|
}
|
|
818
823
|
async function getPositions(client, addressOrKeypair) {
|
|
819
824
|
const address = typeof addressOrKeypair === "string" ? addressOrKeypair : addressOrKeypair.getPublicKey().toSuiAddress();
|
|
820
|
-
const [states,
|
|
825
|
+
const [states, cachedPools] = await Promise.all([getUserState(client, address), getPools()]);
|
|
826
|
+
let pools = cachedPools;
|
|
827
|
+
const unmatchedIds = states.filter((s) => !pools.find((p) => p.id === s.assetId)).map((s) => s.assetId);
|
|
828
|
+
if (unmatchedIds.length > 0) {
|
|
829
|
+
pools = await getPools(true);
|
|
830
|
+
}
|
|
821
831
|
const positions = [];
|
|
822
832
|
for (const state of states) {
|
|
823
833
|
const pool = pools.find((p) => p.id === state.assetId);
|
|
824
|
-
if (!pool)
|
|
834
|
+
if (!pool) {
|
|
835
|
+
console.warn(`[NAVI] No pool found for assetId=${state.assetId} (supply=${state.supplyBalance}, borrow=${state.borrowBalance}) \u2014 funds may be invisible`);
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
825
838
|
const symbol = resolvePoolSymbol(pool);
|
|
826
839
|
const supplyBal = compoundBalance(state.supplyBalance, pool.currentSupplyIndex, pool);
|
|
827
840
|
const borrowBal = compoundBalance(state.borrowBalance, pool.currentBorrowIndex, pool);
|