@zyfai/sdk 0.10.0 → 0.12.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 -1
- package/dist/index.d.mts +424 -25
- package/dist/index.d.ts +424 -25
- package/dist/index.js +889 -27
- package/dist/index.mjs +890 -27
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -469,7 +469,21 @@ if (credited.status === "credited") {
|
|
|
469
469
|
- `asset` is required (`"USDC"`, `"WETH"`, `"EURC"`, `"USDT"`, `"PYUSD"`, or `"NVDAc"` — EURC on Mainnet/Base, USDT and PYUSD on Mainnet, NVDAc on Base); token address is selected from that for the chain. Depositing an asset on a chain where it does not exist throws before any transfer.
|
|
470
470
|
- The total Safe balance must meet the per-asset minimum after the deposit (see above). WETH uses a live ETH/USD price, so the wei threshold moves with the market.
|
|
471
471
|
- Call `connectAccount()` on the **same** `ZyfaiSDK` instance before `sendDeposit()`. The method uses that session's JWT when it calls `log_deposit` after the transfer.
|
|
472
|
-
- `sendDeposit()`
|
|
472
|
+
- `sendDeposit(userAddress, chainId, amount, asset)` still transfers that collateral when the wallet already holds it. Pass an object with `spendToken` when the wallet holds a different token or the same token on another chain: the execution API quotes Relay, the wallet signs, and the Safe receives `asset`. Same-chain ETH into WETH wraps in the wallet (`spendToken: "ETH"`). `sendDirectDeposit` and `sendSwapDeposit` are the two steps `sendDeposit` chooses between. Optional `slippageBps` on a swap defaults to 200 (max 500) and is fixed when the funding order is created. Omit it to use the server default. A later `sendSwapDeposit({ orderId })` ignores a new `slippageBps` and signs the stored order.
|
|
473
|
+
|
|
474
|
+
```typescript
|
|
475
|
+
const swapped = await sdk.sendDeposit({
|
|
476
|
+
userAddress,
|
|
477
|
+
chainId: 8453,
|
|
478
|
+
asset: "WETH",
|
|
479
|
+
amount: "10000000",
|
|
480
|
+
spendToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
481
|
+
spendChainId: 42161,
|
|
482
|
+
slippageBps: 200,
|
|
483
|
+
});
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
- `sendDeposit()` confirms the transfer (or the Relay fill) and registers its lifecycle, then returns its ID. Call `waitForDepositPosition()` when the UI should wait until allocation finishes. `waitForDepositCredit()` is the shorter wait for credited balance only.
|
|
473
487
|
- `depositFunds()` remains a compatibility wrapper that calls both steps and waits through the normal completion window; it **rejects** if credit is not confirmed in that window (track in-flight deposits with `getDepositStatus()` or call `waitForDepositCredit()` with a longer `timeoutMs`).
|
|
474
488
|
- If first-deposit protocol patching fails, the transfer still runs. `sendDeposit()` throws if deposit registration is not accepted; retry `logDeposit()` after `connectAccount()`.
|
|
475
489
|
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, EURC, USDT, PYUSD, and NVDAc**, each across the chains it exists on (EURC on Mainnet/Base, USDT and PYUSD on Mainnet, NVDAc on Base → `assetTypeSettings.[usdc|eth|eurc|usdt|pyusd|nvdac]`). Pass optional `strategy` (`"conservative"` default, `"aggressive"` or `"yieldmaxxing"`) — same role as the former `deploySafe` strategy argument. Later deposits skip this.
|
|
@@ -640,6 +654,31 @@ const redeeming = (portfolio.pendingAsyncWithdrawals ?? []).some(
|
|
|
640
654
|
);
|
|
641
655
|
```
|
|
642
656
|
|
|
657
|
+
### Claim rZFI Rewards
|
|
658
|
+
|
|
659
|
+
rZFI accrues to the user's Safe on Base and is claimed by the owner EOA. The
|
|
660
|
+
claim is gas-sponsored and the SDK never signs: you sign one hash in your own
|
|
661
|
+
pipeline.
|
|
662
|
+
|
|
663
|
+
```typescript
|
|
664
|
+
// 1. Prepare (throws if there is nothing to claim)
|
|
665
|
+
const prepared = await sdk.prepareRzfiClaim(userAddress);
|
|
666
|
+
// prepared.claimableAmount (wei), prepared.userOpHashToSign
|
|
667
|
+
|
|
668
|
+
// 2. Sign the raw 32-byte hash with the owner EOA (personal_sign)
|
|
669
|
+
const signature = await walletClient.signMessage({
|
|
670
|
+
account: userAddress,
|
|
671
|
+
message: { raw: prepared.userOpHashToSign! },
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
// 3. Submit within 5 minutes
|
|
675
|
+
const { txHash } = await sdk.submitRzfiClaim(userAddress, signature);
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
`prepared.userOperation` is the full userOp behind the hash if you want to
|
|
679
|
+
verify it before signing. A retryable error means the Merkl reward tree is
|
|
680
|
+
being updated on-chain; call `prepareRzfiClaim` again in a few minutes.
|
|
681
|
+
|
|
643
682
|
### 6. Get Available Protocols
|
|
644
683
|
|
|
645
684
|
Retrieve all available DeFi protocols and pools for a specific chain:
|
|
@@ -1172,6 +1211,17 @@ console.log("APY per strategy:", apyPerStrategy.data);
|
|
|
1172
1211
|
// Each item includes average_apy_withFee and average_apy_with_rzfi_withFee
|
|
1173
1212
|
```
|
|
1174
1213
|
|
|
1214
|
+
### Base Merkl Campaign APR
|
|
1215
|
+
|
|
1216
|
+
Current APR of Zyfai's Merkl incentive campaigns on Base (paid on top of
|
|
1217
|
+
strategy yield). APR is a decimal: `0.011` = 1.1%.
|
|
1218
|
+
|
|
1219
|
+
```typescript
|
|
1220
|
+
const campaigns = await sdk.getBaseMerklCampaigns();
|
|
1221
|
+
// [{ id: "base/rzfi", name, apr, tvlUsd, activeWallets, rewardToken,
|
|
1222
|
+
// totalRewards, dailyRewardAmount, startDate, endDate, isActive }, ...]
|
|
1223
|
+
```
|
|
1224
|
+
|
|
1175
1225
|
### 12. SDK API Key Management
|
|
1176
1226
|
|
|
1177
1227
|
#### Add Wallet to SDK API Key
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { Chain, PublicClient, Address as Address$1 } from 'viem';
|
|
|
3
3
|
/**
|
|
4
4
|
* Public TypeScript types for `@zyfai/sdk` request/response shapes and events.
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
/** Checksummed Ethereum address. */
|
|
7
8
|
type Address = `0x${string}`;
|
|
8
9
|
/** Hex-encoded byte string (e.g. signatures, calldata). */
|
|
@@ -615,12 +616,122 @@ interface DepositResponse {
|
|
|
615
616
|
smartWallet: string;
|
|
616
617
|
/** Deposited amount in least units (decimal string). */
|
|
617
618
|
amount: string;
|
|
619
|
+
/**
|
|
620
|
+
* How the collateral reached the Safe.
|
|
621
|
+
* `direct` transfers the collateral itself. `swap` converts another token
|
|
622
|
+
* through Relay. `wrap` turns same-chain native ETH into WETH, then transfers it.
|
|
623
|
+
*/
|
|
624
|
+
route?: "direct" | "swap" | "wrap";
|
|
625
|
+
/** Relay funding order id when `route` is `swap`. */
|
|
626
|
+
orderId?: string;
|
|
618
627
|
/**
|
|
619
628
|
* Deposit lifecycle record. After `sendDeposit`, status is usually
|
|
620
629
|
* `handover_pending` until {@link ZyfaiSDK.waitForDepositCredit} completes.
|
|
621
630
|
*/
|
|
622
631
|
registration: DepositLifecycleResponse;
|
|
623
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Spend a token that is not already the destination collateral.
|
|
635
|
+
* The execution API quotes Relay; the connected wallet signs the steps.
|
|
636
|
+
*/
|
|
637
|
+
interface SwapDepositParams {
|
|
638
|
+
/** Funding wallet EOA. */
|
|
639
|
+
userAddress: string;
|
|
640
|
+
/** Chain the spent token is on. May differ from the deposit chain. */
|
|
641
|
+
originChainId: number;
|
|
642
|
+
/** Spent token contract. The zero address is native ETH. */
|
|
643
|
+
originCurrency: string;
|
|
644
|
+
/** Spend amount in the origin token's least units. */
|
|
645
|
+
originAmount: string;
|
|
646
|
+
/** Chain the collateral should arrive on. */
|
|
647
|
+
destinationChainId: SupportedChainId;
|
|
648
|
+
/**
|
|
649
|
+
* Collateral Relay should deliver (`USDC`, `WETH`, `EURC`, `cbBTC`, …).
|
|
650
|
+
* The server resolves the contract.
|
|
651
|
+
*/
|
|
652
|
+
destinationAsset: string;
|
|
653
|
+
/** Optional first-deposit {@link Strategy}. */
|
|
654
|
+
strategy?: Strategy;
|
|
655
|
+
/**
|
|
656
|
+
* Max slippage tolerance in basis points (default 200; max 500).
|
|
657
|
+
* Stored on the funding order at quote time. Ignored when `orderId` is set;
|
|
658
|
+
* the stored order's value is used on sign.
|
|
659
|
+
*/
|
|
660
|
+
slippageBps?: number;
|
|
661
|
+
/**
|
|
662
|
+
* Existing review quote to sign. Origin chain, origin token, destination
|
|
663
|
+
* chain, and destination asset must match that order. Omit to create a new
|
|
664
|
+
* funding order.
|
|
665
|
+
*/
|
|
666
|
+
orderId?: string;
|
|
667
|
+
}
|
|
668
|
+
/** Review quote for a Relay swap deposit. The wallet has not signed yet. */
|
|
669
|
+
interface SwapDepositQuote {
|
|
670
|
+
orderId: string;
|
|
671
|
+
status: string;
|
|
672
|
+
spend: string;
|
|
673
|
+
expectedOutput: string;
|
|
674
|
+
minimumOutput: string;
|
|
675
|
+
destinationChainId: number;
|
|
676
|
+
destinationCurrency: string;
|
|
677
|
+
destinationAsset: string;
|
|
678
|
+
fees: {
|
|
679
|
+
name?: string;
|
|
680
|
+
amount?: string;
|
|
681
|
+
amountUsd?: string;
|
|
682
|
+
}[];
|
|
683
|
+
investEligible: boolean;
|
|
684
|
+
expiresAt: string | null;
|
|
685
|
+
timeEstimate?: number | null;
|
|
686
|
+
}
|
|
687
|
+
/** Stored Relay funding order, including any linked deposit lifecycle. */
|
|
688
|
+
interface SwapDepositOrder {
|
|
689
|
+
id: string;
|
|
690
|
+
status: string;
|
|
691
|
+
depositId: string | null;
|
|
692
|
+
sourceTxHashes: string[];
|
|
693
|
+
destinationTxHashes: string[];
|
|
694
|
+
/** Chain the spent token is on. */
|
|
695
|
+
originChainId: number;
|
|
696
|
+
/** Spent token contract stored with the order. */
|
|
697
|
+
originCurrency: string;
|
|
698
|
+
destinationChainId: number;
|
|
699
|
+
destinationCurrency: string;
|
|
700
|
+
destinationAsset: string;
|
|
701
|
+
minimumOutput: string | null;
|
|
702
|
+
providerStatus?: string | null;
|
|
703
|
+
lastError?: string | null;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* `sendDeposit` input. Omit `spendToken` to transfer `asset` on `chainId`.
|
|
707
|
+
* Set `spendToken` when the wallet holds a different token or chain.
|
|
708
|
+
*/
|
|
709
|
+
interface SendDepositParams {
|
|
710
|
+
userAddress: string;
|
|
711
|
+
/** Chain the collateral should arrive on. */
|
|
712
|
+
chainId: SupportedChainId;
|
|
713
|
+
/** Collateral that should land in the Safe. */
|
|
714
|
+
asset: string;
|
|
715
|
+
/**
|
|
716
|
+
* Least units of the token being spent.
|
|
717
|
+
* For a direct deposit this is the collateral amount.
|
|
718
|
+
*/
|
|
719
|
+
amount: string;
|
|
720
|
+
strategy?: Strategy;
|
|
721
|
+
/**
|
|
722
|
+
* Token the wallet spends. A collateral symbol or its contract on `chainId`
|
|
723
|
+
* stays a direct deposit. Anything else is swapped into `asset`.
|
|
724
|
+
*/
|
|
725
|
+
spendToken?: string;
|
|
726
|
+
/** Chain the spend token is on. Defaults to `chainId`. */
|
|
727
|
+
spendChainId?: number;
|
|
728
|
+
/**
|
|
729
|
+
* Max slippage tolerance in basis points when this call swaps (default 200;
|
|
730
|
+
* max 500). Ignored for a direct transfer or a same-chain ETH wrap.
|
|
731
|
+
* Fixed when the funding order is created.
|
|
732
|
+
*/
|
|
733
|
+
slippageBps?: number;
|
|
734
|
+
}
|
|
624
735
|
/**
|
|
625
736
|
* Custody handover and balance-credit states for a registered deposit.
|
|
626
737
|
*
|
|
@@ -665,6 +776,42 @@ interface WithdrawLifecycleResponse {
|
|
|
665
776
|
statusUrl: string;
|
|
666
777
|
estimatedClaimAt?: string | null;
|
|
667
778
|
}
|
|
779
|
+
/** Base Merkl campaign slots served by the data API. */
|
|
780
|
+
type BaseMerklCampaignId = "base" | "base-new-tvl" | "base/rzfi";
|
|
781
|
+
/** A Zyfai Merkl incentive campaign on Base, from {@link ZyfaiSDK.getBaseMerklCampaigns}. */
|
|
782
|
+
interface MerklCampaign {
|
|
783
|
+
id: BaseMerklCampaignId;
|
|
784
|
+
name: string;
|
|
785
|
+
/** Current campaign APR as a decimal (0.011 = 1.1%), on top of strategy yield. */
|
|
786
|
+
apr: number;
|
|
787
|
+
tvlUsd: number;
|
|
788
|
+
activeWallets: number;
|
|
789
|
+
rewardToken: Address;
|
|
790
|
+
totalRewards: number;
|
|
791
|
+
dailyRewardAmount: number;
|
|
792
|
+
startDate: string;
|
|
793
|
+
endDate: string;
|
|
794
|
+
/** True while now is between startDate and endDate. */
|
|
795
|
+
isActive: boolean;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Two-step rZFI claim state from {@link ZyfaiSDK.prepareRzfiClaim} and
|
|
799
|
+
* {@link ZyfaiSDK.submitRzfiClaim}.
|
|
800
|
+
*/
|
|
801
|
+
interface RzfiClaimResponse {
|
|
802
|
+
success: boolean;
|
|
803
|
+
status: "pending" | "claimed";
|
|
804
|
+
/** Safe that receives the rZFI (Base). */
|
|
805
|
+
safeAddress: Address;
|
|
806
|
+
/** rZFI being claimed, in wei (18 decimals). */
|
|
807
|
+
claimableAmount: string;
|
|
808
|
+
/** Present when pending: sign with the owner EOA (personal_sign of the raw hash). */
|
|
809
|
+
userOpHashToSign?: Hex;
|
|
810
|
+
/** Present when pending: the userOperation behind the hash, for verification. */
|
|
811
|
+
userOperation?: Record<string, unknown>;
|
|
812
|
+
/** Present when claimed. */
|
|
813
|
+
txHash?: Hex;
|
|
814
|
+
}
|
|
668
815
|
interface LogDepositResponse {
|
|
669
816
|
success: boolean;
|
|
670
817
|
message: string;
|
|
@@ -1041,20 +1188,6 @@ type DailyApyHistoryPeriod = `${AllowedHistoryDays}D`;
|
|
|
1041
1188
|
* Zyfai SDK Main Class
|
|
1042
1189
|
*/
|
|
1043
1190
|
|
|
1044
|
-
/**
|
|
1045
|
-
* Client for Zyfai execution (`api.zyf.ai`) and intelligence (`defiapi.zyf.ai`) APIs.
|
|
1046
|
-
*
|
|
1047
|
-
* @remarks
|
|
1048
|
-
* The connected wallet from {@link ZyfaiSDK.connectAccount} is used for **signing only**
|
|
1049
|
-
* (SIWE, on-chain transfers). Pass the user's **EOA** as `userAddress` on execution
|
|
1050
|
-
* methods; the backend resolves the assigned Safe.
|
|
1051
|
-
*
|
|
1052
|
-
* First-time onboarding uses predeployed Safes: {@link ZyfaiSDK.sendDeposit} handles
|
|
1053
|
-
* session and deploy-on-first-deposit without {@link ZyfaiSDK.deploySafe} or
|
|
1054
|
-
* {@link ZyfaiSDK.createSessionKey}.
|
|
1055
|
-
*
|
|
1056
|
-
* @see {@link https://docs.zyf.ai/docs/sdk/agent-quickstart | Agent quickstart}
|
|
1057
|
-
*/
|
|
1058
1191
|
declare class ZyfaiSDK {
|
|
1059
1192
|
private httpClient;
|
|
1060
1193
|
private signer;
|
|
@@ -1581,14 +1714,14 @@ declare class ZyfaiSDK {
|
|
|
1581
1714
|
status: string;
|
|
1582
1715
|
}>;
|
|
1583
1716
|
/**
|
|
1584
|
-
* Transfer
|
|
1717
|
+
* Transfer a collateral token the wallet already holds into the Safe.
|
|
1585
1718
|
*
|
|
1586
1719
|
* @remarks
|
|
1587
|
-
*
|
|
1588
|
-
* {@link ZyfaiSDK.
|
|
1589
|
-
*
|
|
1590
|
-
* {@link ZyfaiSDK.logDeposit}, {@link ZyfaiSDK.getDepositStatus}.
|
|
1720
|
+
* Use this when the connected wallet holds the strategy collateral on the
|
|
1721
|
+
* deposit chain. {@link ZyfaiSDK.sendDeposit} calls this automatically in
|
|
1722
|
+
* that case. A different token uses {@link ZyfaiSDK.sendSwapDeposit}.
|
|
1591
1723
|
*
|
|
1724
|
+
* Confirms the ERC-20 `transfer`, then calls {@link ZyfaiSDK.logDeposit}.
|
|
1592
1725
|
* Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
|
|
1593
1726
|
*
|
|
1594
1727
|
* @group Deposits and withdrawals
|
|
@@ -1596,20 +1729,178 @@ declare class ZyfaiSDK {
|
|
|
1596
1729
|
* @param userAddress - Owner EOA (not the Safe)
|
|
1597
1730
|
* @param chainId - Chain for the transfer
|
|
1598
1731
|
* @param amount - Amount in least units (string integer)
|
|
1599
|
-
* @param asset -
|
|
1732
|
+
* @param asset - Collateral symbol (`USDC`, `WETH`, `EURC`, `NVDAc`)
|
|
1600
1733
|
* @param strategy - Optional first-deposit {@link Strategy}
|
|
1601
|
-
* @returns Transfer receipt and deposit registration
|
|
1734
|
+
* @returns Transfer receipt and deposit registration
|
|
1602
1735
|
*
|
|
1603
|
-
* @throws If validation fails, minimum portfolio is not met, Safe is unavailable, or transfer/register fails
|
|
1736
|
+
* @throws If validation fails, the minimum portfolio is not met, the Safe is unavailable, or transfer/register fails
|
|
1737
|
+
*
|
|
1738
|
+
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1604
1739
|
*
|
|
1605
1740
|
* @example
|
|
1606
1741
|
* ```typescript
|
|
1607
1742
|
* await sdk.connectAccount(provider);
|
|
1608
|
-
* const sent = await sdk.
|
|
1609
|
-
* await sdk.
|
|
1743
|
+
* const sent = await sdk.sendDirectDeposit(eoa, 8453, "10000000", "USDC", "conservative");
|
|
1744
|
+
* await sdk.waitForDepositPosition(sent.registration.id, 8453);
|
|
1745
|
+
* ```
|
|
1746
|
+
*/
|
|
1747
|
+
sendDirectDeposit(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1748
|
+
/**
|
|
1749
|
+
* Fund the Safe with a collateral the wallet already holds, or swap another token into it.
|
|
1750
|
+
*
|
|
1751
|
+
* @remarks
|
|
1752
|
+
* The positional call is unchanged: `asset` must be a collateral symbol, and
|
|
1753
|
+
* the wallet transfers that token on `chainId`.
|
|
1754
|
+
*
|
|
1755
|
+
* The object form spends `spendToken`. When that token is the destination
|
|
1756
|
+
* collateral on `chainId`, this is a direct deposit. Any other token is
|
|
1757
|
+
* quoted through Relay and delivered as `asset`. Same-chain native ETH into
|
|
1758
|
+
* WETH is wrapped in the wallet, because Relay rejects that pair.
|
|
1759
|
+
* Optional `slippageBps` on a swap defaults to 200 (max 500) and is fixed
|
|
1760
|
+
* when the funding order is created.
|
|
1761
|
+
*
|
|
1762
|
+
* Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
|
|
1763
|
+
* Follow with {@link ZyfaiSDK.waitForDepositPosition} when the caller should
|
|
1764
|
+
* wait until the deposit is allocated.
|
|
1765
|
+
*
|
|
1766
|
+
* @group Deposits and withdrawals
|
|
1767
|
+
*
|
|
1768
|
+
* @param userAddress - Owner EOA, or a {@link SendDepositParams} object
|
|
1769
|
+
* @param chainId - Deposit chain when using the positional form
|
|
1770
|
+
* @param amount - Least units of the token being spent
|
|
1771
|
+
* @param asset - Collateral that should land in the Safe
|
|
1772
|
+
* @param strategy - Optional first-deposit {@link Strategy}
|
|
1773
|
+
* @returns Transfer receipt and deposit registration
|
|
1774
|
+
*
|
|
1775
|
+
* @throws If the route cannot be quoted, the transfer fails, or registration fails
|
|
1776
|
+
*
|
|
1777
|
+
* @example
|
|
1778
|
+
* ```typescript
|
|
1779
|
+
* await sdk.connectAccount(provider);
|
|
1780
|
+
* // Wallet already holds USDC on Base.
|
|
1781
|
+
* const direct = await sdk.sendDeposit(eoa, 8453, "10000000", "USDC");
|
|
1782
|
+
*
|
|
1783
|
+
* // Wallet holds a different token. Relay delivers USDC to the Safe.
|
|
1784
|
+
* const swapped = await sdk.sendDeposit({
|
|
1785
|
+
* userAddress: eoa,
|
|
1786
|
+
* chainId: 8453,
|
|
1787
|
+
* asset: "USDC",
|
|
1788
|
+
* amount: "1000000000000000000",
|
|
1789
|
+
* spendToken: "0xTokenOnBase",
|
|
1790
|
+
* });
|
|
1791
|
+
* await sdk.waitForDepositPosition(swapped.registration.id, 8453);
|
|
1610
1792
|
* ```
|
|
1611
1793
|
*/
|
|
1612
1794
|
sendDeposit(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1795
|
+
sendDeposit(params: SendDepositParams): Promise<DepositResponse>;
|
|
1796
|
+
/**
|
|
1797
|
+
* Resolve a deposit without signing.
|
|
1798
|
+
*
|
|
1799
|
+
* @remarks
|
|
1800
|
+
* A collateral the wallet already holds on `chainId` returns `route: "direct"`.
|
|
1801
|
+
* Same-chain native ETH into WETH returns `route: "wrap"`. Any other spend
|
|
1802
|
+
* token returns a Relay review quote (`route: "swap"`). Nothing is signed.
|
|
1803
|
+
* Optional `slippageBps` (default 200, max 500) is stored on that funding
|
|
1804
|
+
* order and reused when the quote is refreshed for signing.
|
|
1805
|
+
*
|
|
1806
|
+
* @group Deposits and withdrawals
|
|
1807
|
+
*
|
|
1808
|
+
* @param params - Destination collateral and optional spend token
|
|
1809
|
+
* @returns The route, and a review quote when a swap is required
|
|
1810
|
+
*
|
|
1811
|
+
* @throws If the spend token or destination collateral is not supported
|
|
1812
|
+
*/
|
|
1813
|
+
quoteDeposit(params: SendDepositParams): Promise<{
|
|
1814
|
+
route: "direct" | "wrap";
|
|
1815
|
+
asset: string;
|
|
1816
|
+
chainId: SupportedChainId;
|
|
1817
|
+
amount: string;
|
|
1818
|
+
} | ({
|
|
1819
|
+
route: "swap";
|
|
1820
|
+
} & SwapDepositQuote)>;
|
|
1821
|
+
/**
|
|
1822
|
+
* Quote a Relay swap that delivers a collateral token to the Safe.
|
|
1823
|
+
*
|
|
1824
|
+
* @remarks
|
|
1825
|
+
* Creates a funding order on the execution API. The connected wallet does
|
|
1826
|
+
* not sign. Pass `orderId` to {@link ZyfaiSDK.sendSwapDeposit} to sign the
|
|
1827
|
+
* refreshed quote, or call {@link ZyfaiSDK.sendDeposit} to quote and sign
|
|
1828
|
+
* in one step.
|
|
1829
|
+
*
|
|
1830
|
+
* Same-chain native ETH into WETH is rejected here. Use {@link ZyfaiSDK.sendDeposit}
|
|
1831
|
+
* with `spendToken: "ETH"`, which wraps in the wallet.
|
|
1832
|
+
*
|
|
1833
|
+
* Optional `slippageBps` defaults to 200 (max 500) and is fixed when this
|
|
1834
|
+
* funding order is created. Sign-time refresh reuses the stored value.
|
|
1835
|
+
*
|
|
1836
|
+
* @group Deposits and withdrawals
|
|
1837
|
+
*
|
|
1838
|
+
* @param params - Origin token, destination collateral, and funding wallet
|
|
1839
|
+
* @returns Review quote. Not yet signed.
|
|
1840
|
+
*
|
|
1841
|
+
* @throws If the server rejects the pair, the amount, or the quote
|
|
1842
|
+
*/
|
|
1843
|
+
quoteSwapDeposit(params: SwapDepositParams): Promise<SwapDepositQuote>;
|
|
1844
|
+
/**
|
|
1845
|
+
* Read a Relay funding order, including a linked deposit once credit starts.
|
|
1846
|
+
*
|
|
1847
|
+
* @group Deposits and withdrawals
|
|
1848
|
+
*
|
|
1849
|
+
* @param orderId - Id from {@link ZyfaiSDK.quoteSwapDeposit}
|
|
1850
|
+
* @returns Stored order
|
|
1851
|
+
*
|
|
1852
|
+
* @throws If `orderId` is missing
|
|
1853
|
+
*/
|
|
1854
|
+
getSwapDeposit(orderId: string): Promise<SwapDepositOrder>;
|
|
1855
|
+
/**
|
|
1856
|
+
* Swap or bridge a token into a Zyfai collateral, then register the deposit.
|
|
1857
|
+
*
|
|
1858
|
+
* @remarks
|
|
1859
|
+
* The execution API quotes Relay with the Safe as recipient. This method
|
|
1860
|
+
* refreshes that quote, signs the steps with the connected wallet, waits
|
|
1861
|
+
* for the collateral transfer into the Safe, and calls {@link ZyfaiSDK.logDeposit}.
|
|
1862
|
+
* Credit still requires that verified transfer. A refund or failed fill does
|
|
1863
|
+
* not register a deposit.
|
|
1864
|
+
*
|
|
1865
|
+
* Requires {@link ZyfaiSDK.connectAccount}. Origin chains other than
|
|
1866
|
+
* Ethereum, Base, and Arbitrum need an EIP-1193 wallet that can sign there.
|
|
1867
|
+
*
|
|
1868
|
+
* Optional `slippageBps` defaults to 200 (max 500) and is fixed when the
|
|
1869
|
+
* funding order is created. A later call that passes `orderId` ignores
|
|
1870
|
+
* `slippageBps` and signs the stored order.
|
|
1871
|
+
*
|
|
1872
|
+
* @group Deposits and withdrawals
|
|
1873
|
+
*
|
|
1874
|
+
* @param params - Origin token and destination collateral
|
|
1875
|
+
* @returns Destination transfer and deposit registration
|
|
1876
|
+
*
|
|
1877
|
+
* @throws If the quote, signature, fill, or registration fails, or if
|
|
1878
|
+
* `orderId` names a funding order whose origin or destination differs from
|
|
1879
|
+
* this call
|
|
1880
|
+
*
|
|
1881
|
+
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1882
|
+
*
|
|
1883
|
+
* @example
|
|
1884
|
+
* ```typescript
|
|
1885
|
+
* await sdk.connectAccount(provider);
|
|
1886
|
+
* const sent = await sdk.sendSwapDeposit({
|
|
1887
|
+
* userAddress: eoa,
|
|
1888
|
+
* originChainId: 42161,
|
|
1889
|
+
* originCurrency: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
1890
|
+
* originAmount: "10000000",
|
|
1891
|
+
* destinationChainId: 8453,
|
|
1892
|
+
* destinationAsset: "WETH",
|
|
1893
|
+
* });
|
|
1894
|
+
* ```
|
|
1895
|
+
*/
|
|
1896
|
+
sendSwapDeposit(params: SwapDepositParams): Promise<DepositResponse>;
|
|
1897
|
+
private sendRoutedDeposit;
|
|
1898
|
+
/** Portfolio floor used by a direct deposit, applied before a wrap or swap spends. */
|
|
1899
|
+
private assertCollateralMinimum;
|
|
1900
|
+
private assertSwapDepositParams;
|
|
1901
|
+
private walletClientForOrigin;
|
|
1902
|
+
private wrapNativeEth;
|
|
1903
|
+
private waitForRelayCreditTx;
|
|
1613
1904
|
/**
|
|
1614
1905
|
* @deprecated Compatibility convenience method. Prefer {@link ZyfaiSDK.sendDeposit} followed by
|
|
1615
1906
|
* {@link ZyfaiSDK.waitForDepositCredit} when the caller owns the completion UX.
|
|
@@ -1648,6 +1939,37 @@ declare class ZyfaiSDK {
|
|
|
1648
1939
|
data: Hex;
|
|
1649
1940
|
value: "0";
|
|
1650
1941
|
}>;
|
|
1942
|
+
/**
|
|
1943
|
+
* Prepare a gas-sponsored rZFI claim into the user's Safe on Base.
|
|
1944
|
+
*
|
|
1945
|
+
* @remarks
|
|
1946
|
+
* The SDK never signs. Sign `userOpHashToSign` with the owner EOA as a
|
|
1947
|
+
* personal_sign of the raw 32-byte hash (viem:
|
|
1948
|
+
* `signMessage({ message: { raw: userOpHashToSign } })`), then pass the
|
|
1949
|
+
* signature to {@link ZyfaiSDK.submitRzfiClaim} within 5 minutes.
|
|
1950
|
+
* Requires an authenticated user session.
|
|
1951
|
+
*
|
|
1952
|
+
* @group Rewards
|
|
1953
|
+
*
|
|
1954
|
+
* @param userAddress - Owner EOA
|
|
1955
|
+
* @returns `status: "pending"` with the hash to sign and the amount
|
|
1956
|
+
*
|
|
1957
|
+
* @throws If there is no rZFI to claim, or the reward tree is updating (retry later)
|
|
1958
|
+
*/
|
|
1959
|
+
prepareRzfiClaim(userAddress: string): Promise<RzfiClaimResponse>;
|
|
1960
|
+
/**
|
|
1961
|
+
* Submit the owner-signed rZFI claim prepared by {@link ZyfaiSDK.prepareRzfiClaim}.
|
|
1962
|
+
*
|
|
1963
|
+
* @group Rewards
|
|
1964
|
+
*
|
|
1965
|
+
* @param userAddress - Owner EOA
|
|
1966
|
+
* @param userOpSignature - Owner EOA signature over `userOpHashToSign`
|
|
1967
|
+
* @returns `status: "claimed"` with the on-chain `txHash`
|
|
1968
|
+
*
|
|
1969
|
+
* @throws If the signature is not the owner's, the claim expired, or it reverted
|
|
1970
|
+
*/
|
|
1971
|
+
submitRzfiClaim(userAddress: string, userOpSignature: Hex): Promise<RzfiClaimResponse>;
|
|
1972
|
+
private assertRzfiClaimUser;
|
|
1651
1973
|
/** Apply the same per-asset minimum portfolio rule as sendDeposit. */
|
|
1652
1974
|
private enforceMinimumPortfolioBalance;
|
|
1653
1975
|
/**
|
|
@@ -1675,6 +1997,16 @@ declare class ZyfaiSDK {
|
|
|
1675
1997
|
* @internal
|
|
1676
1998
|
*/
|
|
1677
1999
|
private ensureDepositProfileForPrepare;
|
|
2000
|
+
/**
|
|
2001
|
+
* Persist the deposit asset on one chain before a signing page runs the transfer or swap.
|
|
2002
|
+
* Does not build calldata and does not check the portfolio minimum.
|
|
2003
|
+
*/
|
|
2004
|
+
ensureDepositAssetOnChain(params: {
|
|
2005
|
+
asset: SupportedAsset;
|
|
2006
|
+
chainId: SupportedChainId;
|
|
2007
|
+
}): Promise<{
|
|
2008
|
+
applied: boolean;
|
|
2009
|
+
}>;
|
|
1678
2010
|
/**
|
|
1679
2011
|
* Prepare a deposit: persist first-deposit profile when needed and return
|
|
1680
2012
|
* ERC-20 transfer calldata for the user to sign (does not broadcast).
|
|
@@ -1993,6 +2325,24 @@ declare class ZyfaiSDK {
|
|
|
1993
2325
|
* ```
|
|
1994
2326
|
*/
|
|
1995
2327
|
getUserDetails(asset?: SupportedAsset): Promise<UpdateUserProfileResponse>;
|
|
2328
|
+
/**
|
|
2329
|
+
* Get Zyfai's Merkl incentive campaigns on Base with their current APR.
|
|
2330
|
+
*
|
|
2331
|
+
* @group Analytics and opportunities
|
|
2332
|
+
*
|
|
2333
|
+
* @remarks Data API. Partner API key only; SIWE not required.
|
|
2334
|
+
*
|
|
2335
|
+
* @returns One entry per campaign slot (rZFI, new TVL, season campaign)
|
|
2336
|
+
*
|
|
2337
|
+
* @example
|
|
2338
|
+
* ```typescript
|
|
2339
|
+
* const campaigns = await sdk.getBaseMerklCampaigns();
|
|
2340
|
+
* for (const c of campaigns.filter((c) => c.isActive)) {
|
|
2341
|
+
* console.log(c.name, `${(c.apr * 100).toFixed(2)}%`);
|
|
2342
|
+
* }
|
|
2343
|
+
* ```
|
|
2344
|
+
*/
|
|
2345
|
+
getBaseMerklCampaigns(): Promise<MerklCampaign[]>;
|
|
1996
2346
|
/**
|
|
1997
2347
|
* Get total value locked (TVL) across all Zyfai accounts.
|
|
1998
2348
|
*
|
|
@@ -2752,6 +3102,55 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
|
2752
3102
|
*/
|
|
2753
3103
|
declare function getManagedAssets(): SupportedAsset[];
|
|
2754
3104
|
|
|
3105
|
+
type DepositRoute = {
|
|
3106
|
+
kind: "direct";
|
|
3107
|
+
asset: string;
|
|
3108
|
+
} | {
|
|
3109
|
+
kind: "wrap";
|
|
3110
|
+
asset: "WETH";
|
|
3111
|
+
} | {
|
|
3112
|
+
kind: "swap";
|
|
3113
|
+
originChainId: number;
|
|
3114
|
+
originCurrency: string;
|
|
3115
|
+
destinationAsset: string;
|
|
3116
|
+
};
|
|
3117
|
+
type DepositRouteInput = {
|
|
3118
|
+
/** Chain the collateral should arrive on. */
|
|
3119
|
+
chainId: number;
|
|
3120
|
+
/** Collateral symbol that should land in the Safe. */
|
|
3121
|
+
asset: string;
|
|
3122
|
+
/**
|
|
3123
|
+
* Token the wallet spends. Omit to spend `asset` on `chainId`.
|
|
3124
|
+
* A symbol or contract equal to that collateral on `chainId` is a direct deposit.
|
|
3125
|
+
*/
|
|
3126
|
+
spendToken?: string;
|
|
3127
|
+
/** Chain the spend token is on. Defaults to `chainId`. */
|
|
3128
|
+
spendChainId?: number;
|
|
3129
|
+
};
|
|
3130
|
+
/**
|
|
3131
|
+
* Choose a direct collateral transfer, a same-chain ETH wrap, or a Relay swap.
|
|
3132
|
+
*
|
|
3133
|
+
* A direct deposit is only when the wallet already holds the destination
|
|
3134
|
+
* collateral on the destination chain. Any other spend token is a swap.
|
|
3135
|
+
* Same-chain native ETH into WETH wraps in the wallet: Relay rejects that pair.
|
|
3136
|
+
*/
|
|
3137
|
+
declare const resolveDepositRoute: (input: DepositRouteInput) => DepositRoute;
|
|
3138
|
+
|
|
3139
|
+
/** Matches the execution API and the deposit UI default. */
|
|
3140
|
+
declare const DEFAULT_RELAY_SLIPPAGE_BPS = 200;
|
|
3141
|
+
/** Hard cap accepted by `POST /users/me/funding-orders`. */
|
|
3142
|
+
declare const MAX_RELAY_SLIPPAGE_BPS = 500;
|
|
3143
|
+
/**
|
|
3144
|
+
* Dashboard presets (basis points). Any integer from 1 to
|
|
3145
|
+
* {@link MAX_RELAY_SLIPPAGE_BPS} is valid; these are the usual choices.
|
|
3146
|
+
*/
|
|
3147
|
+
declare const RELAY_SLIPPAGE_PRESETS_BPS: readonly [50, 200, 500];
|
|
3148
|
+
/**
|
|
3149
|
+
* Clamp a client slippage to the range the execution API stores.
|
|
3150
|
+
* Omitted or non-finite values use {@link DEFAULT_RELAY_SLIPPAGE_BPS}.
|
|
3151
|
+
*/
|
|
3152
|
+
declare const resolveRelaySlippageBps: (clientBps?: number | null) => number;
|
|
3153
|
+
|
|
2755
3154
|
/**
|
|
2756
3155
|
* API Endpoints Configuration
|
|
2757
3156
|
*
|
|
@@ -2851,4 +3250,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
2851
3250
|
*/
|
|
2852
3251
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
2853
3252
|
|
|
2854
|
-
export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
|
3253
|
+
export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, resolveDepositRoute, resolveRelaySlippageBps, type staleBalances };
|