@zyfai/sdk 0.12.0 → 1.0.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 +47 -45
- package/dist/index.d.mts +43 -14
- package/dist/index.d.ts +43 -14
- package/dist/index.js +204 -62
- package/dist/index.mjs +181 -34
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -617,6 +617,68 @@ var VAULT_ABI = [
|
|
|
617
617
|
}
|
|
618
618
|
];
|
|
619
619
|
var VAULT_ADDRESS = "0xD580071c47d4a667858B5FafAb85BC9C609beC5D";
|
|
620
|
+
var MERKL_DISTRIBUTOR_ADDRESS = "0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae";
|
|
621
|
+
var RZFI_TOKEN_ADDRESS = "0x1c08C7df416062b472F553DCC1ed3045489520C5";
|
|
622
|
+
var MERKL_DISTRIBUTOR_ABI = parseAbi([
|
|
623
|
+
"function claim(address[] users, address[] tokens, uint256[] amounts, bytes32[][] proofs)",
|
|
624
|
+
"function claimed(address user, address token) view returns (uint208 amount, uint48 timestamp, bytes32 merkleRoot)",
|
|
625
|
+
"function getMerkleRoot() view returns (bytes32)"
|
|
626
|
+
]);
|
|
627
|
+
var SAFE_ABI = parseAbi([
|
|
628
|
+
"function execTransaction(address to, uint256 value, bytes data, uint8 operation, uint256 safeTxGas, uint256 baseGas, uint256 gasPrice, address gasToken, address refundReceiver, bytes signatures) payable returns (bool success)",
|
|
629
|
+
"function getOwners() view returns (address[])",
|
|
630
|
+
"function getThreshold() view returns (uint256)"
|
|
631
|
+
]);
|
|
632
|
+
|
|
633
|
+
// src/utils/rzfi-claim.ts
|
|
634
|
+
import {
|
|
635
|
+
encodeFunctionData,
|
|
636
|
+
encodePacked,
|
|
637
|
+
pad,
|
|
638
|
+
zeroAddress
|
|
639
|
+
} from "viem";
|
|
640
|
+
var MERKL_API_URL = "https://api.merkl.xyz/v4";
|
|
641
|
+
async function fetchMerklRzfiReward(safe) {
|
|
642
|
+
const response = await fetch(
|
|
643
|
+
`${MERKL_API_URL}/users/${safe}/rewards?chainId=8453`
|
|
644
|
+
);
|
|
645
|
+
if (!response.ok) {
|
|
646
|
+
throw new Error(`Merkl API error: ${response.status}`);
|
|
647
|
+
}
|
|
648
|
+
const body = await response.json();
|
|
649
|
+
const reward = body[0]?.rewards?.find(
|
|
650
|
+
(r) => r.token.address.toLowerCase() === RZFI_TOKEN_ADDRESS.toLowerCase()
|
|
651
|
+
);
|
|
652
|
+
return reward ? { amount: BigInt(reward.amount), root: reward.root, proofs: reward.proofs } : null;
|
|
653
|
+
}
|
|
654
|
+
function encodeRzfiClaimExecTransaction(params) {
|
|
655
|
+
const { safe, owner, amount, proofs } = params;
|
|
656
|
+
const claimData = encodeFunctionData({
|
|
657
|
+
abi: MERKL_DISTRIBUTOR_ABI,
|
|
658
|
+
functionName: "claim",
|
|
659
|
+
args: [[safe], [RZFI_TOKEN_ADDRESS], [amount], [proofs]]
|
|
660
|
+
});
|
|
661
|
+
const signature = encodePacked(
|
|
662
|
+
["bytes32", "bytes32", "uint8"],
|
|
663
|
+
[pad(owner), pad("0x00"), 1]
|
|
664
|
+
);
|
|
665
|
+
return encodeFunctionData({
|
|
666
|
+
abi: SAFE_ABI,
|
|
667
|
+
functionName: "execTransaction",
|
|
668
|
+
args: [
|
|
669
|
+
MERKL_DISTRIBUTOR_ADDRESS,
|
|
670
|
+
0n,
|
|
671
|
+
claimData,
|
|
672
|
+
0,
|
|
673
|
+
0n,
|
|
674
|
+
0n,
|
|
675
|
+
0n,
|
|
676
|
+
zeroAddress,
|
|
677
|
+
zeroAddress,
|
|
678
|
+
signature
|
|
679
|
+
]
|
|
680
|
+
});
|
|
681
|
+
}
|
|
620
682
|
|
|
621
683
|
// src/config/constants.ts
|
|
622
684
|
var ZYFI_FEE_RATE = 0.1;
|
|
@@ -756,7 +818,7 @@ import {
|
|
|
756
818
|
custom,
|
|
757
819
|
http as http2,
|
|
758
820
|
getAddress as getAddress2,
|
|
759
|
-
encodeFunctionData,
|
|
821
|
+
encodeFunctionData as encodeFunctionData2,
|
|
760
822
|
defineChain
|
|
761
823
|
} from "viem";
|
|
762
824
|
import { execute } from "@relayprotocol/relay-sdk";
|
|
@@ -881,7 +943,7 @@ var ASSET_CONFIGS = {
|
|
|
881
943
|
enabled: true
|
|
882
944
|
},
|
|
883
945
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
884
|
-
// protocols with delayed withdrawals — see the `
|
|
946
|
+
// protocols with delayed withdrawals — see the `advanced` strategy.
|
|
885
947
|
NVDAc: {
|
|
886
948
|
symbol: "NVDAc",
|
|
887
949
|
assetType: "nvdac",
|
|
@@ -1445,15 +1507,15 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1445
1507
|
};
|
|
1446
1508
|
|
|
1447
1509
|
// src/utils/strategy.ts
|
|
1448
|
-
var PUBLIC_STRATEGIES = `"conservative", "
|
|
1510
|
+
var PUBLIC_STRATEGIES = `"conservative", "balanced" or "advanced"`;
|
|
1449
1511
|
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1450
1512
|
function toInternalStrategy(publicStrategy) {
|
|
1451
1513
|
switch (publicStrategy) {
|
|
1452
1514
|
case "conservative":
|
|
1453
1515
|
return "safe_strategy";
|
|
1454
|
-
case "
|
|
1516
|
+
case "balanced":
|
|
1455
1517
|
return "degen_strategy";
|
|
1456
|
-
case "
|
|
1518
|
+
case "advanced":
|
|
1457
1519
|
return "async_strategy";
|
|
1458
1520
|
default:
|
|
1459
1521
|
throw new Error(
|
|
@@ -1466,10 +1528,10 @@ function toPublicStrategy(internalStrategy) {
|
|
|
1466
1528
|
return "conservative";
|
|
1467
1529
|
}
|
|
1468
1530
|
if (internalStrategy === "degen_strategy" || internalStrategy === "degen") {
|
|
1469
|
-
return "
|
|
1531
|
+
return "balanced";
|
|
1470
1532
|
}
|
|
1471
1533
|
if (internalStrategy === "async_strategy" || internalStrategy === "async") {
|
|
1472
|
-
return "
|
|
1534
|
+
return "advanced";
|
|
1473
1535
|
}
|
|
1474
1536
|
throw new Error(
|
|
1475
1537
|
`Invalid internal strategy: ${internalStrategy}. Must be "safe_strategy", "degen_strategy" or "async_strategy".`
|
|
@@ -1486,7 +1548,7 @@ function toPublicStrategyOrUndefined(internalStrategy) {
|
|
|
1486
1548
|
}
|
|
1487
1549
|
}
|
|
1488
1550
|
function isValidPublicStrategy(strategy) {
|
|
1489
|
-
return strategy === "conservative" || strategy === "
|
|
1551
|
+
return strategy === "conservative" || strategy === "balanced" || strategy === "advanced";
|
|
1490
1552
|
}
|
|
1491
1553
|
function convertStrategyToPublic(obj) {
|
|
1492
1554
|
if (!obj.strategy) {
|
|
@@ -2258,7 +2320,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2258
2320
|
if (request.strategy) {
|
|
2259
2321
|
if (!isValidPublicStrategy(request.strategy)) {
|
|
2260
2322
|
throw new Error(
|
|
2261
|
-
`Invalid strategy: ${request.strategy}. Must be "conservative", "
|
|
2323
|
+
`Invalid strategy: ${request.strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
2262
2324
|
);
|
|
2263
2325
|
}
|
|
2264
2326
|
rebalanceStrategy = toInternalStrategy(request.strategy);
|
|
@@ -2829,7 +2891,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2829
2891
|
*
|
|
2830
2892
|
* @param userAddress - User's EOA address (the connected EOA, not the smart wallet address)
|
|
2831
2893
|
* @param chainId - Target chain ID
|
|
2832
|
-
* @param strategy - Optional strategy selection: "conservative" (default), "
|
|
2894
|
+
* @param strategy - Optional strategy selection: "conservative" (default), "balanced" or "advanced"
|
|
2833
2895
|
* @param createSessionKey - If true, automatically creates a session key after deployment (default: false)
|
|
2834
2896
|
* @returns Deployment response with Safe address and transaction hash
|
|
2835
2897
|
*
|
|
@@ -3277,11 +3339,11 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3277
3339
|
*
|
|
3278
3340
|
* @example
|
|
3279
3341
|
* ```typescript
|
|
3280
|
-
* // NVDAc only lives in async protocols, so it needs "
|
|
3342
|
+
* // NVDAc only lives in async protocols, so it needs "advanced".
|
|
3281
3343
|
* // Chains default to Base, the only chain it exists on.
|
|
3282
3344
|
* const profile = await sdk.setAssetStrategy({
|
|
3283
3345
|
* asset: "NVDAc",
|
|
3284
|
-
* strategy: "
|
|
3346
|
+
* strategy: "advanced",
|
|
3285
3347
|
* });
|
|
3286
3348
|
* console.log(profile.protocols); // Ipor + Superform
|
|
3287
3349
|
* ```
|
|
@@ -3291,7 +3353,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3291
3353
|
try {
|
|
3292
3354
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3293
3355
|
throw new Error(
|
|
3294
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3356
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3295
3357
|
);
|
|
3296
3358
|
}
|
|
3297
3359
|
const supported = getAssetChainIds(asset);
|
|
@@ -3326,7 +3388,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3326
3388
|
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
3327
3389
|
* assets ({@link getManagedAssets}). Prefer this over
|
|
3328
3390
|
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
3329
|
-
* with the tier (including `
|
|
3391
|
+
* with the tier (including `advanced` async venues).
|
|
3330
3392
|
*
|
|
3331
3393
|
* @group Portfolio and execution
|
|
3332
3394
|
*/
|
|
@@ -3334,7 +3396,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3334
3396
|
const { strategy, asset, chains } = params;
|
|
3335
3397
|
if (!isValidPublicStrategy(strategy)) {
|
|
3336
3398
|
throw new Error(
|
|
3337
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3399
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3338
3400
|
);
|
|
3339
3401
|
}
|
|
3340
3402
|
const assets = asset ? [asset] : getManagedAssets();
|
|
@@ -3531,7 +3593,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3531
3593
|
}
|
|
3532
3594
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3533
3595
|
throw new Error(
|
|
3534
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
3596
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
3535
3597
|
);
|
|
3536
3598
|
}
|
|
3537
3599
|
const assetSymbol = resolveAssetSymbol(asset);
|
|
@@ -4203,7 +4265,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4203
4265
|
safeAddress,
|
|
4204
4266
|
tokenAddress,
|
|
4205
4267
|
to: tokenAddress,
|
|
4206
|
-
data:
|
|
4268
|
+
data: encodeFunctionData2({
|
|
4207
4269
|
abi: ERC20_ABI,
|
|
4208
4270
|
functionName: "transfer",
|
|
4209
4271
|
args: [safeAddress, amountBigInt]
|
|
@@ -4211,6 +4273,91 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4211
4273
|
value: "0"
|
|
4212
4274
|
};
|
|
4213
4275
|
}
|
|
4276
|
+
/**
|
|
4277
|
+
* Build the rZFI claim as an unsigned transaction for your own signer.
|
|
4278
|
+
*
|
|
4279
|
+
* @remarks
|
|
4280
|
+
* Same pattern as {@link ZyfaiSDK.buildDepositTransfer}: sign and send
|
|
4281
|
+
* `{ to, data, value }` from `userAddress` on Base (chain 8453). It must be
|
|
4282
|
+
* sent by `userAddress` itself; any other sender reverts. The sender pays the
|
|
4283
|
+
* gas. Claims all unclaimed rZFI into the user's Safe.
|
|
4284
|
+
*
|
|
4285
|
+
* @group Rewards
|
|
4286
|
+
*
|
|
4287
|
+
* @param userAddress - Owner EOA, which must send the transaction
|
|
4288
|
+
* @returns Safe address, claimable amount, and the transaction to send
|
|
4289
|
+
*
|
|
4290
|
+
* @throws If there is no rZFI to claim, the reward tree is updating (retry
|
|
4291
|
+
* later), or `userAddress` cannot execute the Safe alone (not an owner, or threshold above 1)
|
|
4292
|
+
*/
|
|
4293
|
+
async buildRzfiClaimTransaction(userAddress) {
|
|
4294
|
+
if (!userAddress) {
|
|
4295
|
+
throw new Error("A user address is required");
|
|
4296
|
+
}
|
|
4297
|
+
const owner = getAddress2(userAddress);
|
|
4298
|
+
const chainId = 8453;
|
|
4299
|
+
await this.hydrateSessionWallet();
|
|
4300
|
+
const safe = await this.getSafeAddressFor(owner, chainId);
|
|
4301
|
+
if (!safe) {
|
|
4302
|
+
throw new Error("Smart wallet address is not available");
|
|
4303
|
+
}
|
|
4304
|
+
const { publicClient } = getChainConfig(chainId, this.rpcUrls);
|
|
4305
|
+
const [owners, threshold] = await Promise.all([
|
|
4306
|
+
publicClient.readContract({
|
|
4307
|
+
address: safe,
|
|
4308
|
+
abi: SAFE_ABI,
|
|
4309
|
+
functionName: "getOwners"
|
|
4310
|
+
}),
|
|
4311
|
+
publicClient.readContract({
|
|
4312
|
+
address: safe,
|
|
4313
|
+
abi: SAFE_ABI,
|
|
4314
|
+
functionName: "getThreshold"
|
|
4315
|
+
})
|
|
4316
|
+
]).catch(() => {
|
|
4317
|
+
throw new Error(`Safe ${safe} is not deployed on Base`);
|
|
4318
|
+
});
|
|
4319
|
+
if (threshold !== 1n || !owners.some((o) => getAddress2(o) === owner)) {
|
|
4320
|
+
throw new Error(
|
|
4321
|
+
`${owner} cannot execute Safe ${safe} alone (not an owner, or threshold above 1)`
|
|
4322
|
+
);
|
|
4323
|
+
}
|
|
4324
|
+
const [reward, [claimed], liveRoot] = await Promise.all([
|
|
4325
|
+
fetchMerklRzfiReward(safe),
|
|
4326
|
+
publicClient.readContract({
|
|
4327
|
+
address: MERKL_DISTRIBUTOR_ADDRESS,
|
|
4328
|
+
abi: MERKL_DISTRIBUTOR_ABI,
|
|
4329
|
+
functionName: "claimed",
|
|
4330
|
+
args: [safe, RZFI_TOKEN_ADDRESS]
|
|
4331
|
+
}),
|
|
4332
|
+
publicClient.readContract({
|
|
4333
|
+
address: MERKL_DISTRIBUTOR_ADDRESS,
|
|
4334
|
+
abi: MERKL_DISTRIBUTOR_ABI,
|
|
4335
|
+
functionName: "getMerkleRoot"
|
|
4336
|
+
})
|
|
4337
|
+
]);
|
|
4338
|
+
const claimable = reward ? reward.amount - claimed : 0n;
|
|
4339
|
+
if (!reward || claimable <= 0n) {
|
|
4340
|
+
throw new Error("No rZFI available to claim");
|
|
4341
|
+
}
|
|
4342
|
+
if (reward.root.toLowerCase() !== liveRoot.toLowerCase()) {
|
|
4343
|
+
throw new Error(
|
|
4344
|
+
"rZFI rewards are being updated on-chain. Retry in a few minutes."
|
|
4345
|
+
);
|
|
4346
|
+
}
|
|
4347
|
+
return {
|
|
4348
|
+
safeAddress: safe,
|
|
4349
|
+
chainId: 8453,
|
|
4350
|
+
claimableAmount: claimable.toString(),
|
|
4351
|
+
to: safe,
|
|
4352
|
+
data: encodeRzfiClaimExecTransaction({
|
|
4353
|
+
safe,
|
|
4354
|
+
owner,
|
|
4355
|
+
amount: reward.amount,
|
|
4356
|
+
proofs: reward.proofs
|
|
4357
|
+
}),
|
|
4358
|
+
value: "0"
|
|
4359
|
+
};
|
|
4360
|
+
}
|
|
4214
4361
|
/**
|
|
4215
4362
|
* Prepare a gas-sponsored rZFI claim into the user's Safe on Base.
|
|
4216
4363
|
*
|
|
@@ -4324,7 +4471,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4324
4471
|
async ensureFirstDepositSetup(strategy) {
|
|
4325
4472
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4326
4473
|
throw new Error(
|
|
4327
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4474
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
4328
4475
|
);
|
|
4329
4476
|
}
|
|
4330
4477
|
await this.authenticateUser();
|
|
@@ -4357,7 +4504,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4357
4504
|
const { strategy, asset, chainId } = params;
|
|
4358
4505
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
4359
4506
|
throw new Error(
|
|
4360
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
4507
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
4361
4508
|
);
|
|
4362
4509
|
}
|
|
4363
4510
|
await this.authenticateUser();
|
|
@@ -4740,7 +4887,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4740
4887
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
4741
4888
|
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
4742
4889
|
*
|
|
4743
|
-
* **Delayed withdrawals.** Positions held under the `"
|
|
4890
|
+
* **Delayed withdrawals.** Positions held under the `"advanced"`
|
|
4744
4891
|
* strategy sit in protocols that cannot be exited on demand. For those the
|
|
4745
4892
|
* backend transfers the immediately available portion, then queues a
|
|
4746
4893
|
* redemption for the rest and forwards the funds to the EOA once the
|
|
@@ -4987,7 +5134,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4987
5134
|
* a snapshot, so net values can differ slightly from a fully live calc.
|
|
4988
5135
|
*
|
|
4989
5136
|
* **Total balance.** `portfolioByAssetType` sums deployed positions and idle
|
|
4990
|
-
* Safe balances, and nothing else. Under the `"
|
|
5137
|
+
* Safe balances, and nothing else. Under the `"advanced"` strategy a
|
|
4991
5138
|
* redemption in flight has already left its position and has not landed in
|
|
4992
5139
|
* the Safe yet, so its funds appear in no balance field at all. That makes
|
|
4993
5140
|
* two distinct numbers:
|
|
@@ -5012,7 +5159,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5012
5159
|
* @group Portfolio and execution
|
|
5013
5160
|
*
|
|
5014
5161
|
* @remarks Data API portfolio endpoint. See {@link PortfolioDetailed.pendingAsyncWithdrawals}
|
|
5015
|
-
* when using {@link Strategy |
|
|
5162
|
+
* when using {@link Strategy | grow}.
|
|
5016
5163
|
*
|
|
5017
5164
|
* @param userAddress - User's EOA address
|
|
5018
5165
|
* @returns Portfolio with optional fee-adjusted balance fields
|
|
@@ -5210,7 +5357,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5210
5357
|
*
|
|
5211
5358
|
* @param crossChain - Whether to get cross-chain APY (true = omni account, false = simple account)
|
|
5212
5359
|
* @param days - Time period: 7, 14, or 30
|
|
5213
|
-
* @param strategy - Strategy type: "conservative" (default), "
|
|
5360
|
+
* @param strategy - Strategy type: "conservative" (default), "balanced" or "advanced"
|
|
5214
5361
|
* @param chainId - Optional chain ID filter
|
|
5215
5362
|
* @param tokenSymbol - Optional token symbol filter (e.g. "USDC", "WETH", "WBTC")
|
|
5216
5363
|
* @returns APY per strategy for a specific chain
|
|
@@ -5686,7 +5833,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5686
5833
|
return {
|
|
5687
5834
|
success: true,
|
|
5688
5835
|
chainId,
|
|
5689
|
-
strategyType: "
|
|
5836
|
+
strategyType: "balanced",
|
|
5690
5837
|
data: Array.isArray(data) ? data.map((o) => ({
|
|
5691
5838
|
id: o.id,
|
|
5692
5839
|
protocolId: o.protocol_id || o.protocolId,
|
|
@@ -5697,7 +5844,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5697
5844
|
tvl: o.tvl || o.zyfiTvl,
|
|
5698
5845
|
asset: o.asset || o.underlying_token,
|
|
5699
5846
|
risk: o.risk,
|
|
5700
|
-
strategyType: "
|
|
5847
|
+
strategyType: "balanced",
|
|
5701
5848
|
status: o.status
|
|
5702
5849
|
})) : []
|
|
5703
5850
|
};
|
|
@@ -5708,15 +5855,15 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5708
5855
|
}
|
|
5709
5856
|
}
|
|
5710
5857
|
/**
|
|
5711
|
-
* Get
|
|
5712
|
-
* `"
|
|
5858
|
+
* Get grow opportunities — pools reachable only with the
|
|
5859
|
+
* `"advanced"` strategy, including protocols whose withdrawals are
|
|
5713
5860
|
* asynchronous (Ipor, Superform). Exiting these pools takes about a day
|
|
5714
5861
|
* on Ipor and three on Superform; track the redemption through
|
|
5715
5862
|
* `getPortfolio().portfolio.pendingAsyncWithdrawals`.
|
|
5716
5863
|
*
|
|
5717
5864
|
* @param chainId - Optional chain ID filter
|
|
5718
5865
|
* @param asset - Optional asset filter (e.g. "USDC", "WETH")
|
|
5719
|
-
* @returns List of
|
|
5866
|
+
* @returns List of grow opportunities
|
|
5720
5867
|
*
|
|
5721
5868
|
* @example
|
|
5722
5869
|
* ```typescript
|
|
@@ -5733,7 +5880,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5733
5880
|
return {
|
|
5734
5881
|
success: true,
|
|
5735
5882
|
chainId,
|
|
5736
|
-
strategyType: "
|
|
5883
|
+
strategyType: "advanced",
|
|
5737
5884
|
data: Array.isArray(data) ? data.map((o) => ({
|
|
5738
5885
|
id: o.id,
|
|
5739
5886
|
protocolId: o.protocol_id || o.protocolId,
|
|
@@ -5744,13 +5891,13 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
5744
5891
|
tvl: o.tvl || o.zyfiTvl,
|
|
5745
5892
|
asset: o.asset || o.underlying_token,
|
|
5746
5893
|
risk: o.risk,
|
|
5747
|
-
strategyType: "
|
|
5894
|
+
strategyType: "advanced",
|
|
5748
5895
|
status: o.status
|
|
5749
5896
|
})) : []
|
|
5750
5897
|
};
|
|
5751
5898
|
} catch (error) {
|
|
5752
5899
|
throw new Error(
|
|
5753
|
-
`Failed to get
|
|
5900
|
+
`Failed to get grow opportunities: ${error.message}`
|
|
5754
5901
|
);
|
|
5755
5902
|
}
|
|
5756
5903
|
}
|
|
@@ -6275,7 +6422,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6275
6422
|
if (strategy) {
|
|
6276
6423
|
if (!isValidPublicStrategy(strategy)) {
|
|
6277
6424
|
throw new Error(
|
|
6278
|
-
`Invalid strategy: ${strategy}. Must be "conservative", "
|
|
6425
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
6279
6426
|
);
|
|
6280
6427
|
}
|
|
6281
6428
|
internalStrategy = toInternalStrategy(strategy);
|
|
@@ -6325,7 +6472,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6325
6472
|
try {
|
|
6326
6473
|
if (!isValidPublicStrategy(params.strategy)) {
|
|
6327
6474
|
throw new Error(
|
|
6328
|
-
`Invalid strategy: ${params.strategy}. Must be "conservative", "
|
|
6475
|
+
`Invalid strategy: ${params.strategy}. Must be "conservative", "balanced" or "advanced".`
|
|
6329
6476
|
);
|
|
6330
6477
|
}
|
|
6331
6478
|
const internalStrategy = toInternalStrategy(params.strategy);
|
|
@@ -6424,7 +6571,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
6424
6571
|
if (!tokenUriResponse.tokenUri) {
|
|
6425
6572
|
throw new Error("API did not return a tokenUri");
|
|
6426
6573
|
}
|
|
6427
|
-
const callData =
|
|
6574
|
+
const callData = encodeFunctionData2({
|
|
6428
6575
|
abi: IDENTITY_REGISTRY_ABI,
|
|
6429
6576
|
functionName: "register",
|
|
6430
6577
|
args: [tokenUriResponse.tokenUri]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "TypeScript SDK for self-custodial Zyfai yield agents: discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum, Base, and Arbitrum",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|