@owney/sdk 0.7.28-beta.6 → 0.7.28-beta.7
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 +95 -37
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +95 -37
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1470,9 +1470,22 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1470
1470
|
this.sdk.getUserDetails(asset),
|
|
1471
1471
|
this.sdk.getAvailableProtocols(chainId)
|
|
1472
1472
|
]);
|
|
1473
|
+
debugLog("zyfai:protocol-sync", `${asset}: profile before sync`, {
|
|
1474
|
+
chains: current.chains,
|
|
1475
|
+
protocols: current.protocols,
|
|
1476
|
+
strategy: current.strategy
|
|
1477
|
+
});
|
|
1478
|
+
if ((current.chains?.length ?? 0) === 0 && (current.protocols?.length ?? 0) === 0) {
|
|
1479
|
+
debugLog(
|
|
1480
|
+
"zyfai:protocol-sync",
|
|
1481
|
+
`${asset}: skipping untouched profile until first deposit`
|
|
1482
|
+
);
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1473
1485
|
const update = buildProtocolMergeUpdate(available, current, asset);
|
|
1474
1486
|
if (!update) return;
|
|
1475
1487
|
await this.sdk.updateUserProfile(update);
|
|
1488
|
+
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
1476
1489
|
} catch (error) {
|
|
1477
1490
|
console.warn(
|
|
1478
1491
|
"[zyfai] ensureProtocolsSynced failed (non-fatal):",
|
|
@@ -1514,6 +1527,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1514
1527
|
// --- IAgent: Account lifecycle ---
|
|
1515
1528
|
async activateAgent(state, chainId) {
|
|
1516
1529
|
try {
|
|
1530
|
+
debugLog("zyfai:activation", "starting", {
|
|
1531
|
+
walletAddress: state.walletAddress,
|
|
1532
|
+
chainId
|
|
1533
|
+
});
|
|
1517
1534
|
await this.connectAuth(state, chainId);
|
|
1518
1535
|
const validChainId = isValidChainId(chainId);
|
|
1519
1536
|
await Promise.all([
|
|
@@ -1525,6 +1542,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1525
1542
|
// validator, so pool-wallet users see no prompt. Non-fatal.
|
|
1526
1543
|
this.ensureSessionKeyIfDeployed(validChainId)
|
|
1527
1544
|
]);
|
|
1545
|
+
debugLog("zyfai:activation", "completed", { chainId: validChainId });
|
|
1528
1546
|
} catch (error) {
|
|
1529
1547
|
throw error;
|
|
1530
1548
|
}
|
|
@@ -1607,6 +1625,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1607
1625
|
*/
|
|
1608
1626
|
async applyPoolPolicy(policy, opts = {}) {
|
|
1609
1627
|
try {
|
|
1628
|
+
await this.sdk.ensureFirstDepositSetup("aggressive");
|
|
1610
1629
|
const { protocols: universe } = await this.sdk.getAvailableProtocols(
|
|
1611
1630
|
this.supportedChainIds[0]
|
|
1612
1631
|
);
|
|
@@ -1737,9 +1756,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1737
1756
|
* Persist an explicitly saved deposit-time draft at Zyfai profile level.
|
|
1738
1757
|
* Pool choices are merged into protocol/chain records and each active asset
|
|
1739
1758
|
* is kept at aggressive unless the draft includes a yieldmaxxing-only pool.
|
|
1759
|
+
* The whole operation must succeed before the caller starts moving funds.
|
|
1740
1760
|
*/
|
|
1741
1761
|
async setPoolSelection(selection) {
|
|
1742
1762
|
try {
|
|
1763
|
+
await this.sdk.ensureFirstDepositSetup("aggressive");
|
|
1743
1764
|
const byPair = /* @__PURE__ */ new Map();
|
|
1744
1765
|
for (const entry of selection.selections) {
|
|
1745
1766
|
const pair = `${entry.protocolId}:${entry.chainId}`;
|
|
@@ -1747,39 +1768,31 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1747
1768
|
group.push(entry);
|
|
1748
1769
|
byPair.set(pair, group);
|
|
1749
1770
|
}
|
|
1750
|
-
const customizations =
|
|
1771
|
+
const customizations = await Promise.all(
|
|
1751
1772
|
[...byPair.values()].map(async (scoped) => {
|
|
1752
1773
|
const { protocolId, chainId } = scoped[0];
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
};
|
|
1774
|
-
} catch (error) {
|
|
1775
|
-
console.warn(
|
|
1776
|
-
`[zyfai] setPoolSelection: preserving ${protocolId}/${chainId} failed; skipping the pair:`,
|
|
1777
|
-
error instanceof Error ? error.message : String(error)
|
|
1778
|
-
);
|
|
1779
|
-
return null;
|
|
1780
|
-
}
|
|
1774
|
+
const [current, rawAvailable] = await Promise.all([
|
|
1775
|
+
this.sdk.getSelectedPools(protocolId, chainId),
|
|
1776
|
+
this.sdk.getAvailablePools(protocolId, "yieldmaxxing")
|
|
1777
|
+
]);
|
|
1778
|
+
const allAvailableNames = mapAvailablePools(rawAvailable).filter((pool) => pool.chainId === chainId).map((pool) => pool.name);
|
|
1779
|
+
return {
|
|
1780
|
+
protocolId,
|
|
1781
|
+
chainId,
|
|
1782
|
+
pools: mergeScopedPoolNames(
|
|
1783
|
+
{
|
|
1784
|
+
pools: current.pools ?? [],
|
|
1785
|
+
autoselect: current.autoselect
|
|
1786
|
+
},
|
|
1787
|
+
scoped,
|
|
1788
|
+
allAvailableNames
|
|
1789
|
+
),
|
|
1790
|
+
// An explicit Save freezes exactly the choices the user saw.
|
|
1791
|
+
// This also lets an empty list disable the pair deliberately.
|
|
1792
|
+
autoselect: false
|
|
1793
|
+
};
|
|
1781
1794
|
})
|
|
1782
|
-
)
|
|
1795
|
+
);
|
|
1783
1796
|
if (customizations.length > 0) {
|
|
1784
1797
|
await this.sdk.customizeBatch(customizations);
|
|
1785
1798
|
}
|
|
@@ -1797,9 +1810,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1797
1810
|
);
|
|
1798
1811
|
} catch (error) {
|
|
1799
1812
|
console.warn(
|
|
1800
|
-
"[zyfai] setPoolSelection failed
|
|
1813
|
+
"[zyfai] setPoolSelection failed:",
|
|
1801
1814
|
error instanceof Error ? error.message : String(error)
|
|
1802
1815
|
);
|
|
1816
|
+
throw error;
|
|
1803
1817
|
}
|
|
1804
1818
|
}
|
|
1805
1819
|
/**
|
|
@@ -1808,17 +1822,18 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1808
1822
|
* pairs and assets asked about. A pair still on autoselect, or one whose
|
|
1809
1823
|
* lookup fails, is left out so the caller falls back to its default for it.
|
|
1810
1824
|
*/
|
|
1811
|
-
async getPoolSelection(params) {
|
|
1825
|
+
async getPoolSelection(state, chainId, params) {
|
|
1826
|
+
await this.connectAuth(state, chainId);
|
|
1812
1827
|
const [pairs, strategies] = await Promise.all([
|
|
1813
1828
|
Promise.all(
|
|
1814
|
-
params.pairs.map(async ({ protocolId, chainId }) => {
|
|
1829
|
+
params.pairs.map(async ({ protocolId, chainId: chainId2 }) => {
|
|
1815
1830
|
try {
|
|
1816
1831
|
const current = await this.sdk.getSelectedPools(
|
|
1817
1832
|
protocolId,
|
|
1818
|
-
|
|
1833
|
+
chainId2
|
|
1819
1834
|
);
|
|
1820
1835
|
if (current.autoselect) return null;
|
|
1821
|
-
return { protocolId, chainId, pools: current.pools ?? [] };
|
|
1836
|
+
return { protocolId, chainId: chainId2, pools: current.pools ?? [] };
|
|
1822
1837
|
} catch {
|
|
1823
1838
|
return null;
|
|
1824
1839
|
}
|
|
@@ -2135,6 +2150,33 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2135
2150
|
const validChainId = isValidChainId(chainId);
|
|
2136
2151
|
await this.ensureConnected(state, validChainId);
|
|
2137
2152
|
if (depositCallback) {
|
|
2153
|
+
debugLog("zyfai:first-deposit", "starting sponsored deposit setup", {
|
|
2154
|
+
asset,
|
|
2155
|
+
chainId: validChainId,
|
|
2156
|
+
requestedStrategy: "aggressive"
|
|
2157
|
+
});
|
|
2158
|
+
const setupResult = await this.sdk.ensureFirstDepositSetup("aggressive");
|
|
2159
|
+
debugLog("zyfai:first-deposit", "setup call completed", {
|
|
2160
|
+
requestedStrategy: "aggressive",
|
|
2161
|
+
setupResult
|
|
2162
|
+
});
|
|
2163
|
+
if (isOwneyDebug()) {
|
|
2164
|
+
try {
|
|
2165
|
+
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
2166
|
+
asset === "WETH" ? "WETH" : "USDC"
|
|
2167
|
+
);
|
|
2168
|
+
debugLog("zyfai:first-deposit", "profile immediately after setup", {
|
|
2169
|
+
asset,
|
|
2170
|
+
strategy: profileAfterSetup.strategy,
|
|
2171
|
+
chains: profileAfterSetup.chains,
|
|
2172
|
+
protocols: profileAfterSetup.protocols
|
|
2173
|
+
});
|
|
2174
|
+
} catch (debugError) {
|
|
2175
|
+
debugLog("zyfai:first-deposit", "post-setup profile read failed", {
|
|
2176
|
+
error: debugError instanceof Error ? debugError.message : String(debugError)
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2138
2180
|
const smartWallet = await this.ensureWalletDeployed(
|
|
2139
2181
|
this.getAddress(),
|
|
2140
2182
|
validChainId
|
|
@@ -2152,7 +2194,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2152
2194
|
return { txHash, smartWallet, amount };
|
|
2153
2195
|
}
|
|
2154
2196
|
await this.ensureWalletDeployed(this.getAddress(), validChainId);
|
|
2155
|
-
const raw = await this.sdk.
|
|
2197
|
+
const raw = await this.sdk.sendDeposit(
|
|
2156
2198
|
this.getAddress(),
|
|
2157
2199
|
validChainId,
|
|
2158
2200
|
amount,
|
|
@@ -2349,6 +2391,19 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2349
2391
|
async ensureAutoSelectProtocols(state, chainId, asset) {
|
|
2350
2392
|
await this.connectAuth(state, chainId);
|
|
2351
2393
|
const current = await this.sdk.getUserDetails(asset);
|
|
2394
|
+
debugLog("zyfai:auto-select", `${asset}: profile before check`, {
|
|
2395
|
+
autoSelectProtocols: current.autoSelectProtocols,
|
|
2396
|
+
chains: current.chains,
|
|
2397
|
+
protocols: current.protocols,
|
|
2398
|
+
strategy: current.strategy
|
|
2399
|
+
});
|
|
2400
|
+
if ((current.chains?.length ?? 0) === 0) {
|
|
2401
|
+
debugLog(
|
|
2402
|
+
"zyfai:auto-select",
|
|
2403
|
+
`${asset}: skipping untouched profile until first deposit`
|
|
2404
|
+
);
|
|
2405
|
+
return false;
|
|
2406
|
+
}
|
|
2352
2407
|
const update = buildAutoSelectUpdate(
|
|
2353
2408
|
{
|
|
2354
2409
|
autoSelectProtocols: current.autoSelectProtocols,
|
|
@@ -2359,6 +2414,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2359
2414
|
);
|
|
2360
2415
|
if (!update) return false;
|
|
2361
2416
|
await this.sdk.updateUserProfile(update);
|
|
2417
|
+
debugLog("zyfai:auto-select", `${asset}: wrote profile update`, update);
|
|
2362
2418
|
return true;
|
|
2363
2419
|
}
|
|
2364
2420
|
// --- IAgent: Discovery (no wallet required) ---
|
|
@@ -6804,6 +6860,8 @@ var OwneySDK = class {
|
|
|
6804
6860
|
* `assets` say which protocol/chain lists and strategies to read.
|
|
6805
6861
|
*/
|
|
6806
6862
|
async getPoolSelection(params) {
|
|
6863
|
+
const state = this.requireState();
|
|
6864
|
+
const chainId = this.requireChainId();
|
|
6807
6865
|
await this.ensureAgentsInitialized();
|
|
6808
6866
|
const agent = this.getAgent(params.agentId ?? "zyfai");
|
|
6809
6867
|
if (!agent.getPoolSelection) {
|
|
@@ -6812,7 +6870,7 @@ var OwneySDK = class {
|
|
|
6812
6870
|
`Agent ${agent.id} does not support pool customization`
|
|
6813
6871
|
);
|
|
6814
6872
|
}
|
|
6815
|
-
return agent.getPoolSelection({
|
|
6873
|
+
return agent.getPoolSelection(state, chainId, {
|
|
6816
6874
|
pairs: params.pairs,
|
|
6817
6875
|
assets: params.assets
|
|
6818
6876
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -949,7 +949,7 @@ interface IAgent {
|
|
|
949
949
|
* Read back what `setPoolSelection` saved, for the pairs and assets given,
|
|
950
950
|
* so the Pools step can open on the user's own choices. Optional. (ROUT-650)
|
|
951
951
|
*/
|
|
952
|
-
getPoolSelection?(params: {
|
|
952
|
+
getPoolSelection?(state: ConnectionState, chainId: number, params: {
|
|
953
953
|
pairs: Array<{
|
|
954
954
|
protocolId: string;
|
|
955
955
|
chainId: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -949,7 +949,7 @@ interface IAgent {
|
|
|
949
949
|
* Read back what `setPoolSelection` saved, for the pairs and assets given,
|
|
950
950
|
* so the Pools step can open on the user's own choices. Optional. (ROUT-650)
|
|
951
951
|
*/
|
|
952
|
-
getPoolSelection?(params: {
|
|
952
|
+
getPoolSelection?(state: ConnectionState, chainId: number, params: {
|
|
953
953
|
pairs: Array<{
|
|
954
954
|
protocolId: string;
|
|
955
955
|
chainId: number;
|
package/dist/index.js
CHANGED
|
@@ -1430,9 +1430,22 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1430
1430
|
this.sdk.getUserDetails(asset),
|
|
1431
1431
|
this.sdk.getAvailableProtocols(chainId)
|
|
1432
1432
|
]);
|
|
1433
|
+
debugLog("zyfai:protocol-sync", `${asset}: profile before sync`, {
|
|
1434
|
+
chains: current.chains,
|
|
1435
|
+
protocols: current.protocols,
|
|
1436
|
+
strategy: current.strategy
|
|
1437
|
+
});
|
|
1438
|
+
if ((current.chains?.length ?? 0) === 0 && (current.protocols?.length ?? 0) === 0) {
|
|
1439
|
+
debugLog(
|
|
1440
|
+
"zyfai:protocol-sync",
|
|
1441
|
+
`${asset}: skipping untouched profile until first deposit`
|
|
1442
|
+
);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1433
1445
|
const update = buildProtocolMergeUpdate(available, current, asset);
|
|
1434
1446
|
if (!update) return;
|
|
1435
1447
|
await this.sdk.updateUserProfile(update);
|
|
1448
|
+
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
1436
1449
|
} catch (error) {
|
|
1437
1450
|
console.warn(
|
|
1438
1451
|
"[zyfai] ensureProtocolsSynced failed (non-fatal):",
|
|
@@ -1474,6 +1487,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1474
1487
|
// --- IAgent: Account lifecycle ---
|
|
1475
1488
|
async activateAgent(state, chainId) {
|
|
1476
1489
|
try {
|
|
1490
|
+
debugLog("zyfai:activation", "starting", {
|
|
1491
|
+
walletAddress: state.walletAddress,
|
|
1492
|
+
chainId
|
|
1493
|
+
});
|
|
1477
1494
|
await this.connectAuth(state, chainId);
|
|
1478
1495
|
const validChainId = isValidChainId(chainId);
|
|
1479
1496
|
await Promise.all([
|
|
@@ -1485,6 +1502,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1485
1502
|
// validator, so pool-wallet users see no prompt. Non-fatal.
|
|
1486
1503
|
this.ensureSessionKeyIfDeployed(validChainId)
|
|
1487
1504
|
]);
|
|
1505
|
+
debugLog("zyfai:activation", "completed", { chainId: validChainId });
|
|
1488
1506
|
} catch (error) {
|
|
1489
1507
|
throw error;
|
|
1490
1508
|
}
|
|
@@ -1567,6 +1585,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1567
1585
|
*/
|
|
1568
1586
|
async applyPoolPolicy(policy, opts = {}) {
|
|
1569
1587
|
try {
|
|
1588
|
+
await this.sdk.ensureFirstDepositSetup("aggressive");
|
|
1570
1589
|
const { protocols: universe } = await this.sdk.getAvailableProtocols(
|
|
1571
1590
|
this.supportedChainIds[0]
|
|
1572
1591
|
);
|
|
@@ -1697,9 +1716,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1697
1716
|
* Persist an explicitly saved deposit-time draft at Zyfai profile level.
|
|
1698
1717
|
* Pool choices are merged into protocol/chain records and each active asset
|
|
1699
1718
|
* is kept at aggressive unless the draft includes a yieldmaxxing-only pool.
|
|
1719
|
+
* The whole operation must succeed before the caller starts moving funds.
|
|
1700
1720
|
*/
|
|
1701
1721
|
async setPoolSelection(selection) {
|
|
1702
1722
|
try {
|
|
1723
|
+
await this.sdk.ensureFirstDepositSetup("aggressive");
|
|
1703
1724
|
const byPair = /* @__PURE__ */ new Map();
|
|
1704
1725
|
for (const entry of selection.selections) {
|
|
1705
1726
|
const pair = `${entry.protocolId}:${entry.chainId}`;
|
|
@@ -1707,39 +1728,31 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1707
1728
|
group.push(entry);
|
|
1708
1729
|
byPair.set(pair, group);
|
|
1709
1730
|
}
|
|
1710
|
-
const customizations =
|
|
1731
|
+
const customizations = await Promise.all(
|
|
1711
1732
|
[...byPair.values()].map(async (scoped) => {
|
|
1712
1733
|
const { protocolId, chainId } = scoped[0];
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
};
|
|
1734
|
-
} catch (error) {
|
|
1735
|
-
console.warn(
|
|
1736
|
-
`[zyfai] setPoolSelection: preserving ${protocolId}/${chainId} failed; skipping the pair:`,
|
|
1737
|
-
error instanceof Error ? error.message : String(error)
|
|
1738
|
-
);
|
|
1739
|
-
return null;
|
|
1740
|
-
}
|
|
1734
|
+
const [current, rawAvailable] = await Promise.all([
|
|
1735
|
+
this.sdk.getSelectedPools(protocolId, chainId),
|
|
1736
|
+
this.sdk.getAvailablePools(protocolId, "yieldmaxxing")
|
|
1737
|
+
]);
|
|
1738
|
+
const allAvailableNames = mapAvailablePools(rawAvailable).filter((pool) => pool.chainId === chainId).map((pool) => pool.name);
|
|
1739
|
+
return {
|
|
1740
|
+
protocolId,
|
|
1741
|
+
chainId,
|
|
1742
|
+
pools: mergeScopedPoolNames(
|
|
1743
|
+
{
|
|
1744
|
+
pools: current.pools ?? [],
|
|
1745
|
+
autoselect: current.autoselect
|
|
1746
|
+
},
|
|
1747
|
+
scoped,
|
|
1748
|
+
allAvailableNames
|
|
1749
|
+
),
|
|
1750
|
+
// An explicit Save freezes exactly the choices the user saw.
|
|
1751
|
+
// This also lets an empty list disable the pair deliberately.
|
|
1752
|
+
autoselect: false
|
|
1753
|
+
};
|
|
1741
1754
|
})
|
|
1742
|
-
)
|
|
1755
|
+
);
|
|
1743
1756
|
if (customizations.length > 0) {
|
|
1744
1757
|
await this.sdk.customizeBatch(customizations);
|
|
1745
1758
|
}
|
|
@@ -1757,9 +1770,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1757
1770
|
);
|
|
1758
1771
|
} catch (error) {
|
|
1759
1772
|
console.warn(
|
|
1760
|
-
"[zyfai] setPoolSelection failed
|
|
1773
|
+
"[zyfai] setPoolSelection failed:",
|
|
1761
1774
|
error instanceof Error ? error.message : String(error)
|
|
1762
1775
|
);
|
|
1776
|
+
throw error;
|
|
1763
1777
|
}
|
|
1764
1778
|
}
|
|
1765
1779
|
/**
|
|
@@ -1768,17 +1782,18 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1768
1782
|
* pairs and assets asked about. A pair still on autoselect, or one whose
|
|
1769
1783
|
* lookup fails, is left out so the caller falls back to its default for it.
|
|
1770
1784
|
*/
|
|
1771
|
-
async getPoolSelection(params) {
|
|
1785
|
+
async getPoolSelection(state, chainId, params) {
|
|
1786
|
+
await this.connectAuth(state, chainId);
|
|
1772
1787
|
const [pairs, strategies] = await Promise.all([
|
|
1773
1788
|
Promise.all(
|
|
1774
|
-
params.pairs.map(async ({ protocolId, chainId }) => {
|
|
1789
|
+
params.pairs.map(async ({ protocolId, chainId: chainId2 }) => {
|
|
1775
1790
|
try {
|
|
1776
1791
|
const current = await this.sdk.getSelectedPools(
|
|
1777
1792
|
protocolId,
|
|
1778
|
-
|
|
1793
|
+
chainId2
|
|
1779
1794
|
);
|
|
1780
1795
|
if (current.autoselect) return null;
|
|
1781
|
-
return { protocolId, chainId, pools: current.pools ?? [] };
|
|
1796
|
+
return { protocolId, chainId: chainId2, pools: current.pools ?? [] };
|
|
1782
1797
|
} catch {
|
|
1783
1798
|
return null;
|
|
1784
1799
|
}
|
|
@@ -2095,6 +2110,33 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2095
2110
|
const validChainId = isValidChainId(chainId);
|
|
2096
2111
|
await this.ensureConnected(state, validChainId);
|
|
2097
2112
|
if (depositCallback) {
|
|
2113
|
+
debugLog("zyfai:first-deposit", "starting sponsored deposit setup", {
|
|
2114
|
+
asset,
|
|
2115
|
+
chainId: validChainId,
|
|
2116
|
+
requestedStrategy: "aggressive"
|
|
2117
|
+
});
|
|
2118
|
+
const setupResult = await this.sdk.ensureFirstDepositSetup("aggressive");
|
|
2119
|
+
debugLog("zyfai:first-deposit", "setup call completed", {
|
|
2120
|
+
requestedStrategy: "aggressive",
|
|
2121
|
+
setupResult
|
|
2122
|
+
});
|
|
2123
|
+
if (isOwneyDebug()) {
|
|
2124
|
+
try {
|
|
2125
|
+
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
2126
|
+
asset === "WETH" ? "WETH" : "USDC"
|
|
2127
|
+
);
|
|
2128
|
+
debugLog("zyfai:first-deposit", "profile immediately after setup", {
|
|
2129
|
+
asset,
|
|
2130
|
+
strategy: profileAfterSetup.strategy,
|
|
2131
|
+
chains: profileAfterSetup.chains,
|
|
2132
|
+
protocols: profileAfterSetup.protocols
|
|
2133
|
+
});
|
|
2134
|
+
} catch (debugError) {
|
|
2135
|
+
debugLog("zyfai:first-deposit", "post-setup profile read failed", {
|
|
2136
|
+
error: debugError instanceof Error ? debugError.message : String(debugError)
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2098
2140
|
const smartWallet = await this.ensureWalletDeployed(
|
|
2099
2141
|
this.getAddress(),
|
|
2100
2142
|
validChainId
|
|
@@ -2112,7 +2154,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2112
2154
|
return { txHash, smartWallet, amount };
|
|
2113
2155
|
}
|
|
2114
2156
|
await this.ensureWalletDeployed(this.getAddress(), validChainId);
|
|
2115
|
-
const raw = await this.sdk.
|
|
2157
|
+
const raw = await this.sdk.sendDeposit(
|
|
2116
2158
|
this.getAddress(),
|
|
2117
2159
|
validChainId,
|
|
2118
2160
|
amount,
|
|
@@ -2309,6 +2351,19 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2309
2351
|
async ensureAutoSelectProtocols(state, chainId, asset) {
|
|
2310
2352
|
await this.connectAuth(state, chainId);
|
|
2311
2353
|
const current = await this.sdk.getUserDetails(asset);
|
|
2354
|
+
debugLog("zyfai:auto-select", `${asset}: profile before check`, {
|
|
2355
|
+
autoSelectProtocols: current.autoSelectProtocols,
|
|
2356
|
+
chains: current.chains,
|
|
2357
|
+
protocols: current.protocols,
|
|
2358
|
+
strategy: current.strategy
|
|
2359
|
+
});
|
|
2360
|
+
if ((current.chains?.length ?? 0) === 0) {
|
|
2361
|
+
debugLog(
|
|
2362
|
+
"zyfai:auto-select",
|
|
2363
|
+
`${asset}: skipping untouched profile until first deposit`
|
|
2364
|
+
);
|
|
2365
|
+
return false;
|
|
2366
|
+
}
|
|
2312
2367
|
const update = buildAutoSelectUpdate(
|
|
2313
2368
|
{
|
|
2314
2369
|
autoSelectProtocols: current.autoSelectProtocols,
|
|
@@ -2319,6 +2374,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2319
2374
|
);
|
|
2320
2375
|
if (!update) return false;
|
|
2321
2376
|
await this.sdk.updateUserProfile(update);
|
|
2377
|
+
debugLog("zyfai:auto-select", `${asset}: wrote profile update`, update);
|
|
2322
2378
|
return true;
|
|
2323
2379
|
}
|
|
2324
2380
|
// --- IAgent: Discovery (no wallet required) ---
|
|
@@ -6785,6 +6841,8 @@ var OwneySDK = class {
|
|
|
6785
6841
|
* `assets` say which protocol/chain lists and strategies to read.
|
|
6786
6842
|
*/
|
|
6787
6843
|
async getPoolSelection(params) {
|
|
6844
|
+
const state = this.requireState();
|
|
6845
|
+
const chainId = this.requireChainId();
|
|
6788
6846
|
await this.ensureAgentsInitialized();
|
|
6789
6847
|
const agent = this.getAgent(params.agentId ?? "zyfai");
|
|
6790
6848
|
if (!agent.getPoolSelection) {
|
|
@@ -6793,7 +6851,7 @@ var OwneySDK = class {
|
|
|
6793
6851
|
`Agent ${agent.id} does not support pool customization`
|
|
6794
6852
|
);
|
|
6795
6853
|
}
|
|
6796
|
-
return agent.getPoolSelection({
|
|
6854
|
+
return agent.getPoolSelection(state, chainId, {
|
|
6797
6855
|
pairs: params.pairs,
|
|
6798
6856
|
assets: params.assets
|
|
6799
6857
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owney/sdk",
|
|
3
|
-
"version": "0.7.28-beta.
|
|
3
|
+
"version": "0.7.28-beta.7",
|
|
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.11.2",
|
|
27
27
|
"siwe": "^3.0.0",
|
|
28
28
|
"viem": "^2.48.1"
|
|
29
29
|
},
|