@zyfai/sdk 1.0.0 → 1.1.0
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 +51 -37
- package/dist/index.d.mts +79 -26
- package/dist/index.d.ts +79 -26
- package/dist/index.js +261 -69
- package/dist/index.mjs +232 -39
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -128,6 +128,9 @@ var ENDPOINTS = {
|
|
|
128
128
|
USER_WITHDRAW: "/users/withdraw/v2",
|
|
129
129
|
PARTIAL_WITHDRAW: "/users/partial-withdraw/v2",
|
|
130
130
|
LOG_DEPOSIT: "/users/log_deposit/v2",
|
|
131
|
+
FIRST_PERMIT_DEPOSIT: "/users/me/permit-deposit",
|
|
132
|
+
FIRST_PERMIT_DEPOSIT_PREPARE: "/users/me/permit-deposit/prepare",
|
|
133
|
+
FIRST_PERMIT_DEPOSIT_SUBMIT: (id) => `/users/me/permit-deposit/${encodeURIComponent(id)}/submit`,
|
|
131
134
|
FUNDING_ORDERS: "/users/me/funding-orders",
|
|
132
135
|
FUNDING_ORDER: (orderId) => `/users/me/funding-orders/${encodeURIComponent(orderId)}`,
|
|
133
136
|
FUNDING_ORDER_QUOTE: (orderId) => `/users/me/funding-orders/${encodeURIComponent(orderId)}/quote`,
|
|
@@ -335,8 +338,9 @@ var HttpClient = class {
|
|
|
335
338
|
case 403:
|
|
336
339
|
throw new Error("Forbidden: Access denied");
|
|
337
340
|
case 404:
|
|
338
|
-
throw
|
|
339
|
-
`Not found: ${data.message || "Resource not found"}`
|
|
341
|
+
throw Object.assign(
|
|
342
|
+
new Error(`Not found: ${data.message || "Resource not found"}`),
|
|
343
|
+
{ status }
|
|
340
344
|
);
|
|
341
345
|
case 429:
|
|
342
346
|
throw new Error("Rate limit exceeded. Please try again later.");
|
|
@@ -459,6 +463,20 @@ var HttpClient = class {
|
|
|
459
463
|
};
|
|
460
464
|
|
|
461
465
|
// src/utils/poll.ts
|
|
466
|
+
async function pollUntil(fn, predicate, options) {
|
|
467
|
+
const intervalMs = options?.intervalMs ?? 5e3;
|
|
468
|
+
const timeoutMs = options?.timeoutMs ?? 12e4;
|
|
469
|
+
const label = options?.label ?? "condition";
|
|
470
|
+
const started = Date.now();
|
|
471
|
+
while (Date.now() - started < timeoutMs) {
|
|
472
|
+
const value = await fn();
|
|
473
|
+
if (predicate(value)) {
|
|
474
|
+
return { value, elapsedMs: Date.now() - started };
|
|
475
|
+
}
|
|
476
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
477
|
+
}
|
|
478
|
+
throw new Error(`Timed out waiting for ${label} after ${timeoutMs}ms`);
|
|
479
|
+
}
|
|
462
480
|
function sleep(ms) {
|
|
463
481
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
464
482
|
}
|
|
@@ -882,7 +900,7 @@ function isMainnetMinPortfolioExempt(chainId, ...addresses) {
|
|
|
882
900
|
|
|
883
901
|
// src/core/ZyfaiSDK.ts
|
|
884
902
|
var import_accounts2 = require("viem/accounts");
|
|
885
|
-
var
|
|
903
|
+
var import_viem6 = require("viem");
|
|
886
904
|
var import_relay_sdk2 = require("@relayprotocol/relay-sdk");
|
|
887
905
|
|
|
888
906
|
// src/config/chains.ts
|
|
@@ -1005,7 +1023,7 @@ var ASSET_CONFIGS = {
|
|
|
1005
1023
|
enabled: true
|
|
1006
1024
|
},
|
|
1007
1025
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
1008
|
-
// protocols with delayed withdrawals — see the `
|
|
1026
|
+
// protocols with delayed withdrawals — see the `yieldmaxxing` strategy.
|
|
1009
1027
|
NVDAc: {
|
|
1010
1028
|
symbol: "NVDAc",
|
|
1011
1029
|
assetType: "nvdac",
|
|
@@ -1198,6 +1216,29 @@ var positiveUnits = (value) => {
|
|
|
1198
1216
|
};
|
|
1199
1217
|
var resolveCollateralMinimum = (storedMinimum, quote) => positiveUnits(storedMinimum) ?? positiveUnits(quote.details?.currencyOut?.minimumAmount) ?? positiveUnits(quote.details?.currencyOut?.amount) ?? "0";
|
|
1200
1218
|
|
|
1219
|
+
// src/deposits/first-permit-deposit.ts
|
|
1220
|
+
var import_viem4 = require("viem");
|
|
1221
|
+
var firstPermitTypes = {
|
|
1222
|
+
Permit: [
|
|
1223
|
+
{ name: "owner", type: "address" },
|
|
1224
|
+
{ name: "spender", type: "address" },
|
|
1225
|
+
{ name: "value", type: "uint256" },
|
|
1226
|
+
{ name: "nonce", type: "uint256" },
|
|
1227
|
+
{ name: "deadline", type: "uint256" }
|
|
1228
|
+
]
|
|
1229
|
+
};
|
|
1230
|
+
function matchesFirstPermitDeposit(intent, request) {
|
|
1231
|
+
return intent.chainId === request.chainId && (0, import_viem4.isAddressEqual)(intent.token, request.token) && intent.amount === request.amount.toString();
|
|
1232
|
+
}
|
|
1233
|
+
function validateFirstPermit({ domain, message }, request) {
|
|
1234
|
+
const value = BigInt(message.value);
|
|
1235
|
+
const nonce = BigInt(message.nonce);
|
|
1236
|
+
if (domain.chainId !== request.chainId || !(0, import_viem4.isAddressEqual)(domain.verifyingContract, request.token) || !(0, import_viem4.isAddressEqual)(message.owner, request.owner) || !(0, import_viem4.isAddressEqual)(message.spender, request.safe) || value !== request.amount || nonce < 0n || !Number.isSafeInteger(message.deadline) || message.deadline <= Math.floor(Date.now() / 1e3)) {
|
|
1237
|
+
throw new Error("Prepared permit does not match this deposit");
|
|
1238
|
+
}
|
|
1239
|
+
return { ...message, value, nonce, deadline: BigInt(message.deadline) };
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1201
1242
|
// src/deposits/relay-slippage.ts
|
|
1202
1243
|
var DEFAULT_RELAY_SLIPPAGE_BPS = 200;
|
|
1203
1244
|
var MAX_RELAY_SLIPPAGE_BPS = 500;
|
|
@@ -1321,7 +1362,7 @@ function getManagedAssets() {
|
|
|
1321
1362
|
// src/utils/safe-account.ts
|
|
1322
1363
|
var import_module_sdk = require("@rhinestone/module-sdk");
|
|
1323
1364
|
var import_accounts = require("permissionless/accounts");
|
|
1324
|
-
var
|
|
1365
|
+
var import_viem5 = require("viem");
|
|
1325
1366
|
var import_account_abstraction = require("viem/account-abstraction");
|
|
1326
1367
|
|
|
1327
1368
|
// src/config/modules.ts
|
|
@@ -1351,12 +1392,12 @@ var getSafeAccount = async (config) => {
|
|
|
1351
1392
|
if (!safeOwnerAddress) {
|
|
1352
1393
|
throw new Error("Safe owner address is required");
|
|
1353
1394
|
}
|
|
1354
|
-
const formattedOwnerAddress = (0,
|
|
1395
|
+
const formattedOwnerAddress = (0, import_viem5.getAddress)(safeOwnerAddress);
|
|
1355
1396
|
const ownableValidator = (0, import_module_sdk.getOwnableValidator)({
|
|
1356
1397
|
owners: [formattedOwnerAddress],
|
|
1357
1398
|
threshold: 1
|
|
1358
1399
|
});
|
|
1359
|
-
const saltHex = (0,
|
|
1400
|
+
const saltHex = (0, import_viem5.fromHex)((0, import_viem5.toHex)(ACCOUNT_SALT), "bigint");
|
|
1360
1401
|
const tempOwner = {
|
|
1361
1402
|
address: formattedOwnerAddress,
|
|
1362
1403
|
type: "json-rpc"
|
|
@@ -1403,12 +1444,12 @@ var isSafeDeployed = async (address, publicClient) => {
|
|
|
1403
1444
|
}
|
|
1404
1445
|
};
|
|
1405
1446
|
var isOwnableValidatorOwner = async (safeAddress, userAddress, publicClient) => {
|
|
1406
|
-
const normalizedUser = (0,
|
|
1407
|
-
const normalizedSafe = (0,
|
|
1447
|
+
const normalizedUser = (0, import_viem5.getAddress)(userAddress);
|
|
1448
|
+
const normalizedSafe = (0, import_viem5.getAddress)(safeAddress);
|
|
1408
1449
|
const validatorAddresses = Array.from(
|
|
1409
1450
|
/* @__PURE__ */ new Set([
|
|
1410
|
-
(0,
|
|
1411
|
-
(0,
|
|
1451
|
+
(0, import_viem5.getAddress)(OWNABLE_VALIDATOR),
|
|
1452
|
+
(0, import_viem5.getAddress)(import_module_sdk.OWNABLE_VALIDATOR_ADDRESS)
|
|
1412
1453
|
])
|
|
1413
1454
|
);
|
|
1414
1455
|
for (const validatorAddress of validatorAddresses) {
|
|
@@ -1419,7 +1460,7 @@ var isOwnableValidatorOwner = async (safeAddress, userAddress, publicClient) =>
|
|
|
1419
1460
|
functionName: "getOwners",
|
|
1420
1461
|
args: [normalizedSafe]
|
|
1421
1462
|
});
|
|
1422
|
-
if (owners.some((owner) => (0,
|
|
1463
|
+
if (owners.some((owner) => (0, import_viem5.getAddress)(owner) === normalizedUser)) {
|
|
1423
1464
|
return true;
|
|
1424
1465
|
}
|
|
1425
1466
|
} catch {
|
|
@@ -1550,15 +1591,15 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1550
1591
|
};
|
|
1551
1592
|
|
|
1552
1593
|
// src/utils/strategy.ts
|
|
1553
|
-
var PUBLIC_STRATEGIES = `"conservative", "
|
|
1594
|
+
var PUBLIC_STRATEGIES = `"conservative", "aggressive" or "yieldmaxxing"`;
|
|
1554
1595
|
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1555
1596
|
function toInternalStrategy(publicStrategy) {
|
|
1556
1597
|
switch (publicStrategy) {
|
|
1557
1598
|
case "conservative":
|
|
1558
1599
|
return "safe_strategy";
|
|
1559
|
-
case "
|
|
1600
|
+
case "aggressive":
|
|
1560
1601
|
return "degen_strategy";
|
|
1561
|
-
case "
|
|
1602
|
+
case "yieldmaxxing":
|
|
1562
1603
|
return "async_strategy";
|
|
1563
1604
|
default:
|
|
1564
1605
|
throw new Error(
|
|
@@ -1571,10 +1612,10 @@ function toPublicStrategy(internalStrategy) {
|
|
|
1571
1612
|
return "conservative";
|
|
1572
1613
|
}
|
|
1573
1614
|
if (internalStrategy === "degen_strategy" || internalStrategy === "degen") {
|
|
1574
|
-
return "
|
|
1615
|
+
return "aggressive";
|
|
1575
1616
|
}
|
|
1576
1617
|
if (internalStrategy === "async_strategy" || internalStrategy === "async") {
|
|
1577
|
-
return "
|
|
1618
|
+
return "yieldmaxxing";
|
|
1578
1619
|
}
|
|
1579
1620
|
throw new Error(
|
|
1580
1621
|
`Invalid internal strategy: ${internalStrategy}. Must be "safe_strategy", "degen_strategy" or "async_strategy".`
|
|
@@ -1591,7 +1632,7 @@ function toPublicStrategyOrUndefined(internalStrategy) {
|
|
|
1591
1632
|
}
|
|
1592
1633
|
}
|
|
1593
1634
|
function isValidPublicStrategy(strategy) {
|
|
1594
|
-
return strategy === "conservative" || strategy === "
|
|
1635
|
+
return strategy === "conservative" || strategy === "aggressive" || strategy === "yieldmaxxing";
|
|
1595
1636
|
}
|
|
1596
1637
|
function convertStrategyToPublic(obj) {
|
|
1597
1638
|
if (!obj.strategy) {
|
|
@@ -2197,7 +2238,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2197
2238
|
}
|
|
2198
2239
|
this.httpClient.setAuthToken(session.accessToken);
|
|
2199
2240
|
this.authenticatedUserId = session.userId ?? "bearer-session";
|
|
2200
|
-
this.sessionEoa = session.eoa ? (0,
|
|
2241
|
+
this.sessionEoa = session.eoa ? (0, import_viem6.getAddress)(session.eoa) : null;
|
|
2201
2242
|
this.sessionChannel = session.channel;
|
|
2202
2243
|
this.isPredeployed = false;
|
|
2203
2244
|
this.predeployedResolved = false;
|
|
@@ -2246,7 +2287,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2246
2287
|
this.isPredeployed = loginResponse.predeployed || false;
|
|
2247
2288
|
this.predeployedResolved = true;
|
|
2248
2289
|
this.connectedSmartWallet = loginResponse.smartWallet || null;
|
|
2249
|
-
this.sessionEoa = (0,
|
|
2290
|
+
this.sessionEoa = (0, import_viem6.getAddress)(params.message.address);
|
|
2250
2291
|
this.sessionChannel = void 0;
|
|
2251
2292
|
return loginResponse;
|
|
2252
2293
|
}
|
|
@@ -2275,7 +2316,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2275
2316
|
return;
|
|
2276
2317
|
}
|
|
2277
2318
|
const walletClient = this.getWalletClient();
|
|
2278
|
-
const userAddress = (0,
|
|
2319
|
+
const userAddress = (0, import_viem6.getAddress)(walletClient.account.address);
|
|
2279
2320
|
const chainId = this.currentChainId || walletClient.chain?.id || 8453;
|
|
2280
2321
|
const challengeResponse = await this.httpClient.post(ENDPOINTS.AUTH_CHALLENGE, {});
|
|
2281
2322
|
let uri;
|
|
@@ -2363,7 +2404,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2363
2404
|
if (request.strategy) {
|
|
2364
2405
|
if (!isValidPublicStrategy(request.strategy)) {
|
|
2365
2406
|
throw new Error(
|
|
2366
|
-
`Invalid strategy: ${request.strategy}. Must be "conservative", "
|
|
2407
|
+
`Invalid strategy: ${request.strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
2367
2408
|
);
|
|
2368
2409
|
}
|
|
2369
2410
|
rebalanceStrategy = toInternalStrategy(request.strategy);
|
|
@@ -2653,10 +2694,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2653
2694
|
this.walletClient.chain?.id || 8453,
|
|
2654
2695
|
this.rpcUrls
|
|
2655
2696
|
);
|
|
2656
|
-
this.walletClient = (0,
|
|
2697
|
+
this.walletClient = (0, import_viem6.createWalletClient)({
|
|
2657
2698
|
account: newAddress,
|
|
2658
2699
|
chain: chainConfig.chain,
|
|
2659
|
-
transport: (0,
|
|
2700
|
+
transport: (0, import_viem6.custom)(this.currentProvider)
|
|
2660
2701
|
});
|
|
2661
2702
|
this.currentChainId = this.walletClient.chain?.id || null;
|
|
2662
2703
|
try {
|
|
@@ -2721,10 +2762,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2721
2762
|
}
|
|
2722
2763
|
this.signer = (0, import_accounts2.privateKeyToAccount)(privateKey);
|
|
2723
2764
|
this.currentChainId = chainId;
|
|
2724
|
-
this.walletClient = (0,
|
|
2765
|
+
this.walletClient = (0, import_viem6.createWalletClient)({
|
|
2725
2766
|
account: this.signer,
|
|
2726
2767
|
chain: chainConfig.chain,
|
|
2727
|
-
transport: (0,
|
|
2768
|
+
transport: (0, import_viem6.http)(chainConfig.rpcUrl)
|
|
2728
2769
|
});
|
|
2729
2770
|
connectedAddress = this.signer.address;
|
|
2730
2771
|
this.currentProvider = null;
|
|
@@ -2742,10 +2783,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2742
2783
|
if (!accounts || accounts.length === 0) {
|
|
2743
2784
|
throw new Error("No accounts found in wallet provider");
|
|
2744
2785
|
}
|
|
2745
|
-
this.walletClient = (0,
|
|
2786
|
+
this.walletClient = (0, import_viem6.createWalletClient)({
|
|
2746
2787
|
account: accounts[0],
|
|
2747
2788
|
chain: chainConfig.chain,
|
|
2748
|
-
transport: (0,
|
|
2789
|
+
transport: (0, import_viem6.custom)(provider)
|
|
2749
2790
|
});
|
|
2750
2791
|
connectedAddress = accounts[0];
|
|
2751
2792
|
this.currentProvider = provider;
|
|
@@ -2754,7 +2795,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2754
2795
|
provider.on("accountsChanged", this.handleAccountsChanged.bind(this));
|
|
2755
2796
|
}
|
|
2756
2797
|
} else if (provider.account && provider.transport) {
|
|
2757
|
-
this.walletClient = (0,
|
|
2798
|
+
this.walletClient = (0, import_viem6.createWalletClient)({
|
|
2758
2799
|
account: provider.account,
|
|
2759
2800
|
chain: chainConfig.chain,
|
|
2760
2801
|
transport: provider.transport
|
|
@@ -2815,10 +2856,10 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2815
2856
|
targetChainId,
|
|
2816
2857
|
this.rpcUrls
|
|
2817
2858
|
);
|
|
2818
|
-
return (0,
|
|
2859
|
+
return (0, import_viem6.createWalletClient)({
|
|
2819
2860
|
account: this.signer,
|
|
2820
2861
|
chain: targetChainConfig.chain,
|
|
2821
|
-
transport: (0,
|
|
2862
|
+
transport: (0, import_viem6.http)(targetChainConfig.rpcUrl)
|
|
2822
2863
|
});
|
|
2823
2864
|
} else {
|
|
2824
2865
|
if (!this.walletClient) {
|
|
@@ -2934,7 +2975,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2934
2975
|
*
|
|
2935
2976
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
2936
2977
|
* @param chainId - Target chain ID
|
|
2937
|
-
* @param strategy - Optional strategy selection: "conservative" (default), "
|
|
2978
|
+
* @param strategy - Optional strategy selection: "conservative" (default), "aggressive" or "yieldmaxxing"
|
|
2938
2979
|
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
2939
2980
|
* @returns Deployment response with Safe address and transaction hash
|
|
2940
2981
|
*
|
|
@@ -3382,11 +3423,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3382
3423
|
*
|
|
3383
3424
|
* @example
|
|
3384
3425
|
* ```typescript
|
|
3385
|
-
* // NVDAc only lives in async protocols, so it needs "
|
|
3426
|
+
* // NVDAc only lives in async protocols, so it needs "yieldmaxxing".
|
|
3386
3427
|
* // Chains default to Base, the only chain it exists on.
|
|
3387
3428
|
* const profile = await sdk.setAssetStrategy({
|
|
3388
3429
|
* asset: "NVDAc",
|
|
3389
|
-
* strategy: "
|
|
3430
|
+
* strategy: "yieldmaxxing",
|
|
3390
3431
|
* });
|
|
3391
3432
|
* console.log(profile.protocols); // Ipor + Superform
|
|
3392
3433
|
* ```
|
|
@@ -3396,7 +3437,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3396
3437
|
try {
|
|
3397
3438
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3398
3439
|
throw new Error(
|
|
3399
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3440
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
3400
3441
|
);
|
|
3401
3442
|
}
|
|
3402
3443
|
const supported = getAssetChainIds(asset);
|
|
@@ -3431,7 +3472,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3431
3472
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
3432
3473
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
3433
3474
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
3434
|
-
* with the tier (including `
|
|
3475
|
+
* with the tier (including `yieldmaxxing` async venues).
|
|
3435
3476
|
*
|
|
3436
3477
|
* @group Portfolio and execution
|
|
3437
3478
|
*/
|
|
@@ -3439,7 +3480,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3439
3480
|
const { strategy, asset, chains } = params;
|
|
3440
3481
|
if (!isValidPublicStrategy(strategy)) {
|
|
3441
3482
|
throw new Error(
|
|
3442
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3483
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
3443
3484
|
);
|
|
3444
3485
|
}
|
|
3445
3486
|
const assets = asset ? [asset] : getManagedAssets();
|
|
@@ -3588,14 +3629,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3588
3629
|
return this.httpClient.post(ENDPOINTS.DEPLOY_CHAINS, { chainIds });
|
|
3589
3630
|
}
|
|
3590
3631
|
/**
|
|
3591
|
-
*
|
|
3632
|
+
* Deposit a collateral token the wallet already holds into the Safe.
|
|
3592
3633
|
*
|
|
3593
3634
|
* @remarks
|
|
3594
3635
|
* Use this when the connected wallet holds the strategy collateral on the
|
|
3595
3636
|
* deposit chain. {@link ZyfaiSDK.sendDeposit} calls this automatically in
|
|
3596
3637
|
* that case. A different token uses {@link ZyfaiSDK.sendSwapDeposit}.
|
|
3597
3638
|
*
|
|
3598
|
-
*
|
|
3639
|
+
* Eligible first deposits sign an ERC-2612 permit and the backend sponsors and
|
|
3640
|
+
* registers the pull. Other direct deposits confirm an ERC-20 transfer and
|
|
3641
|
+
* call {@link ZyfaiSDK.logDeposit}.
|
|
3599
3642
|
* Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
|
|
3600
3643
|
*
|
|
3601
3644
|
* @group Deposits and withdrawals
|
|
@@ -3619,6 +3662,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3619
3662
|
* ```
|
|
3620
3663
|
*/
|
|
3621
3664
|
async sendDirectDeposit(userAddress, chainId, amount, asset, strategy) {
|
|
3665
|
+
return this.sendCollateralDeposit(userAddress, chainId, amount, asset, strategy, true);
|
|
3666
|
+
}
|
|
3667
|
+
async sendCollateralDeposit(userAddress, chainId, amount, asset, strategy, allowPermit) {
|
|
3622
3668
|
try {
|
|
3623
3669
|
if (!userAddress) {
|
|
3624
3670
|
throw new Error("User address is required");
|
|
@@ -3636,7 +3682,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3636
3682
|
}
|
|
3637
3683
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3638
3684
|
throw new Error(
|
|
3639
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3685
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
3640
3686
|
);
|
|
3641
3687
|
}
|
|
3642
3688
|
const assetSymbol = resolveAssetSymbol(asset);
|
|
@@ -3710,6 +3756,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3710
3756
|
);
|
|
3711
3757
|
}
|
|
3712
3758
|
}
|
|
3759
|
+
if (allowPermit && this.isPredeployed && this.isConnectedUser(userAddress)) {
|
|
3760
|
+
const sponsored = await this.sendFirstPermitDeposit({
|
|
3761
|
+
owner: (0, import_viem6.getAddress)(userAddress),
|
|
3762
|
+
safe: safeAddress,
|
|
3763
|
+
chainId,
|
|
3764
|
+
token: (0, import_viem6.getAddress)(token),
|
|
3765
|
+
amount: amountBigInt
|
|
3766
|
+
});
|
|
3767
|
+
if (sponsored) return sponsored;
|
|
3768
|
+
}
|
|
3713
3769
|
const txHash = await walletClient.writeContract({
|
|
3714
3770
|
address: token,
|
|
3715
3771
|
abi: erc20TransferWriteAbi(assetSymbol),
|
|
@@ -3742,6 +3798,115 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3742
3798
|
throw new Error(`Deposit failed: ${error.message}`);
|
|
3743
3799
|
}
|
|
3744
3800
|
}
|
|
3801
|
+
/**
|
|
3802
|
+
* Read the current first-deposit permit intent after a pending or interrupted deposit.
|
|
3803
|
+
*
|
|
3804
|
+
* @remarks
|
|
3805
|
+
* Uses the execution API and the SIWE session from {@link ZyfaiSDK.connectAccount}.
|
|
3806
|
+
* A registered intent provides the deposit id for {@link ZyfaiSDK.getDepositStatus}.
|
|
3807
|
+
*
|
|
3808
|
+
* @group Deposits and withdrawals
|
|
3809
|
+
*
|
|
3810
|
+
* @param userAddress - Authenticated EOA
|
|
3811
|
+
* @returns The latest permit intent, or null when no intent exists
|
|
3812
|
+
* @throws If the address differs from the authenticated EOA or the request fails
|
|
3813
|
+
*
|
|
3814
|
+
* @example
|
|
3815
|
+
* ```typescript
|
|
3816
|
+
* const intent = await sdk.getFirstPermitDepositStatus(eoa);
|
|
3817
|
+
* if (intent?.depositId) await sdk.waitForDepositCredit(intent.depositId, intent.chainId);
|
|
3818
|
+
* ```
|
|
3819
|
+
*/
|
|
3820
|
+
async getFirstPermitDepositStatus(userAddress) {
|
|
3821
|
+
if (!this.sessionEoa || !(0, import_viem6.isAddressEqual)((0, import_viem6.getAddress)(userAddress), this.sessionEoa)) {
|
|
3822
|
+
throw new Error("userAddress does not match authenticated session EOA");
|
|
3823
|
+
}
|
|
3824
|
+
return (await this.getFirstPermitDepositAvailability()).intent;
|
|
3825
|
+
}
|
|
3826
|
+
async getFirstPermitDepositAvailability(chainId) {
|
|
3827
|
+
try {
|
|
3828
|
+
return await this.httpClient.get(
|
|
3829
|
+
ENDPOINTS.FIRST_PERMIT_DEPOSIT,
|
|
3830
|
+
chainId != null ? { params: { chainId } } : void 0
|
|
3831
|
+
);
|
|
3832
|
+
} catch (error) {
|
|
3833
|
+
if (error instanceof Error && "status" in error && error.status === 404) {
|
|
3834
|
+
return { enabledTokens: [], intent: null };
|
|
3835
|
+
}
|
|
3836
|
+
throw error;
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
async sendFirstPermitDeposit(request) {
|
|
3840
|
+
const { enabledTokens, intent, permitPreferred } = await this.getFirstPermitDepositAvailability(request.chainId);
|
|
3841
|
+
let id;
|
|
3842
|
+
let accepted;
|
|
3843
|
+
if (intent?.status === "queued" || intent?.status === "submitted") {
|
|
3844
|
+
if (!matchesFirstPermitDeposit(intent, request)) {
|
|
3845
|
+
throw new Error(`First permit deposit ${intent.id} is already pending for a different deposit`);
|
|
3846
|
+
}
|
|
3847
|
+
id = intent.id;
|
|
3848
|
+
accepted = intent;
|
|
3849
|
+
} else {
|
|
3850
|
+
const { owner, chainId, token, amount } = request;
|
|
3851
|
+
if (permitPreferred === false) return null;
|
|
3852
|
+
if (!enabledTokens.includes(`${chainId}:${token.toLowerCase()}`)) return null;
|
|
3853
|
+
const prepared = await this.httpClient.post(
|
|
3854
|
+
ENDPOINTS.FIRST_PERMIT_DEPOSIT_PREPARE,
|
|
3855
|
+
{ owner, chainId, token, amount: amount.toString() }
|
|
3856
|
+
);
|
|
3857
|
+
if (!prepared) return null;
|
|
3858
|
+
const message = validateFirstPermit(prepared, request);
|
|
3859
|
+
const currentWallet = this.getWalletClient();
|
|
3860
|
+
const wallet = currentWallet.chain?.id === chainId ? currentWallet : await this.walletClientForOrigin(chainId);
|
|
3861
|
+
const signature = await wallet.signTypedData({
|
|
3862
|
+
account: wallet.account,
|
|
3863
|
+
domain: prepared.domain,
|
|
3864
|
+
types: firstPermitTypes,
|
|
3865
|
+
primaryType: "Permit",
|
|
3866
|
+
message
|
|
3867
|
+
});
|
|
3868
|
+
id = prepared.id;
|
|
3869
|
+
try {
|
|
3870
|
+
accepted = await this.httpClient.post(
|
|
3871
|
+
ENDPOINTS.FIRST_PERMIT_DEPOSIT_SUBMIT(id),
|
|
3872
|
+
{ signature }
|
|
3873
|
+
);
|
|
3874
|
+
} catch (error) {
|
|
3875
|
+
accepted = await this.getFirstPermitDepositStatus(owner).catch(() => null);
|
|
3876
|
+
if (accepted?.id !== id || accepted.status === "prepared") {
|
|
3877
|
+
throw new Error(
|
|
3878
|
+
`Could not confirm first permit deposit ${id}. Check getFirstPermitDepositStatus before retrying: ${thrownMessage(error)}`
|
|
3879
|
+
);
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
let status = accepted;
|
|
3884
|
+
const { value: registered } = await pollUntil(async () => {
|
|
3885
|
+
const current = status ?? await this.getFirstPermitDepositStatus(request.owner);
|
|
3886
|
+
status = null;
|
|
3887
|
+
if (current?.id !== id || !matchesFirstPermitDeposit(current, request)) {
|
|
3888
|
+
throw new Error(`Unable to resolve first permit deposit ${id}. Check getFirstPermitDepositStatus before retrying.`);
|
|
3889
|
+
}
|
|
3890
|
+
if (current.status === "failed") {
|
|
3891
|
+
throw new Error(`First permit deposit ${id} failed`);
|
|
3892
|
+
}
|
|
3893
|
+
return current;
|
|
3894
|
+
}, (current) => current.status === "registered", {
|
|
3895
|
+
intervalMs: 3e3,
|
|
3896
|
+
label: `first permit deposit ${id} registration. Check getFirstPermitDepositStatus before retrying`
|
|
3897
|
+
});
|
|
3898
|
+
if (!registered.txHash || !registered.depositId) {
|
|
3899
|
+
throw new Error(`First permit deposit ${id} is missing its registration. Check getFirstPermitDepositStatus before retrying.`);
|
|
3900
|
+
}
|
|
3901
|
+
return {
|
|
3902
|
+
success: true,
|
|
3903
|
+
txHash: registered.txHash,
|
|
3904
|
+
smartWallet: request.safe,
|
|
3905
|
+
amount: registered.amount,
|
|
3906
|
+
route: "direct",
|
|
3907
|
+
registration: await this.getDepositStatus(registered.depositId)
|
|
3908
|
+
};
|
|
3909
|
+
}
|
|
3745
3910
|
async sendDeposit(userAddressOrParams, chainId, amount, asset, strategy) {
|
|
3746
3911
|
if (typeof userAddressOrParams !== "string") {
|
|
3747
3912
|
return this.sendRoutedDeposit(userAddressOrParams);
|
|
@@ -4030,12 +4195,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4030
4195
|
BigInt(params.amount)
|
|
4031
4196
|
);
|
|
4032
4197
|
await this.wrapNativeEth(params.chainId, params.amount);
|
|
4033
|
-
const sent = await this.
|
|
4198
|
+
const sent = await this.sendCollateralDeposit(
|
|
4034
4199
|
params.userAddress,
|
|
4035
4200
|
params.chainId,
|
|
4036
4201
|
params.amount,
|
|
4037
4202
|
"WETH",
|
|
4038
|
-
params.strategy
|
|
4203
|
+
params.strategy,
|
|
4204
|
+
false
|
|
4039
4205
|
);
|
|
4040
4206
|
return { ...sent, route: "wrap" };
|
|
4041
4207
|
}
|
|
@@ -4123,16 +4289,16 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4123
4289
|
method: "wallet_switchEthereumChain",
|
|
4124
4290
|
params: [{ chainId: `0x${originChainId.toString(16)}` }]
|
|
4125
4291
|
});
|
|
4126
|
-
const chain = isSupportedChain(originChainId) ? getChainConfig(originChainId, this.rpcUrls).chain : (0,
|
|
4292
|
+
const chain = isSupportedChain(originChainId) ? getChainConfig(originChainId, this.rpcUrls).chain : (0, import_viem6.defineChain)({
|
|
4127
4293
|
id: originChainId,
|
|
4128
4294
|
name: `Chain ${originChainId}`,
|
|
4129
4295
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
4130
4296
|
rpcUrls: { default: { http: ["http://127.0.0.1"] } }
|
|
4131
4297
|
});
|
|
4132
|
-
this.walletClient = (0,
|
|
4298
|
+
this.walletClient = (0, import_viem6.createWalletClient)({
|
|
4133
4299
|
account: this.walletClient.account,
|
|
4134
4300
|
chain,
|
|
4135
|
-
transport: (0,
|
|
4301
|
+
transport: (0, import_viem6.custom)(this.currentProvider)
|
|
4136
4302
|
});
|
|
4137
4303
|
if (isSupportedChain(originChainId)) {
|
|
4138
4304
|
this.currentChainId = originChainId;
|
|
@@ -4308,7 +4474,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4308
4474
|
safeAddress,
|
|
4309
4475
|
tokenAddress,
|
|
4310
4476
|
to: tokenAddress,
|
|
4311
|
-
data: (0,
|
|
4477
|
+
data: (0, import_viem6.encodeFunctionData)({
|
|
4312
4478
|
abi: ERC20_ABI,
|
|
4313
4479
|
functionName: "transfer",
|
|
4314
4480
|
args: [safeAddress, amountBigInt]
|
|
@@ -4337,7 +4503,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4337
4503
|
if (!userAddress) {
|
|
4338
4504
|
throw new Error("A user address is required");
|
|
4339
4505
|
}
|
|
4340
|
-
const owner = (0,
|
|
4506
|
+
const owner = (0, import_viem6.getAddress)(userAddress);
|
|
4341
4507
|
const chainId = 8453;
|
|
4342
4508
|
await this.hydrateSessionWallet();
|
|
4343
4509
|
const safe = await this.getSafeAddressFor(owner, chainId);
|
|
@@ -4359,7 +4525,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4359
4525
|
]).catch(() => {
|
|
4360
4526
|
throw new Error(`Safe ${safe} is not deployed on Base`);
|
|
4361
4527
|
});
|
|
4362
|
-
if (threshold !== 1n || !owners.some((o) => (0,
|
|
4528
|
+
if (threshold !== 1n || !owners.some((o) => (0, import_viem6.getAddress)(o) === owner)) {
|
|
4363
4529
|
throw new Error(
|
|
4364
4530
|
`${owner} cannot execute Safe ${safe} alone (not an owner, or threshold above 1)`
|
|
4365
4531
|
);
|
|
@@ -4448,7 +4614,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4448
4614
|
if (!userAddress) {
|
|
4449
4615
|
throw new Error("A user address is required");
|
|
4450
4616
|
}
|
|
4451
|
-
if (this.sessionEoa && (0,
|
|
4617
|
+
if (this.sessionEoa && (0, import_viem6.getAddress)(userAddress) !== this.sessionEoa) {
|
|
4452
4618
|
throw new Error("userAddress does not match authenticated session EOA");
|
|
4453
4619
|
}
|
|
4454
4620
|
}
|
|
@@ -4514,7 +4680,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4514
4680
|
async ensureFirstDepositSetup(strategy) {
|
|
4515
4681
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4516
4682
|
throw new Error(
|
|
4517
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4683
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
4518
4684
|
);
|
|
4519
4685
|
}
|
|
4520
4686
|
await this.authenticateUser();
|
|
@@ -4547,7 +4713,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4547
4713
|
const { strategy, asset, chainId } = params;
|
|
4548
4714
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4549
4715
|
throw new Error(
|
|
4550
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4716
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
4551
4717
|
);
|
|
4552
4718
|
}
|
|
4553
4719
|
await this.authenticateUser();
|
|
@@ -4594,7 +4760,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4594
4760
|
*/
|
|
4595
4761
|
async prepareDeposit(params) {
|
|
4596
4762
|
const { userAddress, chainId, amount, asset } = params;
|
|
4597
|
-
if (this.sessionEoa && (0,
|
|
4763
|
+
if (this.sessionEoa && (0, import_viem6.getAddress)(userAddress) !== this.sessionEoa) {
|
|
4598
4764
|
throw new Error("userAddress does not match authenticated session EOA");
|
|
4599
4765
|
}
|
|
4600
4766
|
const setup = await this.ensureDepositProfileForPrepare({
|
|
@@ -4930,7 +5096,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4930
5096
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
4931
5097
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
4932
5098
|
*
|
|
4933
|
-
* **Delayed withdrawals.** Positions held under the `"
|
|
5099
|
+
* **Delayed withdrawals.** Positions held under the `"yieldmaxxing"`
|
|
4934
5100
|
* strategy sit in protocols that cannot be exited on demand. For those the
|
|
4935
5101
|
* backend transfers the immediately available portion, then queues a
|
|
4936
5102
|
* redemption for the rest and forwards the funds to the EOA once the
|
|
@@ -5177,7 +5343,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5177
5343
|
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
5178
5344
|
*
|
|
5179
5345
|
* **Total balance.** `portfolioByAssetType` sums deployed positions and idle
|
|
5180
|
-
* Safe balances, and nothing else. Under the `"
|
|
5346
|
+
* Safe balances, and nothing else. Under the `"yieldmaxxing"` strategy a
|
|
5181
5347
|
* redemption in flight has already left its position and has not landed in
|
|
5182
5348
|
* the Safe yet, so its funds appear in no balance field at all. That makes
|
|
5183
5349
|
* two distinct numbers:
|
|
@@ -5202,7 +5368,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5202
5368
|
* @group Portfolio and execution
|
|
5203
5369
|
*
|
|
5204
5370
|
* @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
|
|
5205
|
-
* when using {@link Strategy |
|
|
5371
|
+
* when using {@link Strategy | yieldmaxxing}.
|
|
5206
5372
|
*
|
|
5207
5373
|
* @param userAddress - User's EOA address
|
|
5208
5374
|
* @returns Portfolio with optional fee-adjusted balance fields
|
|
@@ -5400,7 +5566,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5400
5566
|
*
|
|
5401
5567
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
5402
5568
|
* @param days - Time period: 7, 14, or 30
|
|
5403
|
-
* @param strategy - Strategy type: "conservative" (default), "
|
|
5569
|
+
* @param strategy - Strategy type: "conservative" (default), "aggressive" or "yieldmaxxing"
|
|
5404
5570
|
* @param chainId - Optional chain ID filter
|
|
5405
5571
|
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
5406
5572
|
* @returns APY per strategy for a specific chain
|
|
@@ -5855,19 +6021,19 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5855
6021
|
}
|
|
5856
6022
|
}
|
|
5857
6023
|
/**
|
|
5858
|
-
* Get
|
|
6024
|
+
* Get balanced (high-risk, high-reward) yield opportunities.
|
|
5859
6025
|
*
|
|
5860
6026
|
* @param chainId - Optional chain ID filter
|
|
5861
6027
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH", "WBTC")
|
|
5862
|
-
* @returns List of
|
|
6028
|
+
* @returns List of balanced opportunities
|
|
5863
6029
|
*
|
|
5864
6030
|
* @example
|
|
5865
6031
|
* ```typescript
|
|
5866
|
-
* const opportunities = await sdk.
|
|
6032
|
+
* const opportunities = await sdk.getBalancedOpportunities(8453, "WETH");
|
|
5867
6033
|
* opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
|
|
5868
6034
|
* ```
|
|
5869
6035
|
*/
|
|
5870
|
-
async
|
|
6036
|
+
async getBalancedOpportunities(chainId, asset, status) {
|
|
5871
6037
|
try {
|
|
5872
6038
|
const response = await this.httpClient.dataGet(
|
|
5873
6039
|
DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId, asset, status)
|
|
@@ -5893,12 +6059,25 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5893
6059
|
};
|
|
5894
6060
|
} catch (error) {
|
|
5895
6061
|
throw new Error(
|
|
5896
|
-
`Failed to get
|
|
6062
|
+
`Failed to get balanced opportunities: ${error.message}`
|
|
5897
6063
|
);
|
|
5898
6064
|
}
|
|
5899
6065
|
}
|
|
5900
6066
|
/**
|
|
5901
|
-
*
|
|
6067
|
+
* @deprecated Use {@link getBalancedOpportunities} instead. Retains the
|
|
6068
|
+
* pre-rename `getAggressiveOpportunities` entry point; same HTTP request as
|
|
6069
|
+
* balanced, with legacy `strategyType: "aggressive"` on the response and rows.
|
|
6070
|
+
*/
|
|
6071
|
+
async getAggressiveOpportunities(chainId, asset, status) {
|
|
6072
|
+
const result = await this.getBalancedOpportunities(chainId, asset, status);
|
|
6073
|
+
return {
|
|
6074
|
+
...result,
|
|
6075
|
+
strategyType: "aggressive",
|
|
6076
|
+
data: result.data.map((o) => ({ ...o, strategyType: "aggressive" }))
|
|
6077
|
+
};
|
|
6078
|
+
}
|
|
6079
|
+
/**
|
|
6080
|
+
* Get advanced yield opportunities — pools reachable only with the
|
|
5902
6081
|
* `"advanced"` strategy, including protocols whose withdrawals are
|
|
5903
6082
|
* asynchronous (Ipor, Superform). Exiting these pools takes about a day
|
|
5904
6083
|
* on Ipor and three on Superform; track the redemption through
|
|
@@ -5906,15 +6085,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5906
6085
|
*
|
|
5907
6086
|
* @param chainId - Optional chain ID filter
|
|
5908
6087
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
5909
|
-
* @returns List of
|
|
6088
|
+
* @returns List of advanced opportunities
|
|
5910
6089
|
*
|
|
5911
6090
|
* @example
|
|
5912
6091
|
* ```typescript
|
|
5913
|
-
* const opportunities = await sdk.
|
|
6092
|
+
* const opportunities = await sdk.getAdvancedOpportunities(8453);
|
|
5914
6093
|
* opportunities.data.forEach(o => console.log(o.protocolName, o.apy));
|
|
5915
6094
|
* ```
|
|
5916
6095
|
*/
|
|
5917
|
-
async
|
|
6096
|
+
async getAdvancedOpportunities(chainId, asset, status) {
|
|
5918
6097
|
try {
|
|
5919
6098
|
const response = await this.httpClient.dataGet(
|
|
5920
6099
|
DATA_ENDPOINTS.OPPORTUNITIES_ASYNC(chainId, asset, status)
|
|
@@ -5940,10 +6119,23 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5940
6119
|
};
|
|
5941
6120
|
} catch (error) {
|
|
5942
6121
|
throw new Error(
|
|
5943
|
-
`Failed to get
|
|
6122
|
+
`Failed to get advanced opportunities: ${error.message}`
|
|
5944
6123
|
);
|
|
5945
6124
|
}
|
|
5946
6125
|
}
|
|
6126
|
+
/**
|
|
6127
|
+
* @deprecated Use {@link getAdvancedOpportunities} instead. Retains the
|
|
6128
|
+
* pre-rename `getAsyncOpportunities` entry point; same HTTP request as
|
|
6129
|
+
* advanced, with legacy `strategyType: "yieldmaxxing"` on the response and rows.
|
|
6130
|
+
*/
|
|
6131
|
+
async getAsyncOpportunities(chainId, asset, status) {
|
|
6132
|
+
const result = await this.getAdvancedOpportunities(chainId, asset, status);
|
|
6133
|
+
return {
|
|
6134
|
+
...result,
|
|
6135
|
+
strategyType: "yieldmaxxing",
|
|
6136
|
+
data: result.data.map((o) => ({ ...o, strategyType: "yieldmaxxing" }))
|
|
6137
|
+
};
|
|
6138
|
+
}
|
|
5947
6139
|
/**
|
|
5948
6140
|
* Get active conservative opportunities (status = "live") with risk and utilization data
|
|
5949
6141
|
* Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
|
|
@@ -6465,7 +6657,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6465
6657
|
if (strategy) {
|
|
6466
6658
|
if (!isValidPublicStrategy(strategy)) {
|
|
6467
6659
|
throw new Error(
|
|
6468
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
6660
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
6469
6661
|
);
|
|
6470
6662
|
}
|
|
6471
6663
|
internalStrategy = toInternalStrategy(strategy);
|
|
@@ -6515,7 +6707,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6515
6707
|
try {
|
|
6516
6708
|
if (!isValidPublicStrategy(params.strategy)) {
|
|
6517
6709
|
throw new Error(
|
|
6518
|
-
`Invalid strategy: ${params.strategy}. Must be "conservative", "
|
|
6710
|
+
`Invalid strategy: ${params.strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
6519
6711
|
);
|
|
6520
6712
|
}
|
|
6521
6713
|
const internalStrategy = toInternalStrategy(params.strategy);
|
|
@@ -6614,7 +6806,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6614
6806
|
if (!tokenUriResponse.tokenUri) {
|
|
6615
6807
|
throw new Error("API did not return a tokenUri");
|
|
6616
6808
|
}
|
|
6617
|
-
const callData = (0,
|
|
6809
|
+
const callData = (0, import_viem6.encodeFunctionData)({
|
|
6618
6810
|
abi: IDENTITY_REGISTRY_ABI,
|
|
6619
6811
|
functionName: "register",
|
|
6620
6812
|
args: [tokenUriResponse.tokenUri]
|