@owney/sdk 0.7.7-beta.3 → 0.7.7-beta.4
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/index.cjs +31 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +31 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -217,6 +217,32 @@ function resolveChainId(chain) {
|
|
|
217
217
|
if (Number.isFinite(asNum) && asNum > 0) return asNum;
|
|
218
218
|
return NAME_TO_CHAIN_ID[chain.trim().toLowerCase()] ?? NaN;
|
|
219
219
|
}
|
|
220
|
+
function mapPendingAllocations(raw) {
|
|
221
|
+
if (!Array.isArray(raw)) return void 0;
|
|
222
|
+
const pending = [];
|
|
223
|
+
for (const entry of raw) {
|
|
224
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
225
|
+
const e = entry;
|
|
226
|
+
if (e.isPending !== true) continue;
|
|
227
|
+
if (typeof e.chainId !== "number" || !Number.isFinite(e.chainId)) continue;
|
|
228
|
+
if (typeof e.tokenSymbol !== "string" || e.tokenSymbol === "") continue;
|
|
229
|
+
if (typeof e.balance !== "string") continue;
|
|
230
|
+
let amount;
|
|
231
|
+
try {
|
|
232
|
+
amount = hexToDecimal(e.balance, tokenDecimals(e.tokenSymbol));
|
|
233
|
+
} catch {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (!Number.isFinite(amount) || amount <= 0) continue;
|
|
237
|
+
pending.push({
|
|
238
|
+
chainId: e.chainId,
|
|
239
|
+
asset: e.tokenSymbol,
|
|
240
|
+
amount: String(amount),
|
|
241
|
+
...typeof e.updatedAt === "string" && e.updatedAt !== "" ? { since: e.updatedAt } : {}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return pending.length > 0 ? pending : void 0;
|
|
245
|
+
}
|
|
220
246
|
function mapBalances(raw, _chainId, smartWallet) {
|
|
221
247
|
const portfolio = raw.portfolio;
|
|
222
248
|
const portfolioByChain = portfolio.portfolioByChain ?? {};
|
|
@@ -268,12 +294,16 @@ function mapBalances(raw, _chainId, smartWallet) {
|
|
|
268
294
|
// structural read keeps it undefined today and auto-populates later.
|
|
269
295
|
liquidity: p.liquidity
|
|
270
296
|
}));
|
|
297
|
+
const pendingAllocations = mapPendingAllocations(
|
|
298
|
+
portfolio.staleBalances
|
|
299
|
+
);
|
|
271
300
|
return {
|
|
272
301
|
smartWallet,
|
|
273
302
|
totalBalance: String(totalBalance),
|
|
274
303
|
totalBalanceAsset: "usdc",
|
|
275
304
|
tokens,
|
|
276
|
-
positions
|
|
305
|
+
positions,
|
|
306
|
+
...pendingAllocations ? { pendingAllocations } : {}
|
|
277
307
|
};
|
|
278
308
|
}
|
|
279
309
|
function sumTokenValues(tokens) {
|
package/dist/index.d.cts
CHANGED
|
@@ -180,6 +180,21 @@ interface OwneyPosition {
|
|
|
180
180
|
* response later; undefined until then. */
|
|
181
181
|
liquidity?: number;
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Funds that have landed in the agent's wallet but are not yet deployed into a
|
|
185
|
+
* protocol. Sourced from Zyfai `staleBalances[].isPending`. Absent when nothing
|
|
186
|
+
* is pending, and for agents that do not report it (sail).
|
|
187
|
+
*/
|
|
188
|
+
interface OwneyPendingAllocation {
|
|
189
|
+
/** Deliberately loose (not OwneySupportedChainId) because Zyfai reports balances on unsupported chains. */
|
|
190
|
+
chainId: number;
|
|
191
|
+
/** Raw agent symbol, not normalized to OwneySupportedTokens; carries Zyfai's casing and "eth" alias for WETH. */
|
|
192
|
+
asset: string;
|
|
193
|
+
/** Decimal string, consistent with `OwneyToken.amount`. */
|
|
194
|
+
amount: string;
|
|
195
|
+
/** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
|
|
196
|
+
since?: string;
|
|
197
|
+
}
|
|
183
198
|
interface AgentBalance {
|
|
184
199
|
smartWallet?: `0x${string}`;
|
|
185
200
|
totalBalance: string;
|
|
@@ -191,6 +206,8 @@ interface AgentBalance {
|
|
|
191
206
|
* them (zyfai). Omitted for agents that don't expose positions (sail).
|
|
192
207
|
*/
|
|
193
208
|
positions?: OwneyPosition[];
|
|
209
|
+
/** Funds received but not yet deployed. Omitted when nothing is pending. */
|
|
210
|
+
pendingAllocations?: OwneyPendingAllocation[];
|
|
194
211
|
}
|
|
195
212
|
interface OwneyBalances {
|
|
196
213
|
totalBalance: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -180,6 +180,21 @@ interface OwneyPosition {
|
|
|
180
180
|
* response later; undefined until then. */
|
|
181
181
|
liquidity?: number;
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Funds that have landed in the agent's wallet but are not yet deployed into a
|
|
185
|
+
* protocol. Sourced from Zyfai `staleBalances[].isPending`. Absent when nothing
|
|
186
|
+
* is pending, and for agents that do not report it (sail).
|
|
187
|
+
*/
|
|
188
|
+
interface OwneyPendingAllocation {
|
|
189
|
+
/** Deliberately loose (not OwneySupportedChainId) because Zyfai reports balances on unsupported chains. */
|
|
190
|
+
chainId: number;
|
|
191
|
+
/** Raw agent symbol, not normalized to OwneySupportedTokens; carries Zyfai's casing and "eth" alias for WETH. */
|
|
192
|
+
asset: string;
|
|
193
|
+
/** Decimal string, consistent with `OwneyToken.amount`. */
|
|
194
|
+
amount: string;
|
|
195
|
+
/** ISO timestamp from Zyfai's `updatedAt`, when the payload carries one. */
|
|
196
|
+
since?: string;
|
|
197
|
+
}
|
|
183
198
|
interface AgentBalance {
|
|
184
199
|
smartWallet?: `0x${string}`;
|
|
185
200
|
totalBalance: string;
|
|
@@ -191,6 +206,8 @@ interface AgentBalance {
|
|
|
191
206
|
* them (zyfai). Omitted for agents that don't expose positions (sail).
|
|
192
207
|
*/
|
|
193
208
|
positions?: OwneyPosition[];
|
|
209
|
+
/** Funds received but not yet deployed. Omitted when nothing is pending. */
|
|
210
|
+
pendingAllocations?: OwneyPendingAllocation[];
|
|
194
211
|
}
|
|
195
212
|
interface OwneyBalances {
|
|
196
213
|
totalBalance: string;
|
package/dist/index.js
CHANGED
|
@@ -184,6 +184,32 @@ function resolveChainId(chain) {
|
|
|
184
184
|
if (Number.isFinite(asNum) && asNum > 0) return asNum;
|
|
185
185
|
return NAME_TO_CHAIN_ID[chain.trim().toLowerCase()] ?? NaN;
|
|
186
186
|
}
|
|
187
|
+
function mapPendingAllocations(raw) {
|
|
188
|
+
if (!Array.isArray(raw)) return void 0;
|
|
189
|
+
const pending = [];
|
|
190
|
+
for (const entry of raw) {
|
|
191
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
192
|
+
const e = entry;
|
|
193
|
+
if (e.isPending !== true) continue;
|
|
194
|
+
if (typeof e.chainId !== "number" || !Number.isFinite(e.chainId)) continue;
|
|
195
|
+
if (typeof e.tokenSymbol !== "string" || e.tokenSymbol === "") continue;
|
|
196
|
+
if (typeof e.balance !== "string") continue;
|
|
197
|
+
let amount;
|
|
198
|
+
try {
|
|
199
|
+
amount = hexToDecimal(e.balance, tokenDecimals(e.tokenSymbol));
|
|
200
|
+
} catch {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (!Number.isFinite(amount) || amount <= 0) continue;
|
|
204
|
+
pending.push({
|
|
205
|
+
chainId: e.chainId,
|
|
206
|
+
asset: e.tokenSymbol,
|
|
207
|
+
amount: String(amount),
|
|
208
|
+
...typeof e.updatedAt === "string" && e.updatedAt !== "" ? { since: e.updatedAt } : {}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return pending.length > 0 ? pending : void 0;
|
|
212
|
+
}
|
|
187
213
|
function mapBalances(raw, _chainId, smartWallet) {
|
|
188
214
|
const portfolio = raw.portfolio;
|
|
189
215
|
const portfolioByChain = portfolio.portfolioByChain ?? {};
|
|
@@ -235,12 +261,16 @@ function mapBalances(raw, _chainId, smartWallet) {
|
|
|
235
261
|
// structural read keeps it undefined today and auto-populates later.
|
|
236
262
|
liquidity: p.liquidity
|
|
237
263
|
}));
|
|
264
|
+
const pendingAllocations = mapPendingAllocations(
|
|
265
|
+
portfolio.staleBalances
|
|
266
|
+
);
|
|
238
267
|
return {
|
|
239
268
|
smartWallet,
|
|
240
269
|
totalBalance: String(totalBalance),
|
|
241
270
|
totalBalanceAsset: "usdc",
|
|
242
271
|
tokens,
|
|
243
|
-
positions
|
|
272
|
+
positions,
|
|
273
|
+
...pendingAllocations ? { pendingAllocations } : {}
|
|
244
274
|
};
|
|
245
275
|
}
|
|
246
276
|
function sumTokenValues(tokens) {
|