Enso 백서

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 35쪽 중 11쪽

earn vault. The `amountOut` represents vault shares, not underlying tokens. ### 3. Vault Migration Move from one yield protocol to another - exit Yearn vault and enter Aave lending position. <CodeGroup> ```typescript SDK theme={null} // yvWETH → aWETH (migrate from Yearn to Aave) const migration = await ensoClient.getRouteData({ fromAddress, receiver, spender, chainId: 1, amountIn: ["1000000000000000000"], // 1 yvWETH tokenIn: ["0xa258c4606ca8206d8aa700ce2143d7db854d168c"], // yvWETH tokenOut: ["0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8"], // aWETH slippage: "100", // 1% routingStrategy: "delegate" }); console.log('aWETH tokens received:', migration.amountOut); console.log('Migration complexity:', migration.route.length, 'steps'); // Route: yvWETH → withdraw to WETH → deposit to Aave → receive aWETH ``` ```bash cURL theme={null} # Route: yvWETH → withdraw to WETH → deposit to Aave → receive aWETH curl --request POST \ --url https://api.enso.build/api/v1/shortcuts/route \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $ENSO_API_KEY" \ --data '{ "chainId": 1, "fromAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "routingStrategy": "delegate", "receiver": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "spender": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "tokenIn": ["0xa258c4606ca8206d8aa700ce2143d7db854d168c"], "tokenOut": ["0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8"], "amountIn": ["1000000000000000000"], "slippage": "100" }' | jq ``` </CodeGroup> **Complex routing:** This involves exiting one protocol (Yearn) and entering another (Aave). The route array will show multiple steps including withdrawal, potential swaps, and final deposit. ### 4. Crosschain Transfer Move assets between blockchains using Enso's integrated bridge routing. <CodeGroup> ```typescript SDK theme={null} // USDC from Ethereum → USDC.e on Plume Network const crossChain = await ensoClient.getRouteData({ fromAddress, receiver, spender, chainId: 1, // Ethereum destinationChainId: 98866, // Plume Network amountIn: ["1000000000"], // 1,000 USDC tokenIn: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], // USDC on Ethereum tokenOut: ["0x78adD880A697070c1e765Ac44D65323a0DcCE913"], // USDC.e on Plume slippage: "300", // 3% (higher for crosschain) routingStrategy: "delegate" }); console.log('USDC.e on Plume:', crossChain.amountOut); console.log('Bridge fee:', crossChain.feeAmount); console.log('Crosschain complexity:', crossChain.route.length, 'steps'); ``` ```bash cURL theme={null} # USDC from Ethereum → USDC.e on Plume Network curl --request POST \ --url https://api.enso.build/api/v1/shortcuts/route \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $ENSO_API_KEY" \ --data '{ "chainId": 1, "destinationChainId": 98866, "fromAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "routingStrategy": "delegate", "receiver": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "spender": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "tokenIn": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], "tokenOut": ["0x78adD880A697070c1e765Ac44D65323a0DcCE913"], "amountIn": ["1000000000"], "slippage": "300" }' | jq ``` </CodeGroup> **Crosschain considerations:** Higher slippage accounts for bridge fees and potential price differences. The `feeAmount` shows bridge costs, and `route` reveals pre- and post- bridging steps. ### 5. Crosschain Vault Zapping The most complex example: bridge assets and enter a vault on the destination chain in one transaction. <CodeGroup> ```typescript SDK theme={null} // USDC Ethereum → myPUSD vault on Plume (crosschain vault zap) const crossChainVault = await ensoClient.getRouteData({ fromAddress, receiver, spender, chainId: 1, // Ethereum destinationChainId: 98866, // Plume Network amountIn: ["2000000000"], // 2,000 USDC tokenIn: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], // USDC on Ethereum tokenOut: ["0xAf5aEAb2248415716569Be5d24FbE10b16590D6c"], // myPUSD vault on Plume slippage: "500", // 5% (complex crosschain + vault operation) routingStrategy: "delegate" }); console.log('myPUSD vault shares:', crossChainVault.amountOut); console.log('Total route steps:', crossChainVault.route.length); console.log('Estimated gas:', crossChainVault.gas); ``` ```bash cURL theme={null} # USDC Ethereum → myPUSD vault on Plume (crosschain vault zap) curl --request POST \ --url https://api.enso.build/api/v1/shortcuts/route \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $ENSO_API_KEY" \ --data '{ "chainId": 1, "destinationChainId": 98866, "fromAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "routingStrategy": "delegate", "receiver": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "spender": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", "tokenIn": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], "tokenOut": ["0xAf5aEAb2248415716569Be5d24FbE10b16590D6c"], "amountIn": ["2000000000"], "slippage": "500" }' | jq ``` </CodeGroup> **Maximum complexity:** This combines crosschain bridging with vault interaction. ## Route vs Bundle Output Route returns a single optimized path from the requested input position to the requested output position. The `route` array explains the actions Enso selected, while `tx`, `amountOut`, and `gas` are the execution fields your application should display and submit. Bundle returns a transaction built from the explicit actions you provide. When bundled actions include routing, the response can also include route-style information for those routed segments, giving users and reviewers more transparency into how the final transaction was constructed. Use Route when the product can express the desired outcome as `tokenIn -> tokenOut`. Use Bundle when the product must control the exact sequence of actions, such as checking a bridged balance, harvesting rewards, borrowing, repaying, or depositing through a protocol-specific path. ## Related APIs & Next Steps ### When to Use Other APIs * **[Bundle API](/api-reference/defi-shortcuts/bundle-a-list-of-actions)**: When you need custom multi-step logic or want to orchestrate specific actions in sequence, or you need actions beyond `swap`, `deposit` and `redeem` the route API uses * **[Nontokenized Positions](/api-reference/defi-shortcuts/routing-to-a-non-tokenized-position)**: For lending positions that don't issue tokens (like Aave debt positions) * **[Approval Endpoint](/api-reference/defi-shortcuts/approve-enso-contract)**: Managing token permissions when using `"router"` strategy ### Supporting APIs * **[Tokens API](/api-reference/tokens/tokens)**: Discover available tokens and their addresses across chains * **[Prices API](/api-reference/tokens/token-price)**: Get current token valuations for your UI * **[Networks API](/api-reference/integration/networks)**: List supported chains and their details <div> <p>Updated </p> </div> # Solana routing Source: https://docs.enso.build/pages/build/get-started/solana-routing Route assets from EVM chains to Solana and track delivery or refunds. The Route API supports EVM → Solana transfers. Solana is a destination only, and each route ends with token delivery to the Solana receiver. Availability depends on the source chain and requested assets. <Note> Solana's chain ID is `1861167595`. Use it only as `destinationChainId` in Route API requests. </Note> ## How it works ```mermaid theme={null} flowchart LR A["Source EVM transaction<br/>Optional swaps or position exits"] --> B["Bridge"] B --> C["Solana receiver<br/>Requested output token"] ``` Request a route with an EVM input asset and a Solana output token. Enso returns a transaction to sign and submit on the source EVM chain. Depending on the route mode, this transaction can include swaps or position exits before bridging. The requested output token arrives at `receiver` on Solana. The receiver does not sign a Solana transaction for this transfer. Enso does not execute destination callbacks or compose additional actions on Solana. ## Request requirements | Parameter | Requirement | | - | - | | `chainId` | The supported source EVM chain ID. | | <code>destinationChainId</code> | `1861167595`, the current Enso identifier for Solana. | | `fromAddress` | The source EVM wallet address. | | `tokenIn` | Exactly one source-chain asset address. | | `amountIn` | Exactly one positive, fixed integer string in the input token's base unit. Dynamic amounts and placeholders are unsupported. | | `tokenOut` | Exactly one case-sensitive Solana mint address, or the native SOL identifier below. | | `receiver` | An explicit, case-sensitive Solana recipient address. | | `refundReceiver` | An explicit, nonzero EVM address on the source chain for bridge refunds. | | `slippage` | Slippage tolerance in basis points. `"50"` means 0.5%. Use this instead of `minAmountOut`. | Preserve the original case of Solana addresses throughout your integration, including requests, storage, and display. The Solana `receiver` and EVM `refundReceiver` are separate addresses on different chains. ## Example: Ethereum USDC to Solana USDC Set `ENSO_API_KEY` to your Enso API key, `EVM_ADDRESS` to your source wallet, and `SOLANA_ADDRESS` to the recipient's Solana wallet address. This request routes 100 USDC from Ethereum to USDC on Solana with 0.5% slippage. ```bash theme={null} curl --request POST \ --url https://api.enso.build/api/v1/shortcuts/route \ --header "Authorization: Bearer $ENSO_API_KEY" \ --header 'Content-Type: application/json' \ --data @- <<EOF { "chainId": 1, "destinationChainId": 1861167595, "fromAddress": "$EVM_ADDRESS", "receiver": "$SOLANA_ADDRESS", "refundReceiver": "$EVM_ADDRESS", "routingStrategy": "router", "tokenIn": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], "tokenOut": ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"], "amountIn": ["100000000"], "slippage": "50" } EOF ``` To receive native SOL, replace `tokenOut` with `["11111111111111111111111111111111"]`. This identifier belongs in `tokenOut`; `receiver` must still be the recipient's Solana wallet address. ## Submit the source transaction 1. Review the returned quote, including `amountOut`, `minAmountOut`, and `metadata.bridgeFees`. The request cannot set `minAmountOut`, but the response can include the calculated minimum. 2. For the `router` strategy used above, submit required `preTransactions` in order on the source chain and wait for each receipt. Skip a `tokenApproval` only when the existing allowance is sufficient. 3. Sign and submit the returned `tx` with the source EVM wallet, preserving its `to`, `data`, and `value`. Save the source transaction hash for status checks. <Note> Source confirmation and Solana delivery are separate stages. A successful source transaction does not confirm that the recipient has received tokens on Solana. </Note> ## Route modes `crosschainRouteMode` controls whether Enso can add source-chain routing before bridging. It defaults to `"full"`. | Mode | Behavior for Solana destinations | | - | - | | `"source"`, `"sourceOrDestination"`, `"full"` | Allow source-side EVM swaps or position exits before bridging into `tokenOut`. | | `"direct"`, `"destination"` | Bridge the requested input directly into `tokenOut`, without additional Enso routing. | No mode enables Enso execution on Solana. In particular, `"destination"` does not enable a Solana callback or destination-side composition. ## Track delivery and refunds Use `GET /api/v1/bridge/route` with the source EVM chain ID and source transaction hash. Poll every 30 seconds; in-progress results are cached for up to 30 seconds. For the Ethereum example, set `SOURCE_TX_HASH` to the transaction hash saved after submission: ```bash theme={null} curl --get https://api.enso.build/api/v1/bridge/route \ --header "Authorization: Bearer $ENSO_API_KEY" \ --data-urlencode 'chainId=1' \ --data-urlencode "txHash=$SOURCE_TX_HASH" ``` The response includes an overall `status` and a `hops` array with each bridge transfer's details. * `inflight` means the route has not completed. * `delivered` confirms delivery. The Solana hop's `destinationTxHash`, when present, is a case-sensitive transaction signature. * `failed` can represent a failed transfer or a refund. A refunded hop includes `refundChainId` and `refundTxHash` when the payout is available. The refund goes to `refundReceiver` on the source EVM chain. * `unknown` means the checker could not determine the status. Inspect `traversal` and the entries in `hops` for available details. ## Unsupported features * Routes originating on Solana. * Explicit `minAmountOut` requests, including `"0"`. * Intents, the `checkout` routing strategy, and destination-chain fee collection. * Destination callbacks or composition, and public Solana Bundle API actions. Source-side composition uses the Route API. <div> <p>Updated </p> </div> # Bundle Actions Reference Source: https://docs.enso.build/pages/build/reference/actions Public actions, inputs, outputs, and composition rules for Bundle API requests. The Bundle API accepts an ordered array of public actions. This page documents stable Enso composition actions and common protocol action families. <Note> Start with the [Bundle API guide](/pages/build/get-started/bundling-actions) for request shape, execution, approvals, and response handling. Use the standalone [Route API](/pages/build/get-started/route) when Enso should choose the complete path. The `enso:route` section below documents the route action used inside a Bundle request. </Note> <Info> Protocol support and inputs change over time. Use [Supported Actions](/api-reference/integration/supported-actions) for the current action list and [Standard per Protocol](/api-reference/integration/standard-per-protocol) for actions available on a specific protocol. Generic protocol tables below describe common fields, not a universal schema for every integration. </Info> ## Action index * **Routing and composition:** [`route`](#route), [`split`](#split), [`merge`](#merge), [`call`](#call) * **Safety and fees:** [`slippage`](#slippage), [`minamountout`](#minamountout), [`fee`](#fee), [`ensofee`](#ensofee) * **Protocol actions:** [`swap`](#swap), [`deposit`](#deposit), [`redeem`](#redeem), [`bridge`](#bridge), [`borrow`](#borrow), [`repay`](#repay), [`harvest`](#harvest) * **Token actions:** [`approve`](#approve), [`transfer`](#transfer), [`transferfrom`](#transferfrom), [`permittransferfrom`](#permittransferfrom), [`balance`](#balance) * **Liquidity actions:** [`depositclmm`](#depositclmm), [`redeemclmm`](#redeemclmm) * **Logic:** [Math Actions](#math-actions), [Helpers Actions](#helpers-actions) ## Chaining actions Use a previous output as a later input with a zero-based reference: ```typescript theme={null} { useOutputOfCallAt: 0 } ``` Array outputs require an explicit item index: ```typescript theme={null} { useOutputOfCallAt: 0, index: 1 } ``` The following source-backed example splits USDT into two routed outputs and passes both into a CLMM deposit: ```typescript theme={null} const bundle = await client.getBundleData( { chainId: 42161, fromAddress: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", routingStrategy: "router", }, [ { protocol: "enso", action: "split", args: { tokenIn: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", tokenOut: [ "0xaf88d065e77c8cc2239327c5edb3a432268e5831", "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", ], amountIn: "100000000", }, }, { protocol: "sushiswap-v3", action: "depositclmm", args: { tokenOut: "0xf0cbce1942a68beb3d1b73f0dd86c8dcc363ef49", ticks: [-887271, 887271], tokenIn: [ "0xaf88d065e77c8cc2239327c5edb3a432268e5831", "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", ], poolFee: "100", amountIn: [ { useOutputOfCallAt: 0, index: 0 }, { useOutputOfCallAt: 0, index: 1 }, ], }, }, ], ); ``` References must point to an earlier available output. Checks such as `check` and `minamountout` do not produce a normal token amount for downstream consumption. ## Action outputs | Action | Output | Shape | Reference notes | | - | - | - | - | | `route` | Routed token amount or amounts | Scalar or array | Use `index` for a multi-output route. | | `balance` | Execution-account or requested account balance | Scalar | Advanced `account` and `estimate` behavior is documented separately. | | `split` | One routed amount per `tokenOut` | Array | `index` is required. | | `merge` | Merged output amount | Scalar | — | | `call` | Contract return value | ABI-dependent | Shape follows the supplied ABI. | | `slippage` | Calculated minimum amount | Scalar | The referenced producer must already exist. | | `minamountout` | Assertion only | None | Do not reference it as a token producer. | | `fee`, `ensofee` | Amount after fee | Scalar | Feed the net amount into the next action. | | Math actions | Calculated number | Scalar | — | | Comparison, `not` | Boolean result | Scalar | — | | `toggle` | Selected amount | Scalar | — | | `check` | Assertion only | None | Reverts when the condition is false. | | Protocol actions | Protocol-specific | Varies | Use current per-protocol action metadata. | ## Ondo quote estimates `GET /api/v1/shortcuts/quote` supports routes containing the synthetic `ondosplit` and `ondomerge` actions. It returns a soft estimate based on current Folio view data and Ondo soft attestations; it does not build an executable Ondo transaction or obtain a hard attestation. Use the Route API when execution-ready Ondo actions are required. Generic `split` and `merge` actions remain unavailable in the Quote API. ## Core actions ### `route` `enso:route` finds a path between `tokenIn` and `tokenOut` inside a Bundle request. It can expand into swaps, deposits, or redeems, and the Bundle response includes the selected hops in `route`. This is different from the standalone [Route API](/pages/build/get-started/route), which is usually simpler when the entire request has one final destination. ```typescript theme={null} { protocol: "enso", action: "route", args: { tokenIn: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", tokenOut: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84", amountIn: "1000000000000000000", slippage: "300", }, } ``` To charge a fee on routed trades, configure [Fees](/pages/build/reference/fees) in the developer portal. For cross-chain routing, add `destinationChainId`. `ignoreBridges` and `refundReceiver` apply only to cross-chain route actions. Source completion and destination execution are asynchronous. ```typescript theme={null} { protocol: "enso", action: "route", args: { tokenIn: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", tokenOut: "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58", amountIn: "1000000000000000000", destinationChainId: 10, receiver: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", refundReceiver: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", ignoreBridges: ["ccip"], }, } ``` | Parameter | Description | Required | | - | - | - | | `tokenIn` | Input token address. Use `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` for the native asset. | Yes | | `tokenOut` | Output token address. | Yes | | `amountIn` | Base-unit amount or previous output reference. | Yes | | `slippage` | Slippage tolerance in basis points. | No | | `minAmountOut` | Explicit minimum output amount or amounts. | No | | `receiver` | Output recipient override. | No | | `ignoreAggregators` | Aggregators to exclude from route selection. | No | | `ignoreStandards` | Protocol standards to exclude from route selection. | No | | `destinationChainId` | Destination chain for a cross-chain route. | No | | `refundReceiver` | Cross-chain dust/refund recipient. | No | | `ignoreBridges` | Bridges to exclude from cross-chain route selection. | No | ### `swap` Swaps one token for another using a specific pool or exchange protocol. ```typescript the
프로젝트로 돌아가기