@zyfai/sdk 0.10.0 → 0.11.2
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 +15 -1
- package/dist/index.d.mts +339 -25
- package/dist/index.d.ts +339 -25
- package/dist/index.js +790 -27
- package/dist/index.mjs +791 -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.
|
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
|
*
|
|
@@ -1041,20 +1152,6 @@ type DailyApyHistoryPeriod = `${AllowedHistoryDays}D`;
|
|
|
1041
1152
|
* Zyfai SDK Main Class
|
|
1042
1153
|
*/
|
|
1043
1154
|
|
|
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
1155
|
declare class ZyfaiSDK {
|
|
1059
1156
|
private httpClient;
|
|
1060
1157
|
private signer;
|
|
@@ -1581,14 +1678,14 @@ declare class ZyfaiSDK {
|
|
|
1581
1678
|
status: string;
|
|
1582
1679
|
}>;
|
|
1583
1680
|
/**
|
|
1584
|
-
* Transfer
|
|
1681
|
+
* Transfer a collateral token the wallet already holds into the Safe.
|
|
1585
1682
|
*
|
|
1586
1683
|
* @remarks
|
|
1587
|
-
*
|
|
1588
|
-
* {@link ZyfaiSDK.
|
|
1589
|
-
*
|
|
1590
|
-
* {@link ZyfaiSDK.logDeposit}, {@link ZyfaiSDK.getDepositStatus}.
|
|
1684
|
+
* Use this when the connected wallet holds the strategy collateral on the
|
|
1685
|
+
* deposit chain. {@link ZyfaiSDK.sendDeposit} calls this automatically in
|
|
1686
|
+
* that case. A different token uses {@link ZyfaiSDK.sendSwapDeposit}.
|
|
1591
1687
|
*
|
|
1688
|
+
* Confirms the ERC-20 `transfer`, then calls {@link ZyfaiSDK.logDeposit}.
|
|
1592
1689
|
* Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
|
|
1593
1690
|
*
|
|
1594
1691
|
* @group Deposits and withdrawals
|
|
@@ -1596,20 +1693,178 @@ declare class ZyfaiSDK {
|
|
|
1596
1693
|
* @param userAddress - Owner EOA (not the Safe)
|
|
1597
1694
|
* @param chainId - Chain for the transfer
|
|
1598
1695
|
* @param amount - Amount in least units (string integer)
|
|
1599
|
-
* @param asset -
|
|
1696
|
+
* @param asset - Collateral symbol (`USDC`, `WETH`, `EURC`, `NVDAc`)
|
|
1600
1697
|
* @param strategy - Optional first-deposit {@link Strategy}
|
|
1601
|
-
* @returns Transfer receipt and deposit registration
|
|
1698
|
+
* @returns Transfer receipt and deposit registration
|
|
1699
|
+
*
|
|
1700
|
+
* @throws If validation fails, the minimum portfolio is not met, the Safe is unavailable, or transfer/register fails
|
|
1602
1701
|
*
|
|
1603
|
-
* @
|
|
1702
|
+
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1604
1703
|
*
|
|
1605
1704
|
* @example
|
|
1606
1705
|
* ```typescript
|
|
1607
1706
|
* await sdk.connectAccount(provider);
|
|
1608
|
-
* const sent = await sdk.
|
|
1609
|
-
* await sdk.
|
|
1707
|
+
* const sent = await sdk.sendDirectDeposit(eoa, 8453, "10000000", "USDC", "conservative");
|
|
1708
|
+
* await sdk.waitForDepositPosition(sent.registration.id, 8453);
|
|
1709
|
+
* ```
|
|
1710
|
+
*/
|
|
1711
|
+
sendDirectDeposit(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1712
|
+
/**
|
|
1713
|
+
* Fund the Safe with a collateral the wallet already holds, or swap another token into it.
|
|
1714
|
+
*
|
|
1715
|
+
* @remarks
|
|
1716
|
+
* The positional call is unchanged: `asset` must be a collateral symbol, and
|
|
1717
|
+
* the wallet transfers that token on `chainId`.
|
|
1718
|
+
*
|
|
1719
|
+
* The object form spends `spendToken`. When that token is the destination
|
|
1720
|
+
* collateral on `chainId`, this is a direct deposit. Any other token is
|
|
1721
|
+
* quoted through Relay and delivered as `asset`. Same-chain native ETH into
|
|
1722
|
+
* WETH is wrapped in the wallet, because Relay rejects that pair.
|
|
1723
|
+
* Optional `slippageBps` on a swap defaults to 200 (max 500) and is fixed
|
|
1724
|
+
* when the funding order is created.
|
|
1725
|
+
*
|
|
1726
|
+
* Requires {@link ZyfaiSDK.connectAccount}. Pass the **EOA** as `userAddress`.
|
|
1727
|
+
* Follow with {@link ZyfaiSDK.waitForDepositPosition} when the caller should
|
|
1728
|
+
* wait until the deposit is allocated.
|
|
1729
|
+
*
|
|
1730
|
+
* @group Deposits and withdrawals
|
|
1731
|
+
*
|
|
1732
|
+
* @param userAddress - Owner EOA, or a {@link SendDepositParams} object
|
|
1733
|
+
* @param chainId - Deposit chain when using the positional form
|
|
1734
|
+
* @param amount - Least units of the token being spent
|
|
1735
|
+
* @param asset - Collateral that should land in the Safe
|
|
1736
|
+
* @param strategy - Optional first-deposit {@link Strategy}
|
|
1737
|
+
* @returns Transfer receipt and deposit registration
|
|
1738
|
+
*
|
|
1739
|
+
* @throws If the route cannot be quoted, the transfer fails, or registration fails
|
|
1740
|
+
*
|
|
1741
|
+
* @example
|
|
1742
|
+
* ```typescript
|
|
1743
|
+
* await sdk.connectAccount(provider);
|
|
1744
|
+
* // Wallet already holds USDC on Base.
|
|
1745
|
+
* const direct = await sdk.sendDeposit(eoa, 8453, "10000000", "USDC");
|
|
1746
|
+
*
|
|
1747
|
+
* // Wallet holds a different token. Relay delivers USDC to the Safe.
|
|
1748
|
+
* const swapped = await sdk.sendDeposit({
|
|
1749
|
+
* userAddress: eoa,
|
|
1750
|
+
* chainId: 8453,
|
|
1751
|
+
* asset: "USDC",
|
|
1752
|
+
* amount: "1000000000000000000",
|
|
1753
|
+
* spendToken: "0xTokenOnBase",
|
|
1754
|
+
* });
|
|
1755
|
+
* await sdk.waitForDepositPosition(swapped.registration.id, 8453);
|
|
1610
1756
|
* ```
|
|
1611
1757
|
*/
|
|
1612
1758
|
sendDeposit(userAddress: string, chainId: SupportedChainId, amount: string, asset: string, strategy?: Strategy): Promise<DepositResponse>;
|
|
1759
|
+
sendDeposit(params: SendDepositParams): Promise<DepositResponse>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Resolve a deposit without signing.
|
|
1762
|
+
*
|
|
1763
|
+
* @remarks
|
|
1764
|
+
* A collateral the wallet already holds on `chainId` returns `route: "direct"`.
|
|
1765
|
+
* Same-chain native ETH into WETH returns `route: "wrap"`. Any other spend
|
|
1766
|
+
* token returns a Relay review quote (`route: "swap"`). Nothing is signed.
|
|
1767
|
+
* Optional `slippageBps` (default 200, max 500) is stored on that funding
|
|
1768
|
+
* order and reused when the quote is refreshed for signing.
|
|
1769
|
+
*
|
|
1770
|
+
* @group Deposits and withdrawals
|
|
1771
|
+
*
|
|
1772
|
+
* @param params - Destination collateral and optional spend token
|
|
1773
|
+
* @returns The route, and a review quote when a swap is required
|
|
1774
|
+
*
|
|
1775
|
+
* @throws If the spend token or destination collateral is not supported
|
|
1776
|
+
*/
|
|
1777
|
+
quoteDeposit(params: SendDepositParams): Promise<{
|
|
1778
|
+
route: "direct" | "wrap";
|
|
1779
|
+
asset: string;
|
|
1780
|
+
chainId: SupportedChainId;
|
|
1781
|
+
amount: string;
|
|
1782
|
+
} | ({
|
|
1783
|
+
route: "swap";
|
|
1784
|
+
} & SwapDepositQuote)>;
|
|
1785
|
+
/**
|
|
1786
|
+
* Quote a Relay swap that delivers a collateral token to the Safe.
|
|
1787
|
+
*
|
|
1788
|
+
* @remarks
|
|
1789
|
+
* Creates a funding order on the execution API. The connected wallet does
|
|
1790
|
+
* not sign. Pass `orderId` to {@link ZyfaiSDK.sendSwapDeposit} to sign the
|
|
1791
|
+
* refreshed quote, or call {@link ZyfaiSDK.sendDeposit} to quote and sign
|
|
1792
|
+
* in one step.
|
|
1793
|
+
*
|
|
1794
|
+
* Same-chain native ETH into WETH is rejected here. Use {@link ZyfaiSDK.sendDeposit}
|
|
1795
|
+
* with `spendToken: "ETH"`, which wraps in the wallet.
|
|
1796
|
+
*
|
|
1797
|
+
* Optional `slippageBps` defaults to 200 (max 500) and is fixed when this
|
|
1798
|
+
* funding order is created. Sign-time refresh reuses the stored value.
|
|
1799
|
+
*
|
|
1800
|
+
* @group Deposits and withdrawals
|
|
1801
|
+
*
|
|
1802
|
+
* @param params - Origin token, destination collateral, and funding wallet
|
|
1803
|
+
* @returns Review quote. Not yet signed.
|
|
1804
|
+
*
|
|
1805
|
+
* @throws If the server rejects the pair, the amount, or the quote
|
|
1806
|
+
*/
|
|
1807
|
+
quoteSwapDeposit(params: SwapDepositParams): Promise<SwapDepositQuote>;
|
|
1808
|
+
/**
|
|
1809
|
+
* Read a Relay funding order, including a linked deposit once credit starts.
|
|
1810
|
+
*
|
|
1811
|
+
* @group Deposits and withdrawals
|
|
1812
|
+
*
|
|
1813
|
+
* @param orderId - Id from {@link ZyfaiSDK.quoteSwapDeposit}
|
|
1814
|
+
* @returns Stored order
|
|
1815
|
+
*
|
|
1816
|
+
* @throws If `orderId` is missing
|
|
1817
|
+
*/
|
|
1818
|
+
getSwapDeposit(orderId: string): Promise<SwapDepositOrder>;
|
|
1819
|
+
/**
|
|
1820
|
+
* Swap or bridge a token into a Zyfai collateral, then register the deposit.
|
|
1821
|
+
*
|
|
1822
|
+
* @remarks
|
|
1823
|
+
* The execution API quotes Relay with the Safe as recipient. This method
|
|
1824
|
+
* refreshes that quote, signs the steps with the connected wallet, waits
|
|
1825
|
+
* for the collateral transfer into the Safe, and calls {@link ZyfaiSDK.logDeposit}.
|
|
1826
|
+
* Credit still requires that verified transfer. A refund or failed fill does
|
|
1827
|
+
* not register a deposit.
|
|
1828
|
+
*
|
|
1829
|
+
* Requires {@link ZyfaiSDK.connectAccount}. Origin chains other than
|
|
1830
|
+
* Ethereum, Base, and Arbitrum need an EIP-1193 wallet that can sign there.
|
|
1831
|
+
*
|
|
1832
|
+
* Optional `slippageBps` defaults to 200 (max 500) and is fixed when the
|
|
1833
|
+
* funding order is created. A later call that passes `orderId` ignores
|
|
1834
|
+
* `slippageBps` and signs the stored order.
|
|
1835
|
+
*
|
|
1836
|
+
* @group Deposits and withdrawals
|
|
1837
|
+
*
|
|
1838
|
+
* @param params - Origin token and destination collateral
|
|
1839
|
+
* @returns Destination transfer and deposit registration
|
|
1840
|
+
*
|
|
1841
|
+
* @throws If the quote, signature, fill, or registration fails, or if
|
|
1842
|
+
* `orderId` names a funding order whose origin or destination differs from
|
|
1843
|
+
* this call
|
|
1844
|
+
*
|
|
1845
|
+
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1846
|
+
*
|
|
1847
|
+
* @example
|
|
1848
|
+
* ```typescript
|
|
1849
|
+
* await sdk.connectAccount(provider);
|
|
1850
|
+
* const sent = await sdk.sendSwapDeposit({
|
|
1851
|
+
* userAddress: eoa,
|
|
1852
|
+
* originChainId: 42161,
|
|
1853
|
+
* originCurrency: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
1854
|
+
* originAmount: "10000000",
|
|
1855
|
+
* destinationChainId: 8453,
|
|
1856
|
+
* destinationAsset: "WETH",
|
|
1857
|
+
* });
|
|
1858
|
+
* ```
|
|
1859
|
+
*/
|
|
1860
|
+
sendSwapDeposit(params: SwapDepositParams): Promise<DepositResponse>;
|
|
1861
|
+
private sendRoutedDeposit;
|
|
1862
|
+
/** Portfolio floor used by a direct deposit, applied before a wrap or swap spends. */
|
|
1863
|
+
private assertCollateralMinimum;
|
|
1864
|
+
private assertSwapDepositParams;
|
|
1865
|
+
private walletClientForOrigin;
|
|
1866
|
+
private wrapNativeEth;
|
|
1867
|
+
private waitForRelayCreditTx;
|
|
1613
1868
|
/**
|
|
1614
1869
|
* @deprecated Compatibility convenience method. Prefer {@link ZyfaiSDK.sendDeposit} followed by
|
|
1615
1870
|
* {@link ZyfaiSDK.waitForDepositCredit} when the caller owns the completion UX.
|
|
@@ -1675,6 +1930,16 @@ declare class ZyfaiSDK {
|
|
|
1675
1930
|
* @internal
|
|
1676
1931
|
*/
|
|
1677
1932
|
private ensureDepositProfileForPrepare;
|
|
1933
|
+
/**
|
|
1934
|
+
* Persist the deposit asset on one chain before a signing page runs the transfer or swap.
|
|
1935
|
+
* Does not build calldata and does not check the portfolio minimum.
|
|
1936
|
+
*/
|
|
1937
|
+
ensureDepositAssetOnChain(params: {
|
|
1938
|
+
asset: SupportedAsset;
|
|
1939
|
+
chainId: SupportedChainId;
|
|
1940
|
+
}): Promise<{
|
|
1941
|
+
applied: boolean;
|
|
1942
|
+
}>;
|
|
1678
1943
|
/**
|
|
1679
1944
|
* Prepare a deposit: persist first-deposit profile when needed and return
|
|
1680
1945
|
* ERC-20 transfer calldata for the user to sign (does not broadcast).
|
|
@@ -2752,6 +3017,55 @@ type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
|
2752
3017
|
*/
|
|
2753
3018
|
declare function getManagedAssets(): SupportedAsset[];
|
|
2754
3019
|
|
|
3020
|
+
type DepositRoute = {
|
|
3021
|
+
kind: "direct";
|
|
3022
|
+
asset: string;
|
|
3023
|
+
} | {
|
|
3024
|
+
kind: "wrap";
|
|
3025
|
+
asset: "WETH";
|
|
3026
|
+
} | {
|
|
3027
|
+
kind: "swap";
|
|
3028
|
+
originChainId: number;
|
|
3029
|
+
originCurrency: string;
|
|
3030
|
+
destinationAsset: string;
|
|
3031
|
+
};
|
|
3032
|
+
type DepositRouteInput = {
|
|
3033
|
+
/** Chain the collateral should arrive on. */
|
|
3034
|
+
chainId: number;
|
|
3035
|
+
/** Collateral symbol that should land in the Safe. */
|
|
3036
|
+
asset: string;
|
|
3037
|
+
/**
|
|
3038
|
+
* Token the wallet spends. Omit to spend `asset` on `chainId`.
|
|
3039
|
+
* A symbol or contract equal to that collateral on `chainId` is a direct deposit.
|
|
3040
|
+
*/
|
|
3041
|
+
spendToken?: string;
|
|
3042
|
+
/** Chain the spend token is on. Defaults to `chainId`. */
|
|
3043
|
+
spendChainId?: number;
|
|
3044
|
+
};
|
|
3045
|
+
/**
|
|
3046
|
+
* Choose a direct collateral transfer, a same-chain ETH wrap, or a Relay swap.
|
|
3047
|
+
*
|
|
3048
|
+
* A direct deposit is only when the wallet already holds the destination
|
|
3049
|
+
* collateral on the destination chain. Any other spend token is a swap.
|
|
3050
|
+
* Same-chain native ETH into WETH wraps in the wallet: Relay rejects that pair.
|
|
3051
|
+
*/
|
|
3052
|
+
declare const resolveDepositRoute: (input: DepositRouteInput) => DepositRoute;
|
|
3053
|
+
|
|
3054
|
+
/** Matches the execution API and the deposit UI default. */
|
|
3055
|
+
declare const DEFAULT_RELAY_SLIPPAGE_BPS = 200;
|
|
3056
|
+
/** Hard cap accepted by `POST /users/me/funding-orders`. */
|
|
3057
|
+
declare const MAX_RELAY_SLIPPAGE_BPS = 500;
|
|
3058
|
+
/**
|
|
3059
|
+
* Dashboard presets (basis points). Any integer from 1 to
|
|
3060
|
+
* {@link MAX_RELAY_SLIPPAGE_BPS} is valid; these are the usual choices.
|
|
3061
|
+
*/
|
|
3062
|
+
declare const RELAY_SLIPPAGE_PRESETS_BPS: readonly [50, 200, 500];
|
|
3063
|
+
/**
|
|
3064
|
+
* Clamp a client slippage to the range the execution API stores.
|
|
3065
|
+
* Omitted or non-finite values use {@link DEFAULT_RELAY_SLIPPAGE_BPS}.
|
|
3066
|
+
*/
|
|
3067
|
+
declare const resolveRelaySlippageBps: (clientBps?: number | null) => number;
|
|
3068
|
+
|
|
2755
3069
|
/**
|
|
2756
3070
|
* API Endpoints Configuration
|
|
2757
3071
|
*
|
|
@@ -2851,4 +3165,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
2851
3165
|
*/
|
|
2852
3166
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
2853
3167
|
|
|
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 };
|
|
3168
|
+
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_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 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, 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 };
|