bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 35쪽 중 7쪽
eeeeeeeeeeeeee` for the native asset.
When native value is involved, send the returned `tx.value` exactly as provided.
## Chain action outputs
A later action can consume an earlier action's output:
```typescript theme={null}
{ useOutputOfCallAt: 0 }
```
If the producer returns an array, select an item explicitly:
```typescript theme={null}
{ useOutputOfCallAt: 0, index: 1 }
```
References are zero-based and must point to an earlier output. Array outputs require `index`. Some checks do not expose a normal consumable output; consult the [action output table](/pages/build/reference/actions#action-outputs) before chaining them.
## Receivers and intermediate assets
The query-level `receiver` is the default recipient for final outputs. An action-level `receiver` overrides recipient behavior for that action when supported. `refundReceiver` is for dust or applicable cross-chain refunds.
Do not send every intermediate output to the user. Assets consumed by later actions must remain with the executing account until the sequence completes.
## Example: route into a deposit
This source-backed example routes native ETH into rETH and deposits the route output into Aave. The deposit consumes action `0` dynamically.
```typescript theme={null}
import { EnsoClient } from "@ensofinance/sdk";
const client = new EnsoClient({ apiKey: process.env.ENSO_API_KEY! });
const result = await client.getBundleData(
{
chainId: 1,
fromAddress: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
routingStrategy: "router",
},
[
{
protocol: "enso",
action: "route",
args: {
tokenIn: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
tokenOut: "0xae78736Cd615f374D3085123A210448E74Fc6393",
amountIn: "10000000000000000",
slippage: "300",
},
},
{
protocol: "aave-v3",
action: "deposit",
args: {
primaryAddress: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
tokenIn: "0xae78736Cd615f374D3085123A210448E74Fc6393",
tokenOut: "0xCc9EE9483f662091a1de4795249E24aC0aC2630f",
amountIn: { useOutputOfCallAt: 0 },
},
},
],
);
```
Equivalent REST request:
```bash theme={null}
curl --fail --silent --show-error -X POST \
'https://api.enso.build/api/v1/shortcuts/bundle?chainId=1&fromAddress=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&routingStrategy=router' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ENSO_API_KEY" \
-d '[
{
"protocol": "enso",
"action": "route",
"args": {
"tokenIn": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"tokenOut": "0xae78736Cd615f374D3085123A210448E74Fc6393",
"amountIn": "10000000000000000",
"slippage": "300"
}
},
{
"protocol": "aave-v3",
"action": "deposit",
"args": {
"primaryAddress": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
"tokenIn": "0xae78736Cd615f374D3085123A210448E74Fc6393",
"tokenOut": "0xCc9EE9483f662091a1de4795249E24aC0aC2630f",
"amountIn": { "useOutputOfCallAt": 0 }
}
}
]' | jq
```
## Example: consume an array output
`split` returns one output per `tokenOut`. The following CLMM deposit selects both outputs explicitly.
```typescript theme={null}
const result = 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 },
],
},
},
],
);
```
For CLMM flows that require explicit protection for the internal swaps, `slippage` checks can sit between `split` and `depositclmm`. They reference the split outputs; they do not need to appear after the final deposit.
## Fees
To charge a fee on your users' trades, configure [Fees](/pages/build/reference/fees) in the developer portal; no request parameters are needed. For a standalone fee step that returns the net amount, use the public [`enso:fee` action](/pages/build/reference/actions#fee).
## Example: bridge callback
A bridge callback executes later on the destination chain. For supported callback bridges, the callback must begin with `enso:balance`; callback output references are local to the callback array.
```typescript theme={null}
const result = await client.getBundleData(
{
chainId: 10,
fromAddress: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
receiver: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
routingStrategy: "router",
},
[
{
protocol: "stargate",
action: "bridge",
args: {
primaryAddress: "0xe8cdf27acd73a434d661c84887215f7598e7d0d3",
destinationChainId: 130,
tokenIn: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
amountIn: "5000000000000000000",
receiver: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
callback: [
{
protocol: "enso",
action: "balance",
args: {
token: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
},
},
{
protocol: "enso",
action: "route",
args: {
tokenIn: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
tokenOut: "0x078d782b760474a361dda0af3839290b0ef57ad6",
amountIn: { useOutputOfCallAt: 0 },
slippage: "100",
},
},
],
},
},
],
);
```
After submitting the source transaction, monitor [Bridge Status](/pages/build/get-started/bridge-status). Bridge-provider callback capabilities and refund behavior differ; see [Crosschain Routing](/pages/build/get-started/crosschain-routing).
## Execute the response
Building a bundle does not submit it.
1. Inspect `preTransactions`. Submit each required transaction before the bundle transaction. Skip `tokenApproval` entries when the current allowance is sufficient.
2. Submit `tx` unchanged, including `to`, `data`, and `value`.
3. Do not submit an expired quote; respect `validUntil` when present.
4. For cross-chain bundles, monitor bridge and destination status after source confirmation.
### Response fields
| Field | Description |
| - | - |
| `tx` | Signer-ready transaction. |
| `preTransactions` | Transactions that may need to run before `tx`, including token approvals and protocol setup. Entries are returned in execution order. |
| `metadata.bridgeFees` | Bridge fees by protocol, source and destination chain, fee token, amount, and quote type. Amounts use the fee token's base unit. `deductedFromAmountOut` indicates whether the fee already reduced the quoted output. |
| `approvals` | Deprecated legacy approval list. Use `preTransactions` for all new integrations. |
| `createdAt` | Block number used to build the transaction. |
| `bundle` | Normalized action sequence returned by the backend. It can include injected fee actions. |
| `metadata.bridgeRefundAssets` | Ordered bridge-principal refund destinations for the selected transaction. Empty when no bridge refund path applies; entries do not guarantee that every failure is refundable. |
| `route` | Expanded route hops selected for route actions. |
| `amountsOut` | Expected final outputs by token. |
| `minAmountsOut` | Minimum protected outputs by token. |
| `feeAmount` | Fees by token. |
| `gas` | Estimated gas when quoting is enabled. |
| `priceImpact` | Estimated price impact when available. |
| `bridgingEstimates` | Cross-chain timing and fee estimates when applicable. |
| `validUntil` | Quote expiry timestamp when applicable. |
| `userOp` | ERC-4337 user operation for supported execution flows. |
When `skipQuote=true`, quote-dependent fields such as output amounts and gas may be absent.
## Limits and common errors
| Constraint | Current limit or behavior |
| - | - |
| Top-level actions | 50 maximum |
| Total actions including callbacks | 100 maximum |
| Actions in each callback | 10 maximum |
| Callback nesting | 5 callback levels beneath a top-level action |
| Output references | Resolved against outputs already built; missing or future references fail during bundle construction. Array outputs require `index`. |
| Static `amountIn` | Positive base-unit integer string; placeholders and output references are also supported. Other amount fields are action-specific. |
| Callback order | CCIP, Stargate, and Relay callbacks require `enso:balance` first. CCTP callbacks support a narrower documented sequence. |
| Simulation failure | Error detail depends on the failing action and simulation path; detailed simulation context is not guaranteed. |
See the [FAQ](/pages/build/reference/faq) and [Bundle Actions Reference](/pages/build/reference/actions) for action-specific constraints.
## Next steps
<CardGroup>
<Card title="Bundle Actions Reference" icon="list" href="/pages/build/reference/actions">
Review public action inputs, outputs, fees, checks, and composition rules.
</Card>
<Card title="API Reference" icon="code" href="/api-reference/defi-shortcuts/bundle-a-list-of-actions">
Inspect the exact Bundle endpoint request and response schema.
</Card>
<Card title="Routing Strategies" icon="route" href="/pages/build/reference/routing-strategies">
Understand execution-account and approval behavior.
</Card>
<Card title="Crosschain Routing" icon="bridge" href="/pages/build/get-started/crosschain-routing">
Choose bridge protocols and monitor asynchronous destination execution.
</Card>
</CardGroup>
# Core Concepts
Source: https://docs.enso.build/pages/build/get-started/core-concepts
The Enso primitives every integration uses: token data, balances, routes, bundles, approvals, bridge status, and Quoter.
Enso turns product intent into executable transaction data. Most integrations combine a small set of primitives: discover what can be shown, read what the user owns, request a route or bundle, submit the returned transaction, and refresh balances after execution.
## The Enso Mental Model
| Primitive | What it means | Primary endpoint or guide |
| - | - | - |
| Tokens and protocol data | What your product can show, compare, or route into. Use this for APY, TVL, protocol, chain, decimals, logos, and underlying assets. | [`GET /v1/tokens`](/api-reference/tokens/tokens), [Protocol Data](/pages/build/get-started/protocol-data) |
| Balances | What the user owns before and after execution, including wallet assets and DeFi position tokens. | [`GET /v1/wallet/balances`](/api-reference/defi/wallet-balances), [Balances](/pages/build/get-started/balances) |
| Route API | Enso chooses the path from one source asset or position into one final destination. Use this for swaps, zaps, deposits, withdrawals, migrations, and simple cross-chain routes. | [`POST /v1/shortcuts/route`](/api-reference/defi-shortcuts/optimal-route-between-two-tokens-1), [Route API](/pages/build/get-started/route) |
| Bundle API | Your product specifies an ordered list of actions and Enso turns the same-chain sequence into one transaction. Use this when the workflow needs custom sequencing, dynamic outputs, checks, or actions Route does not cover. | [`POST /v1/shortcuts/bundle`](/api-reference/defi-shortcuts/bundle-a-list-of-actions), [Bundle API](/pages/build/get-started/bundling-actions) |
| Approval | An ERC-20 approval transaction required only when the user spends through the Enso router and allowance is not already high enough. | [`GET /v1/wallet/approve`](/api-reference/defi-shortcuts/approve-enso-contract) |
| Bridge status | Status tracking for async cross-chain execution after the source-chain transaction is submitted. | [Bridge Status](/pages/build/get-started/bridge-status) |
| Quoter | Validation for transactions generated outside Enso. Enso route and action responses are already simulated as part of the Enso flow. | [Quoter](/pages/quoter/overview) |
## Standard Build Flow
1. Discover supported chains, tokens, protocols, actions, and yield destinations.
2. Read the user's balances and current DeFi positions.
3. Build a Route request when Enso should find the path, or a Bundle request when your product controls the action sequence.
4. Ask for approval only when the route or bundle spends an ERC-20 through the router and allowance is insufficient.
5. Submit the returned transaction as-is.
6. Track bridge status only for async cross-chain routes.
7. Refresh balances and position metadata after confirmation.
## Route API, Bundle API, and `enso:route`
Use the canonical [Route API vs Bundle API comparison](/pages/build/get-started/overview#route-api-vs-bundle-api) to choose an endpoint. Route API lets Enso choose the path. Bundle API lets your product submit an ordered action array. The `enso:route` action is one action available inside that array.
Actions executed in one same-chain transaction are atomic. Cross-chain delivery and destination callbacks are asynchronous; monitor them through [Bridge Status](/pages/build/get-started/bridge-status).
## Product Entry Points
| Product | Start here | Essential surface |
| - | - | - |
| Earn tab or yield marketplace | [Enso Earn](/pages/earn/overview) | Token catalog, balances, route, conditional approval, refreshed balances |
| Wallet swaps and zaps | [Route](/pages/build/get-started/route) | Token discovery, route, returned `tx`, refreshed balances |
| Cross-chain deposit | [Crosschain Routing](/pages/build/get-started/crosschain-routing) | Source-chain route, bridge callback, bridge status, destination balance |
| Custom multi-action workflow | [Bundle](/pages/build/get-started/bundling-actions) | Action list, dynamic outputs, checks, returned transaction |
| Third-party transaction validation | [Quoter](/pages/quoter/overview) | Simulate and validate calldata generated outside Enso |
## UI Fields To Plan For
| Screen | Data to show | Source |
| - | - | - |
| Catalog | APY, TVL, protocol, chain, token symbol, decimals, underlying assets, logo | `GET /v1/tokens` |
| Portfolio | Asset amount, USD value, token metadata, current DeFi position tokens | `GET /v1/wallet/balances` plus `GET /v1/tokens` |
| Quote review | Expected output, minimum output, gas, price impact, selected route, transaction target | `POST /v1/shortcuts/route` |
| Approval | Token, spender, amount, chain, approval transaction | `GET /v1/wallet/approve` |
| Post-execution | New source balance, new destination position, any dust, current APY and metadata | `GET /v1/wallet/balances` plus `GET /v1/tokens` |
<div>
<p>Updated </p>
</div>
# Crosschain Routing
Source: https://docs.enso.build/pages/build/get-started/crosschain-routing
Execute complex DeFi operations across multiple blockchains using bridge callbacks and post-bridge execution
Crosschain routing coordinates DeFi operations across multiple blockchains. The source transaction and destination callback are separate stages: each transaction can be atomic on its own chain, but destination failure cannot revert a finalized source-chain bridge.
Both `route` and `bundle` API operate in crosschain mode.
For custom bundles, use the `bridge` action to facilitate cross-chain token transfers using one of four supported bridge protocols: **CCIP**, **CCTP** (USDC-only), **Relay** or **Stargate**.
For example: bridge assets to chains where protocols exist, execute operations such as minting, then optionally bridge results back to your origin chain and deposit them in a yield-bearing position.
```mermaid theme={null}
flowchart LR
subgraph berachain ["🐻 Berachain"]
USDC_BERA((USDC)) --> A1(( ))
end
A1 -.-> |balance<br/>check| USDC_ETH((USDC))
subgraph ethereum ["🌐 Ethereum"]
USDC_ETH((USDC)) -->|reservoir<br/>deposit| rUSD_ETH((rUSD))
end
rUSD_ETH -.-> |balance<br/>check|rUSD_BERA((rUSD))
subgraph berachain ["🐻 Berachain"]
rUSD_BERA((rUSD)) -->|euler-v2<br/>deposit| erUSD((erUSD))
end
```
## Solana destinations
The Route API supports EVM → Solana transfers. Enso can compose operations on the source EVM chain; the route ends with token delivery on Solana, without destination callbacks or composition. See [Solana routing](/pages/build/get-started/solana-routing) for the request requirements, example, route modes, and delivery tracking.
## Quick Start
<Tabs>
<Tab title="Crosschain Stablecoin Minting (Stargate)">
<Tip>
Use the [GET `/layerzero/pool`](/api-reference/integration/layerzero-pool) API to find the correct pool address for Stargate, or `GET /api/v1/ccip/router?chainId={chainId}` for CCIP.
Always start the post-bridging `callback` with a `balance` action.
</Tip>
```ts theme={null}
{
protocol: "stargate",
action: "bridge",
args: {
primaryAddress: rusdEthToBeraPools[0].pool,
destinationChainId: ETHEREUM_ID,
...
callback: [
{
protocol: "enso",
action: "balance",
args: { token: USDC_ETHEREUM },
},
// Mint e-rUSD using the delivered USDC on Ethereum
{
protocol: "reservoir",
action: "deposit",
args: {
...,
amountIn: { useOutputOfCallAt: 0 },
},
},
// Bridge newly minted e-rUSD back to Berachain
{
protocol: "stargate",
action: "bridge",
args: {
destinationChainId: BERACHAIN_ID,
...
// Callback executes on Berachain after e-rUSD arrives
callback: [
{
protocol: "enso",
action: "balance",
args: { token: RUSD_BERACHAIN },
},
// Deposit delivered e-rUSD into Euler on Berachain
{
protocol: "euler-v2",
action: "deposit",
args: {
...,
amountIn: { useOutputOfCallAt: 0 },
},
},
],
},
},
],
},
},
```
</Tab>
<Tab title="Crosschain Swap">
[**Try this route →**](https://happypath.enso.build/?chainId=1\&destinationChainId=8453\&fromAddress=0xd8da6bf26964af9d7eed9e03e53415d37aa96045\&routingStrategy=delegate\&tokenIn=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\&tokenOut=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\&amountIn=1000000000)
To simply bridge an asset, use the `route` API with automatic route optimization from input and output token/chain pairs.
<CodeGroup>
```typescript SDK theme={null}
// Basic USDC transfer: Ethereum → Base
const route = await ensoClient.getRouteData({
fromAddress: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
chainId: 1, // Ethereum
destinationChainId: 8453, // Base
tokenIn: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], // USDC Ethereum
tokenOut: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], // USDC Base
amountIn: ["1000000000"], // 1,000 USDC
slippage: "300", // 3%
routingStrategy: "delegate"
});
await wallet.sendTransaction(route.tx);
```
```bash cURL theme={null}
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": 8453,
"fromAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"routingStrategy": "delegate",
"tokenIn": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"],
"tokenOut": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],
"amountIn": ["1000000000"],
"slippage": "300"
}' | jq
```
</CodeGroup>
</Tab>
</Tabs>
## Core Concepts
<CardGroup>
<Card title="Bridge Protocols" icon="bridge" href="#bridge-protocols">
Enso supports four bridge protocols: **CCIP** (Chainlink), **CCTP** (Circle, USDC-only), **Relay**, and **Stargate** (LayerZero). Each has different characteristics for callback limits, native token support, and fee handling.
</Card>
<Card title="Protocol Discovery" icon="arrow-right-arrow-left">
Use protocol-specific APIs to discover bridge addresses:
`GET /api/v1/ccip/router?chainId={chainId}` for CCIP,
[`/cctp/bridge/tokenmessengerv2`](/pages/build/get-started/bridge-status) for
CCTP, [`/layerzero/pool`](/api-reference/integration/layerzero-pool) for
Stargate.
</Card>
<Card title="Native Drop" icon="gas-pump">
Parent bridge calls calculate gas fees required for all child bridge
operations and include these costs in the initial transaction fee.
</Card>
<Card title="Post-Bridge Execution" icon="play">
Callback actions 프로젝트로 돌아가기