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