@owney/sdk 0.4.3 → 0.4.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/index.cjs +27 -10
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +27 -10
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -240,7 +240,6 @@ function mapApyHistory(raw) {
|
|
|
240
240
|
}
|
|
241
241
|
function mapEntries(rawEntries, chainId) {
|
|
242
242
|
const actionMap = {
|
|
243
|
-
"Deposit to protocol": "Deposit",
|
|
244
243
|
"Top up wallet": "Top up",
|
|
245
244
|
"Partial withdraw from protocol": "Withdraw",
|
|
246
245
|
"Withdraw from protocol": "Withdraw",
|
|
@@ -662,7 +661,7 @@ var ZyfaiAgent = class {
|
|
|
662
661
|
}
|
|
663
662
|
async getEarnings(state, chainId) {
|
|
664
663
|
const { smartWallet } = await this.resolveSmartWallet(state, chainId);
|
|
665
|
-
const raw = await this.sdk.
|
|
664
|
+
const raw = await this.sdk.getOnchainEarnings(smartWallet);
|
|
666
665
|
return mapEarnings(raw, smartWallet);
|
|
667
666
|
}
|
|
668
667
|
async getAccountApy(state, chainId, days) {
|
|
@@ -688,17 +687,24 @@ var ZyfaiAgent = class {
|
|
|
688
687
|
fromDate: options?.fromDate,
|
|
689
688
|
toDate
|
|
690
689
|
});
|
|
691
|
-
|
|
690
|
+
raw.data.forEach((entry, idx) => {
|
|
691
|
+
if (entry.chainId === validChainId && entry.action !== "Deposit to protocol") {
|
|
692
|
+
matched.push({ entry, rawIdx: offset + idx });
|
|
693
|
+
}
|
|
694
|
+
});
|
|
692
695
|
offset += raw.data.length;
|
|
693
696
|
if (raw.data.length < backendPageSize) {
|
|
694
697
|
backendExhausted = true;
|
|
695
698
|
break;
|
|
696
699
|
}
|
|
697
700
|
}
|
|
698
|
-
const
|
|
699
|
-
const
|
|
700
|
-
const hasMore = !backendExhausted ||
|
|
701
|
-
const nextCursor = hasMore ? encodeHistoryCursor({
|
|
701
|
+
const pageData = matched.slice(0, limit).map((m) => m.entry);
|
|
702
|
+
const firstOvershoot = matched[limit];
|
|
703
|
+
const hasMore = !backendExhausted || firstOvershoot !== void 0;
|
|
704
|
+
const nextCursor = hasMore ? encodeHistoryCursor({
|
|
705
|
+
toDate,
|
|
706
|
+
rawOffset: firstOvershoot ? firstOvershoot.rawIdx : offset
|
|
707
|
+
}) : void 0;
|
|
702
708
|
return {
|
|
703
709
|
data: mapEntries(pageData, validChainId),
|
|
704
710
|
hasMore,
|
|
@@ -1677,9 +1683,20 @@ var OwneySDK = class {
|
|
|
1677
1683
|
hasMore = true;
|
|
1678
1684
|
}
|
|
1679
1685
|
}
|
|
1680
|
-
merged.sort(
|
|
1681
|
-
|
|
1682
|
-
|
|
1686
|
+
merged.sort((a, b) => {
|
|
1687
|
+
const dateDiff = new Date(b.date).getTime() - new Date(a.date).getTime();
|
|
1688
|
+
if (dateDiff !== 0)
|
|
1689
|
+
return dateDiff;
|
|
1690
|
+
if (a.agent !== b.agent)
|
|
1691
|
+
return a.agent < b.agent ? -1 : 1;
|
|
1692
|
+
const aTx = a.transactions?.[0]?.txHashes?.[0] ?? "";
|
|
1693
|
+
const bTx = b.transactions?.[0]?.txHashes?.[0] ?? "";
|
|
1694
|
+
if (aTx !== bTx)
|
|
1695
|
+
return aTx < bTx ? -1 : 1;
|
|
1696
|
+
if (a.action !== b.action)
|
|
1697
|
+
return a.action < b.action ? -1 : 1;
|
|
1698
|
+
return 0;
|
|
1699
|
+
});
|
|
1683
1700
|
return {
|
|
1684
1701
|
data: merged,
|
|
1685
1702
|
hasMore,
|
package/dist/index.d.cts
CHANGED
|
@@ -170,6 +170,12 @@ interface RebalanceLog {
|
|
|
170
170
|
amount: string;
|
|
171
171
|
status: "success" | "failed";
|
|
172
172
|
}
|
|
173
|
+
interface AgentHistoryPosition {
|
|
174
|
+
protocol: string;
|
|
175
|
+
pool?: string;
|
|
176
|
+
tokenSymbol?: string;
|
|
177
|
+
amount?: string;
|
|
178
|
+
}
|
|
173
179
|
interface AgentHistoryEntry {
|
|
174
180
|
agent: AgentId;
|
|
175
181
|
action: HistoryAction;
|
|
@@ -178,6 +184,7 @@ interface AgentHistoryEntry {
|
|
|
178
184
|
newApy: string | null;
|
|
179
185
|
transactions: HistoryTransaction[];
|
|
180
186
|
rebalanceLog: RebalanceLog[];
|
|
187
|
+
positions?: AgentHistoryPosition[];
|
|
181
188
|
}
|
|
182
189
|
interface OwneyAgentHistory {
|
|
183
190
|
data: AgentHistoryEntry[];
|
|
@@ -411,4 +418,4 @@ declare class InvalidHistoryCursorError extends Error {
|
|
|
411
418
|
constructor(message: string);
|
|
412
419
|
}
|
|
413
420
|
|
|
414
|
-
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, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneySDK, OwneySDKConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
|
|
421
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, 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
|
@@ -170,6 +170,12 @@ interface RebalanceLog {
|
|
|
170
170
|
amount: string;
|
|
171
171
|
status: "success" | "failed";
|
|
172
172
|
}
|
|
173
|
+
interface AgentHistoryPosition {
|
|
174
|
+
protocol: string;
|
|
175
|
+
pool?: string;
|
|
176
|
+
tokenSymbol?: string;
|
|
177
|
+
amount?: string;
|
|
178
|
+
}
|
|
173
179
|
interface AgentHistoryEntry {
|
|
174
180
|
agent: AgentId;
|
|
175
181
|
action: HistoryAction;
|
|
@@ -178,6 +184,7 @@ interface AgentHistoryEntry {
|
|
|
178
184
|
newApy: string | null;
|
|
179
185
|
transactions: HistoryTransaction[];
|
|
180
186
|
rebalanceLog: RebalanceLog[];
|
|
187
|
+
positions?: AgentHistoryPosition[];
|
|
181
188
|
}
|
|
182
189
|
interface OwneyAgentHistory {
|
|
183
190
|
data: AgentHistoryEntry[];
|
|
@@ -411,4 +418,4 @@ declare class InvalidHistoryCursorError extends Error {
|
|
|
411
418
|
constructor(message: string);
|
|
412
419
|
}
|
|
413
420
|
|
|
414
|
-
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, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAgentStatus, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneySDK, OwneySDKConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions };
|
|
421
|
+
export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, 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
|
@@ -209,7 +209,6 @@ function mapApyHistory(raw) {
|
|
|
209
209
|
}
|
|
210
210
|
function mapEntries(rawEntries, chainId) {
|
|
211
211
|
const actionMap = {
|
|
212
|
-
"Deposit to protocol": "Deposit",
|
|
213
212
|
"Top up wallet": "Top up",
|
|
214
213
|
"Partial withdraw from protocol": "Withdraw",
|
|
215
214
|
"Withdraw from protocol": "Withdraw",
|
|
@@ -631,7 +630,7 @@ var ZyfaiAgent = class {
|
|
|
631
630
|
}
|
|
632
631
|
async getEarnings(state, chainId) {
|
|
633
632
|
const { smartWallet } = await this.resolveSmartWallet(state, chainId);
|
|
634
|
-
const raw = await this.sdk.
|
|
633
|
+
const raw = await this.sdk.getOnchainEarnings(smartWallet);
|
|
635
634
|
return mapEarnings(raw, smartWallet);
|
|
636
635
|
}
|
|
637
636
|
async getAccountApy(state, chainId, days) {
|
|
@@ -657,17 +656,24 @@ var ZyfaiAgent = class {
|
|
|
657
656
|
fromDate: options?.fromDate,
|
|
658
657
|
toDate
|
|
659
658
|
});
|
|
660
|
-
|
|
659
|
+
raw.data.forEach((entry, idx) => {
|
|
660
|
+
if (entry.chainId === validChainId && entry.action !== "Deposit to protocol") {
|
|
661
|
+
matched.push({ entry, rawIdx: offset + idx });
|
|
662
|
+
}
|
|
663
|
+
});
|
|
661
664
|
offset += raw.data.length;
|
|
662
665
|
if (raw.data.length < backendPageSize) {
|
|
663
666
|
backendExhausted = true;
|
|
664
667
|
break;
|
|
665
668
|
}
|
|
666
669
|
}
|
|
667
|
-
const
|
|
668
|
-
const
|
|
669
|
-
const hasMore = !backendExhausted ||
|
|
670
|
-
const nextCursor = hasMore ? encodeHistoryCursor({
|
|
670
|
+
const pageData = matched.slice(0, limit).map((m) => m.entry);
|
|
671
|
+
const firstOvershoot = matched[limit];
|
|
672
|
+
const hasMore = !backendExhausted || firstOvershoot !== void 0;
|
|
673
|
+
const nextCursor = hasMore ? encodeHistoryCursor({
|
|
674
|
+
toDate,
|
|
675
|
+
rawOffset: firstOvershoot ? firstOvershoot.rawIdx : offset
|
|
676
|
+
}) : void 0;
|
|
671
677
|
return {
|
|
672
678
|
data: mapEntries(pageData, validChainId),
|
|
673
679
|
hasMore,
|
|
@@ -1646,9 +1652,20 @@ var OwneySDK = class {
|
|
|
1646
1652
|
hasMore = true;
|
|
1647
1653
|
}
|
|
1648
1654
|
}
|
|
1649
|
-
merged.sort(
|
|
1650
|
-
|
|
1651
|
-
|
|
1655
|
+
merged.sort((a, b) => {
|
|
1656
|
+
const dateDiff = new Date(b.date).getTime() - new Date(a.date).getTime();
|
|
1657
|
+
if (dateDiff !== 0)
|
|
1658
|
+
return dateDiff;
|
|
1659
|
+
if (a.agent !== b.agent)
|
|
1660
|
+
return a.agent < b.agent ? -1 : 1;
|
|
1661
|
+
const aTx = a.transactions?.[0]?.txHashes?.[0] ?? "";
|
|
1662
|
+
const bTx = b.transactions?.[0]?.txHashes?.[0] ?? "";
|
|
1663
|
+
if (aTx !== bTx)
|
|
1664
|
+
return aTx < bTx ? -1 : 1;
|
|
1665
|
+
if (a.action !== b.action)
|
|
1666
|
+
return a.action < b.action ? -1 : 1;
|
|
1667
|
+
return 0;
|
|
1668
|
+
});
|
|
1652
1669
|
return {
|
|
1653
1670
|
data: merged,
|
|
1654
1671
|
hasMore,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owney/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@zyfai/sdk": "^0.2.
|
|
26
|
+
"@zyfai/sdk": "^0.2.36",
|
|
27
27
|
"viem": "^2.48.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
}
|