@owney/sdk 0.3.0-beta.0 → 0.3.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 +12 -0
- package/dist/index.cjs +72 -4
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +72 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -280,12 +280,18 @@ console.log(apy.walletAddress); // "0x..."
|
|
|
280
280
|
console.log(apy.weightedApyAfterFee); // 5.2
|
|
281
281
|
// Per chain + token breakdown, when the agent reports it
|
|
282
282
|
console.log(apy.weightedApyAfterFeeDetails?.apyPerAsset[8453]?.USDC); // 5.4
|
|
283
|
+
// Same per-(chain, asset) breakdown surfaced under a unified key
|
|
284
|
+
console.log(apy.apyByChainAndAsset?.[8453]?.USDC); // 5.4
|
|
283
285
|
|
|
284
286
|
// All agents (balance-weighted)
|
|
285
287
|
const allApy = await sdk.getAccountApy({ days: "30D" });
|
|
286
288
|
console.log(allApy.totalApy); // "5.6"
|
|
287
289
|
console.log(allApy.agentApy.zyfai.weightedApyAfterFee); // 6.0
|
|
288
290
|
console.log(allApy.agentApy.sail.weightedApyAfterFee); // 4.0
|
|
291
|
+
// Per (chain, asset), balance-weighted across all agents.
|
|
292
|
+
// Cells with 0/missing APY for a given agent are excluded from that cell.
|
|
293
|
+
console.log(allApy.apyByChainAndAsset[8453]?.USDC); // 5.3
|
|
294
|
+
console.log(allApy.apyByChainAndAsset[42161]?.USDT); // 4.7
|
|
289
295
|
```
|
|
290
296
|
|
|
291
297
|
### `getHistory({ agentId?, filters? })`
|
|
@@ -560,15 +566,21 @@ interface OwneyEarnings {
|
|
|
560
566
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
561
567
|
}
|
|
562
568
|
|
|
569
|
+
type ApyByChainAndAsset = Partial<
|
|
570
|
+
Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>
|
|
571
|
+
>;
|
|
572
|
+
|
|
563
573
|
interface AccountAgentApy {
|
|
564
574
|
walletAddress: string;
|
|
565
575
|
weightedApyAfterFee?: number;
|
|
566
576
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
577
|
+
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
567
578
|
}
|
|
568
579
|
|
|
569
580
|
interface OwneyAccountApy {
|
|
570
581
|
totalApy: string;
|
|
571
582
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
583
|
+
apyByChainAndAsset: ApyByChainAndAsset;
|
|
572
584
|
}
|
|
573
585
|
|
|
574
586
|
type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
|
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ var P_SUPPORTED_CHAINS = {
|
|
|
36
36
|
chainIds: [8453, 42161],
|
|
37
37
|
chains: ["BASE", "ARBITRUM"]
|
|
38
38
|
};
|
|
39
|
+
var SUPPORTED_TOKENS = ["USDC", "USDT"];
|
|
39
40
|
var SUPPORTED_CHAIN_IDS = P_SUPPORTED_CHAINS.chainIds;
|
|
40
41
|
var SUPPORTED_CHAINS = P_SUPPORTED_CHAINS.chains;
|
|
41
42
|
var SupportedAssets = [
|
|
@@ -209,16 +210,38 @@ function mapEarnings(raw, smartWallet) {
|
|
|
209
210
|
tokens
|
|
210
211
|
};
|
|
211
212
|
}
|
|
213
|
+
function mapWeightedApyByChain(raw) {
|
|
214
|
+
if (!raw)
|
|
215
|
+
return void 0;
|
|
216
|
+
const out = {};
|
|
217
|
+
for (const [chainKey, tokenApy] of Object.entries(raw)) {
|
|
218
|
+
const chainId = Number(chainKey);
|
|
219
|
+
if (!SUPPORTED_CHAIN_IDS.includes(chainId))
|
|
220
|
+
continue;
|
|
221
|
+
const perAsset = {};
|
|
222
|
+
for (const [symbol, apy] of Object.entries(tokenApy)) {
|
|
223
|
+
const token = symbol;
|
|
224
|
+
if (!SUPPORTED_TOKENS.includes(token))
|
|
225
|
+
continue;
|
|
226
|
+
perAsset[token] = apy;
|
|
227
|
+
}
|
|
228
|
+
if (Object.keys(perAsset).length > 0)
|
|
229
|
+
out[chainId] = perAsset;
|
|
230
|
+
}
|
|
231
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
232
|
+
}
|
|
212
233
|
function mapApyHistory(raw) {
|
|
213
234
|
return {
|
|
214
235
|
walletAddress: raw.walletAddress,
|
|
215
|
-
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0
|
|
236
|
+
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
|
|
237
|
+
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
216
238
|
};
|
|
217
239
|
}
|
|
218
240
|
function mapHistory(raw, chainId) {
|
|
219
241
|
const actionMap = {
|
|
220
242
|
"Deposit to protocol": "Deposit",
|
|
221
243
|
"Top up wallet": "Top up",
|
|
244
|
+
"Partial withdraw from protocol": "Withdraw",
|
|
222
245
|
"Withdraw from protocol": "Withdraw",
|
|
223
246
|
Rebalance: "Rebalance"
|
|
224
247
|
};
|
|
@@ -641,6 +664,46 @@ function sumWithdrawnAmount(results) {
|
|
|
641
664
|
return Object.values(results).reduce((sum, r) => sum + BigInt(r.amount), 0n);
|
|
642
665
|
}
|
|
643
666
|
|
|
667
|
+
// src/lib/helpers/account-apy-helper.ts
|
|
668
|
+
function aggregateApyByChainAndAsset(agentApys, agentBalances) {
|
|
669
|
+
const sums = {};
|
|
670
|
+
const weights = {};
|
|
671
|
+
for (const id of Object.keys(agentApys)) {
|
|
672
|
+
const cells = agentApys[id].apyByChainAndAsset;
|
|
673
|
+
const balance = agentBalances[id] ?? 0;
|
|
674
|
+
if (!cells || balance <= 0)
|
|
675
|
+
continue;
|
|
676
|
+
for (const [chainKey, perAsset] of Object.entries(cells)) {
|
|
677
|
+
if (!perAsset)
|
|
678
|
+
continue;
|
|
679
|
+
const chainId = Number(chainKey);
|
|
680
|
+
for (const [asset, apyValue] of Object.entries(perAsset)) {
|
|
681
|
+
const apy = Number(apyValue ?? 0);
|
|
682
|
+
if (apy === 0)
|
|
683
|
+
continue;
|
|
684
|
+
sums[chainId] ??= {};
|
|
685
|
+
weights[chainId] ??= {};
|
|
686
|
+
sums[chainId][asset] = (sums[chainId][asset] ?? 0) + apy * balance;
|
|
687
|
+
weights[chainId][asset] = (weights[chainId][asset] ?? 0) + balance;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
const out = {};
|
|
692
|
+
for (const chainKey of Object.keys(sums)) {
|
|
693
|
+
const chainId = Number(chainKey);
|
|
694
|
+
const perAssetOut = {};
|
|
695
|
+
for (const asset of Object.keys(sums[chainId])) {
|
|
696
|
+
const w = weights[chainId][asset];
|
|
697
|
+
if (w > 0)
|
|
698
|
+
perAssetOut[asset] = sums[chainId][asset] / w;
|
|
699
|
+
}
|
|
700
|
+
if (Object.keys(perAssetOut).length > 0) {
|
|
701
|
+
out[chainId] = perAssetOut;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return out;
|
|
705
|
+
}
|
|
706
|
+
|
|
644
707
|
// src/client.ts
|
|
645
708
|
var OwneySDK = class {
|
|
646
709
|
agents = /* @__PURE__ */ new Map();
|
|
@@ -1042,7 +1105,10 @@ var OwneySDK = class {
|
|
|
1042
1105
|
{ asset, agentErrors: agentErrors2 }
|
|
1043
1106
|
);
|
|
1044
1107
|
}
|
|
1045
|
-
return {
|
|
1108
|
+
return {
|
|
1109
|
+
agentResult: results2,
|
|
1110
|
+
totalWithdrawn: sumWithdrawnAmount(results2).toString()
|
|
1111
|
+
};
|
|
1046
1112
|
}
|
|
1047
1113
|
const requested = BigInt(amount);
|
|
1048
1114
|
const aggregated = await this.getBalances();
|
|
@@ -1131,7 +1197,7 @@ var OwneySDK = class {
|
|
|
1131
1197
|
}
|
|
1132
1198
|
);
|
|
1133
1199
|
}
|
|
1134
|
-
return { agentResult: results };
|
|
1200
|
+
return { agentResult: results, totalWithdrawn: withdrawn.toString() };
|
|
1135
1201
|
}
|
|
1136
1202
|
// --- Portfolio reads ---
|
|
1137
1203
|
/**
|
|
@@ -1269,9 +1335,11 @@ var OwneySDK = class {
|
|
|
1269
1335
|
totalApy += agentApy * weight;
|
|
1270
1336
|
}
|
|
1271
1337
|
}
|
|
1338
|
+
const apyByChainAndAsset = aggregateApyByChainAndAsset(results, balances);
|
|
1272
1339
|
return {
|
|
1273
1340
|
totalApy: String(totalApy),
|
|
1274
|
-
agentApy: results
|
|
1341
|
+
agentApy: results,
|
|
1342
|
+
apyByChainAndAsset
|
|
1275
1343
|
};
|
|
1276
1344
|
}
|
|
1277
1345
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -114,6 +114,7 @@ interface AgentWithdrawResult {
|
|
|
114
114
|
}
|
|
115
115
|
interface OwneyWithdrawResult {
|
|
116
116
|
agentResult: Record<AgentId, AgentWithdrawResult>;
|
|
117
|
+
totalWithdrawn: string;
|
|
117
118
|
}
|
|
118
119
|
interface OwneyToken {
|
|
119
120
|
chain: OwneySupportedChains;
|
|
@@ -139,14 +140,17 @@ interface OwneyEarnings {
|
|
|
139
140
|
totalEarnings: string;
|
|
140
141
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
141
142
|
}
|
|
143
|
+
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
142
144
|
interface AccountAgentApy {
|
|
143
145
|
walletAddress: string;
|
|
144
146
|
weightedApyAfterFee?: number;
|
|
145
147
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
148
|
+
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
146
149
|
}
|
|
147
150
|
interface OwneyAccountApy {
|
|
148
151
|
totalApy: string;
|
|
149
152
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
153
|
+
apyByChainAndAsset: ApyByChainAndAsset;
|
|
150
154
|
}
|
|
151
155
|
type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
|
|
152
156
|
interface HistoryTransaction {
|
|
@@ -378,4 +382,4 @@ declare class AgentChainIncompatibleError extends OwneyError {
|
|
|
378
382
|
}>, connectedChainId: number);
|
|
379
383
|
}
|
|
380
384
|
|
|
381
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneySDK, OwneySDKConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
|
|
385
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneySDK, OwneySDKConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ interface AgentWithdrawResult {
|
|
|
114
114
|
}
|
|
115
115
|
interface OwneyWithdrawResult {
|
|
116
116
|
agentResult: Record<AgentId, AgentWithdrawResult>;
|
|
117
|
+
totalWithdrawn: string;
|
|
117
118
|
}
|
|
118
119
|
interface OwneyToken {
|
|
119
120
|
chain: OwneySupportedChains;
|
|
@@ -139,14 +140,17 @@ interface OwneyEarnings {
|
|
|
139
140
|
totalEarnings: string;
|
|
140
141
|
agentEarnings: Record<AgentId, AgentEarnings>;
|
|
141
142
|
}
|
|
143
|
+
type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
|
|
142
144
|
interface AccountAgentApy {
|
|
143
145
|
walletAddress: string;
|
|
144
146
|
weightedApyAfterFee?: number;
|
|
145
147
|
weightedApyAfterFeeDetails?: AgentApyDetails;
|
|
148
|
+
apyByChainAndAsset?: ApyByChainAndAsset;
|
|
146
149
|
}
|
|
147
150
|
interface OwneyAccountApy {
|
|
148
151
|
totalApy: string;
|
|
149
152
|
agentApy: Record<AgentId, AccountAgentApy>;
|
|
153
|
+
apyByChainAndAsset: ApyByChainAndAsset;
|
|
150
154
|
}
|
|
151
155
|
type HistoryAction = "Rebalance" | "Deposit" | "Top up" | "Withdraw" | "Earned";
|
|
152
156
|
interface HistoryTransaction {
|
|
@@ -378,4 +382,4 @@ declare class AgentChainIncompatibleError extends OwneyError {
|
|
|
378
382
|
}>, connectedChainId: number);
|
|
379
383
|
}
|
|
380
384
|
|
|
381
|
-
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneySDK, OwneySDKConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
|
|
385
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneySDK, OwneySDKConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var P_SUPPORTED_CHAINS = {
|
|
|
6
6
|
chainIds: [8453, 42161],
|
|
7
7
|
chains: ["BASE", "ARBITRUM"]
|
|
8
8
|
};
|
|
9
|
+
var SUPPORTED_TOKENS = ["USDC", "USDT"];
|
|
9
10
|
var SUPPORTED_CHAIN_IDS = P_SUPPORTED_CHAINS.chainIds;
|
|
10
11
|
var SUPPORTED_CHAINS = P_SUPPORTED_CHAINS.chains;
|
|
11
12
|
var SupportedAssets = [
|
|
@@ -179,16 +180,38 @@ function mapEarnings(raw, smartWallet) {
|
|
|
179
180
|
tokens
|
|
180
181
|
};
|
|
181
182
|
}
|
|
183
|
+
function mapWeightedApyByChain(raw) {
|
|
184
|
+
if (!raw)
|
|
185
|
+
return void 0;
|
|
186
|
+
const out = {};
|
|
187
|
+
for (const [chainKey, tokenApy] of Object.entries(raw)) {
|
|
188
|
+
const chainId = Number(chainKey);
|
|
189
|
+
if (!SUPPORTED_CHAIN_IDS.includes(chainId))
|
|
190
|
+
continue;
|
|
191
|
+
const perAsset = {};
|
|
192
|
+
for (const [symbol, apy] of Object.entries(tokenApy)) {
|
|
193
|
+
const token = symbol;
|
|
194
|
+
if (!SUPPORTED_TOKENS.includes(token))
|
|
195
|
+
continue;
|
|
196
|
+
perAsset[token] = apy;
|
|
197
|
+
}
|
|
198
|
+
if (Object.keys(perAsset).length > 0)
|
|
199
|
+
out[chainId] = perAsset;
|
|
200
|
+
}
|
|
201
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
202
|
+
}
|
|
182
203
|
function mapApyHistory(raw) {
|
|
183
204
|
return {
|
|
184
205
|
walletAddress: raw.walletAddress,
|
|
185
|
-
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0
|
|
206
|
+
weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
|
|
207
|
+
apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
|
|
186
208
|
};
|
|
187
209
|
}
|
|
188
210
|
function mapHistory(raw, chainId) {
|
|
189
211
|
const actionMap = {
|
|
190
212
|
"Deposit to protocol": "Deposit",
|
|
191
213
|
"Top up wallet": "Top up",
|
|
214
|
+
"Partial withdraw from protocol": "Withdraw",
|
|
192
215
|
"Withdraw from protocol": "Withdraw",
|
|
193
216
|
Rebalance: "Rebalance"
|
|
194
217
|
};
|
|
@@ -611,6 +634,46 @@ function sumWithdrawnAmount(results) {
|
|
|
611
634
|
return Object.values(results).reduce((sum, r) => sum + BigInt(r.amount), 0n);
|
|
612
635
|
}
|
|
613
636
|
|
|
637
|
+
// src/lib/helpers/account-apy-helper.ts
|
|
638
|
+
function aggregateApyByChainAndAsset(agentApys, agentBalances) {
|
|
639
|
+
const sums = {};
|
|
640
|
+
const weights = {};
|
|
641
|
+
for (const id of Object.keys(agentApys)) {
|
|
642
|
+
const cells = agentApys[id].apyByChainAndAsset;
|
|
643
|
+
const balance = agentBalances[id] ?? 0;
|
|
644
|
+
if (!cells || balance <= 0)
|
|
645
|
+
continue;
|
|
646
|
+
for (const [chainKey, perAsset] of Object.entries(cells)) {
|
|
647
|
+
if (!perAsset)
|
|
648
|
+
continue;
|
|
649
|
+
const chainId = Number(chainKey);
|
|
650
|
+
for (const [asset, apyValue] of Object.entries(perAsset)) {
|
|
651
|
+
const apy = Number(apyValue ?? 0);
|
|
652
|
+
if (apy === 0)
|
|
653
|
+
continue;
|
|
654
|
+
sums[chainId] ??= {};
|
|
655
|
+
weights[chainId] ??= {};
|
|
656
|
+
sums[chainId][asset] = (sums[chainId][asset] ?? 0) + apy * balance;
|
|
657
|
+
weights[chainId][asset] = (weights[chainId][asset] ?? 0) + balance;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
const out = {};
|
|
662
|
+
for (const chainKey of Object.keys(sums)) {
|
|
663
|
+
const chainId = Number(chainKey);
|
|
664
|
+
const perAssetOut = {};
|
|
665
|
+
for (const asset of Object.keys(sums[chainId])) {
|
|
666
|
+
const w = weights[chainId][asset];
|
|
667
|
+
if (w > 0)
|
|
668
|
+
perAssetOut[asset] = sums[chainId][asset] / w;
|
|
669
|
+
}
|
|
670
|
+
if (Object.keys(perAssetOut).length > 0) {
|
|
671
|
+
out[chainId] = perAssetOut;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return out;
|
|
675
|
+
}
|
|
676
|
+
|
|
614
677
|
// src/client.ts
|
|
615
678
|
var OwneySDK = class {
|
|
616
679
|
agents = /* @__PURE__ */ new Map();
|
|
@@ -1012,7 +1075,10 @@ var OwneySDK = class {
|
|
|
1012
1075
|
{ asset, agentErrors: agentErrors2 }
|
|
1013
1076
|
);
|
|
1014
1077
|
}
|
|
1015
|
-
return {
|
|
1078
|
+
return {
|
|
1079
|
+
agentResult: results2,
|
|
1080
|
+
totalWithdrawn: sumWithdrawnAmount(results2).toString()
|
|
1081
|
+
};
|
|
1016
1082
|
}
|
|
1017
1083
|
const requested = BigInt(amount);
|
|
1018
1084
|
const aggregated = await this.getBalances();
|
|
@@ -1101,7 +1167,7 @@ var OwneySDK = class {
|
|
|
1101
1167
|
}
|
|
1102
1168
|
);
|
|
1103
1169
|
}
|
|
1104
|
-
return { agentResult: results };
|
|
1170
|
+
return { agentResult: results, totalWithdrawn: withdrawn.toString() };
|
|
1105
1171
|
}
|
|
1106
1172
|
// --- Portfolio reads ---
|
|
1107
1173
|
/**
|
|
@@ -1239,9 +1305,11 @@ var OwneySDK = class {
|
|
|
1239
1305
|
totalApy += agentApy * weight;
|
|
1240
1306
|
}
|
|
1241
1307
|
}
|
|
1308
|
+
const apyByChainAndAsset = aggregateApyByChainAndAsset(results, balances);
|
|
1242
1309
|
return {
|
|
1243
1310
|
totalApy: String(totalApy),
|
|
1244
|
-
agentApy: results
|
|
1311
|
+
agentApy: results,
|
|
1312
|
+
apyByChainAndAsset
|
|
1245
1313
|
};
|
|
1246
1314
|
}
|
|
1247
1315
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owney/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test:watch": "vitest"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@zyfai/sdk": "^0.2.
|
|
25
|
+
"@zyfai/sdk": "^0.2.34",
|
|
26
26
|
"viem": "^2.48.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|