Enso 백서

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

l.gitbook.io/stargate) * [Explore Layer0](https://docs.layerzero.network/v2) * [Find more about Enso's routing capabilities](/pages/build/get-started/route) <div> <p>Updated </p> </div> # Yield Migrator Source: https://docs.enso.build/pages/templates/yield-migrator A DeFi application that optimizes returns by migrating yield-bearing positions between protocols using the Enso SDK. <CardGroup> <Card href="https://github.com/EnsoBuild/shortcuts-ui-examples/tree/main/apps/yield-migrator" title="Github" icon="github"> Source code </Card> <Card href="https://templates.enso.build/yield" title="Yield Migrator Live Demo" icon="play"> Try it out! </Card> </CardGroup> ## Overview Yield Migrator is a React/Vite web application that simplifies the process of moving funds between yield-generating protocols. The application leverages Enso's Router API to execute complex multi-step transactions in a single operation. ## Features * **Position Discovery**: Automatically detects user's current yield-bearing positions across protocols * **APY Comparison**: Displays potential yield improvements across alternative protocols * **One-Click Migration**: Executes the entire migration process in a single transaction * **Transaction Preview**: Shows expected APY improvement, fees, gas costs, and price impact before execution * **Cross-Protocol Support**: Works with major lending, staking, and liquidity protocols ## Technology Stack * **Frontend**: React, Chakra UI * **Web3**: wagmi, viem, RainbowKit * **DeFi Integration**: Enso Finance SDK * **Build Tools**: Vite, TypeScript ## Implementation Example ```jsx theme={null} import { useEnsoBundleApi } from '@ensofinance/sdk-react'; function MigratePosition({ currentPosition, targetPosition }) { const { createBundleTransaction } = useEnsoBundleApi(); async function handleMigrate() { // Create migration bundle with Enso SDK const bundleTransaction = await createBundleTransaction({ actions: [ // Withdraw from current position { protocol: currentPosition.protocol, action: "withdraw", args: { tokenIn: currentPosition.address, amountIn: currentPosition.balance, primaryAddress: currentPosition.contractAddress } }, // Deposit into new position { protocol: targetPosition.protocol, action: "deposit", args: { tokenIn: "0x...", // Underlying token tokenOut: targetPosition.address, // Use output from previous action amountIn: { useOutputOfCallAt: 0 }, primaryAddress: targetPosition.contractAddress } } ] }); // Execute the transaction await bundleTransaction.execute(); } return ( <Button onClick={handleMigrate}> Migrate Position </Button> ); } ``` <div> <p>Updated </p> </div> # Overview Source: https://docs.enso.build/pages/use-cases/deposits/index <div> <Card href="/pages/use-cases/deposits/zap-to-deposit" title="Zap to deposit"> Maximize user deposits by accepting any token and zapping it directly into a staking or vault position </Card> <Card href="/pages/use-cases/deposits/withdrawal" title="Withdrawal"> Simplify withdrawal from yield-generating vaults and liquidity pools. </Card> <Card href="/pages/use-cases/market-makers/pool-rebalancing" title="Position migration"> Simplify position migration between vaults to keep capital within ecosystem </Card> </div> # Position Migration Source: https://docs.enso.build/pages/use-cases/deposits/position-migration Simplify position migration between vaults to keep capital within ecosystem. ## Migrate from Yearn yvDAI vault to yvUSDC vault This use case enables 1-click migration between different vaults on the same platform to retain user capital. [**Try this route →**](https://happypath.enso.build?chainId=1\&tokenIn=0xda816459f1ab5631232fe5e97a05bbbb94970c95\&tokenOut=0xa354f35829ae975e850e23e9615b11da1b3dc4de) **Route Mechanics**: The routing involves a three-step process. * It first redeems the yvDAI from the yearn-v2 vault to get DAI. * Then, it swaps the DAI for USDC. * Finally, it deposits the USDC into the yearn-v2 vault to get the final yvUSDC position. ```mermaid theme={null} flowchart LR yvDAI((yvDAI)) --> A1 A1[yearn-v2.redeem] --> DAI((DAI)) A2[swap] --> USDC((USDC)) A3[yearn-v2.deposit] --> yvUSDC((yvUSDC)) DAI --> A2 USDC --> A3 ``` ```ts theme={null} export async function migrateYearnDaiToUsdc(): Promise<{ route: any; tx: any }> { const yvDAI: Address = "0xda816459f1ab5631232fe5e97a05bbbb94970c95"; const yvUSDC: Address = "0xa354f35829ae975e850e23e9615b11da1b3dc4de"; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: ETHEREUM_CHAIN, amountIn: ["1000000000000000000"], // 1 yvDAI tokenIn: [yvDAI], tokenOut: [yvUSDC], routingStrategy: 'router' }; happyPathLog(routeParams); const route = await client.getRouteData(routeParams); await sendEoa(route.tx, route.gas); return route; } ``` # Withdrawal Source: https://docs.enso.build/pages/use-cases/deposits/withdrawal Simplify withdrawal from yield-generating vaults and liquidity pools ### Unstake styHONEY to BERA Unstake a `styHONEY` position and convert it back to the native gas token, `BERA`, on Berachain. [**Try this route →**](https://happypath.enso.build/?chainId=80094\&tokenIn=0x99d6a0fb9420f3995fd07dcc36ac827a8e146cf9\&tokenOut=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\&outChainId=80094) **Route Mechanics:** * Redeem `styHONEY` to receive `yHONEY`. * Redeem `yHONEY` to receive `HONEY`. * Swap `HONEY` to `BERA` through Enso's routing. ```mermaid theme={null} flowchart LR styHONEY((styHONEY)) -->|bearn<br/>redeem| yHONEY((yHONEY)) yHONEY -->|bearn<br/>redeem| HONEY((HONEY)) HONEY -->|openocean<br/>swap| BERA((BERA)) ``` ```javascript theme={null} import { Address, EnsoClient, RouteParams } from "@ensofinance/sdk"; const BERACHAIN_MAINNET = 80094; const userAddress = "your-wallet-address" as Address; const styHONEY = "0x99d6A0FB9420F3995fD07dCc36AC827a8E146cf9" as Address; const yHONEY = "0xC82971BcFF09171e16Ac08AEE9f4EA3fB16C3BDC" as Address; const HONEY = "0xfcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce" as Address; const BERA = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: BERACHAIN_MAINNET, amountIn: ["1000000000000000000"], // 1 styHONEY tokenIn: [styHONEY], tokenOut: [BERA], routingStrategy: "delegate", slippage: "300", // 3% slippage for redemption referralCode: "styhoney-bera", }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` *** ### Withdraw Yearn Curve mUSD Vault to USDC Unwind a Yearn Curve `mUSD` vault position back to the base asset, `USDC`, on Ethereum. [**Try this route →**](https://happypath.enso.build?chainId=1\&tokenIn=0x8cc94ccd0f3841a468184aca3cc478d2148e1757\&tokenOut=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) ```javascript theme={null} const CurveMUSD_yVault = "0x8cc94ccd0f3841a468184aca3cc478d2148e1757" as Address; // Yearn Curve mUSD Pool yVault const USDC = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: ETHEREUM_CHAIN, amountIn: ["1000000000000000000"], // Example amount for yVault token tokenIn: [CurveMUSD_yVault], tokenOut: [USDC], routingStrategy: "delegate", slippage: "100", // 1% slippage }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` **Route Mechanics:** * Redeem from Yearn Curve mUSD Pool yVault ( `0x8cc94ccd0f3841a468184aca3cc478d2148e1757` ) to receive Curve mUSD LP tokens * Redeem from Curve.fi mUSD Pool ( `0x8474ddbe98f5aa3179b3b3f5942d724afcdec9f6` ) to receive Curve 3pool LP tokens * Redeem from Curve.fi 3pool ( `0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7` ) to receive USDC *** ### Withdraw Yearn Curve alUSD Vault to USDC Unwind a Yearn Curve `alUSD` vault position back to the base asset, `USDC`, on Ethereum. [**Try this route →**](https://happypath.enso.build?chainId=1\&tokenIn=0xa74d4b67b3368e83797a35382afb776baae4f5c8\&tokenOut=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) ```javascript theme={null} const CurveAlUSD_yVault = "0xa74d4b67b3368e83797a35382afb776baae4f5c8" as Address; // Yearn Curve alUSD Pool yVault const USDC = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: ETHEREUM_CHAIN, amountIn: ["1000000000000000000"], // Example amount for yVault token tokenIn: [CurveAlUSD_yVault], tokenOut: [USDC], routingStrategy: "delegate", slippage: "100", // 1% slippage }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` **Route Mechanics:** * Redeem from Yearn Curve alUSD Pool yVault ( `0xa74d4b67b3368e83797a35382afb776baae4f5c8` ) to receive Curve alUSD LP tokens * Redeem from Curve.fi alUSD Pool ( `0x43b4fdfd4ff969587185cdb6f0bd875c5fc83f8c` ) to receive Curve 3pool LP tokens * Redeem from Curve.fi 3pool ( `0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7` ) to receive USDC *** ### Withdraw Rooster LP (nALPHA/pUSD) to Native Plume Completely unwind a Rooster YAP LP (`nALPHA`/`pUSD`) position back to the native `Plume` token on Plume. [**Try this route →**](https://happypath.enso.build/?chainId=98866\&tokenIn=0xfc3bd0e01b4e755aedd2a4087ccdb90c4d28f038\&tokenOut=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) ```javascript theme={null} const ROOSTER_YAP_NALPHA_PUSD = "0xfc3bd0e01b4e755aedd2a4087ccdb90c4d28f038" as Address; const PLUME = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: ROOSTER_CHAIN, amountIn: ["100000000000000000000"], // 100 Rooster YAP tokens tokenIn: [ROOSTER_YAP_NALPHA_PUSD], tokenOut: [PLUME], routingStrategy: "delegate", slippage: "100", // 1% slippage referralCode: "rooster-exit-native", }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` **Route Mechanics:** * Redeem Rooster YAP pool tokens to underlying PUSD and nALPHA * Merge tokens using the enso.merge action * Swap PUSD to native Plume via internal exchange * Swap nALPHA to native Plume via internal exchange * Consolidate native Plume tokens in user wallet *** ### Unstake kHYPE to USDT0 Unstake `kHYPE` and convert the underlying assets to the `USDT0` stablecoin on HyperEVM. [**Try this route →**](https://happypath.enso.build/?chainId=999\&tokenIn=0xfd739d4e423301ce9385c1fb8850539d657c296d\&tokenOut=0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb) ```javascript theme={null} const KHYPE = "0xfd739d4e423301ce9385c1fb8850539d657c296d" as Address; const USDT0 = "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: HYPEREVM_CHAIN, amountIn: ["1000000000000000000"], // 1 kHYPE tokenIn: [KHYPE], tokenOut: [USDT0], routingStrategy: "delegate", slippage: "100", // 1% slippage referralCode: "kinetiq-withdraw", }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` **Route Mechanics:** * Unstake kHYPE to HYPE via Kinetiq Protocol * Swap HYPE to USDT0 via internal exchange * Transfer USDT0 to user wallet *** ### Unstake kHYPE to Native HYPE Unstake `kHYPE` back to the native `HYPE` token on HyperEVM. [**Try this route →**](https://happypath.enso.build/?chainId=999\&tokenIn=0xfd739d4e423301ce9385c1fb8850539d657c296d\&tokenOut=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) ```javascript theme={null} const KHYPE = "0xfd739d4e423301ce9385c1fb8850539d657c296d" as Address; const HYPE = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: HYPEREVM_CHAIN, amountIn: ["1000000000000000000"], // 1 kHYPE tokenIn: [KHYPE], tokenOut: [HYPE], routingStrategy: "delegate", slippage: "50", // 0.5% slippage referralCode: "kinetiq-unstake-native", }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` **Route Mechanics:** * Unstake kHYPE to native HYPE. *** ### Unstake kHYPE to KEI Unstake `kHYPE` and convert the underlying assets to Wrapped Ethereum (`KEI`) on HyperEVM. [**Try this route →**](https://happypath.enso.build/?chainId=999\&tokenIn=0xfd739d4e423301ce9385c1fb8850539d657c296d\&tokenOut=0xb5fe77d323d69eb352a02006ea8ecc38d882620c) ```javascript theme={null} const KHYPE = "0xfd739d4e423301ce9385c1fb8850539d657c296d" as Address; const KEI = "0xb5fe77d323d69eb352a02006ea8ecc38d882620c" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: HYPEREVM_CHAIN, amountIn: ["1000000000000000000"], // 1 kHYPE tokenIn: [KHYPE], tokenOut: [KEI], routingStrategy: "delegate", slippage: "100", // 1% slippage referralCode: "kinetiq-unstake-weth", }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` **Route Mechanics:** * Unstake kHYPE to HYPE and swap to KEI (WETH). *** ### Unstake kHYPE to UBTC Unstake `kHYPE` and convert the underlying assets to Wrapped Bitcoin (`UBTC`) on HyperEVM. [**Try this route →**](https://happypath.enso.build/?chainId=999\&tokenIn=0xfd739d4e423301ce9385c1fb8850539d657c296d\&tokenOut=0x9fdbda0a5e284c32744d2f17ee5c74b284993463) ```javascript theme={null} const KHYPE = "0xfd739d4e423301ce9385c1fb8850539d657c296d" as Address; const UBTC = "0x9fdbda0a5e284c32744d2f17ee5c74b284993463" as Address; const routeParams: RouteParams = { fromAddress: userAddress, receiver: userAddress, chainId: HYPEREVM_CHAIN, amountIn: ["1000000000000000000"], // 1 kHYPE tokenIn: [KHYPE], tokenOut: [UBTC], routingStrategy: "delegate", slippage: "100", // 1% slippage referralCode: "kinetiq-unstake-wbtc", }; const route = await client.getRouteData(routeParams); await sendSmartWallet(route.tx, route.gas); ``` **Route Mechanics:** * Unstake kHYPE to HYPE and swap to UBTC. ### Zap PLUME into Mystic myUSDC Vault Deposit native PLUME and convert it into a myUSDC vault position on Mystic. [**Try this route →**](https://happypath.enso.build?chainId=98866\&tokenIn=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\&tokenOut=0x6c92efa3F77760619bb13d395836415ac18C86dc) ```javascript theme={null} // SDK Example const client = new EnsoClient({ apiKey: 'your-api-key' }); const routeData = await client.getRouteData({ fromAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', receiver: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', chainId: 98866, amountIn: ['1000000000000000000'], slippage: '300', tokenIn: ['0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'], tokenOut: ['0x6c92efa3F77760619bb13d395836415ac18C86dc'], routingStrategy: 'router' }); // If using 'router' strategy, approval is often required for the input token. await sendEoa(client.getApprovalData(routeData.route.tokenIn[0])); await sendEoa(routeData.tx, routeData.gas); ``` **Route Mechanics:** * swap PLUME (input token) for USDC.e * deposit USDC.e into the myUSDC pool, interacting with primary `0xCE192A6E105cD8dd97b8Dedc5B5b263B52bb6AE0` *** ### Deposit native PLUME into Solera aPlunALPHA Deposit native PLUME and convert it into a Solera aPlunALPHA vault position. [**Try this route →**](https://happypath.enso.build?chainId=98866\&tokenIn=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\&tokenOut=0x5d0EC9B10e6759719CeFE14b8c881634678b32f2) ```javascript theme={null} // SDK Example const client = new EnsoClient({ apiKey: 'your-api-key' }); const routeData = await client.getRouteData({ fromAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', receiver: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', chainId: 98866, amountIn: ['1000000000000000'], slippage: '300', tokenIn: ['0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'], tokenOut: ['0x5d0EC9B10e6759719CeFE14b8c881634678b32f2'], routingStrategy: 'router' }); // If using 'router' strategy, approval is often required for the input token. await sendEoa(client.getApprovalData(routeData.route.tokenIn[0])); await sendEoa(routeData.tx, routeData.gas); ``` **Route Mechanics:** * swap PLUME for PUSD using `enso.swap` action * deposit `PUSD` into `NALPHA Nucleus` pool, interacting with primary `0xc9f6a492fb1d623690dc065bbced6dfb4a324a35` * deposit `NALPHA` into the `Solera` pool, interacting with primary `0x5d0ec9b10e6759719cefe14b8c881634678b32f2` *** ### Deposit USDC.e into Nucleus nYIELD Vault Deposit bridged USDC.e and convert it into an nYIELD vault position on Nucleus. [**Try this route →**](https://happypath.enso.build?chainId=98866\&tokenIn=0x78adD880A697070c1e765Ac44D65323a0DcCE913\&tokenOut=0x892DFf5257B39f7afB7803dd7C81E8ECDB6af3E8) ```javascript theme={null} // SDK Example const client = new EnsoClient({ apiKey: 'your-api-key' }); const routeData = await client.getRouteData({ fromAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', receiver: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', chainId: 98866, amountIn: ['1000000000'], slippage: '300', tokenIn: ['0x78adD880A697070c1e765Ac44D65323a0DcCE913'], tokenOut: ['0x892DFf5257B39f7afB7803dd7C81E8ECDB6af3E8'], routingStrategy: 'delegate' }); await sendSmartWallet(routeData.tx, routeData.gas); ``` **Route Mechanics:** * swap `USDC` for `PUSD` using `enso.swap` action * deposit `PUSD` into `nYIELD Nucleus` pool, interacting with primary `0x92a735f600175fe9ba350a915572a86f68ebbe66` to get `nUSDY` *** ### Deposit USDC.e into Tempest PUSD Vault Deposit bridged USDC.e and convert it into a Tempest PUSD vault position. [**Try this route →**](https://happypath.enso.build?chainId=98866\&tokenIn=0x78adD880A697070c1e765Ac44D65323a0DcCE913\&tokenOut=0x3C4F9804ce0810821F61289Eb4F92c8E5007c119) ```javascript theme={null} // SDK Example const client = new EnsoClient({ apiKey: 'your-api-key' }); const routeData = await client.getRouteData({ fromAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', receiver: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', chainId: 98866, amountIn: ['1000000000'], slippage: '300', tokenIn: ['0x78adD880A697070c1e765Ac44D65323a0DcCE913'], tokenOut: ['0x3C4F9804ce0810821F61289Eb4F92c8E5007c119'], routingStrategy: 'delegate' }); await sendSmartWallet(routeData.tx, routeData.gas); ``` **Route Mechanics:** * swap `USDC.e` for `PUSD` using `enso.swap` action * deposit `PUSD` into `Tempest pool`, interacting with primary `0x3C4F9804ce0810821F61289Eb4F92c8E5007c119` *** ### Stake PLUME for pETH on Dinero Deposit native PLUME and convert it into the pETH liquid staking derivative on Dinero. [**Try this route →**](https://happypath.enso.build?chainId=98866\&tokenIn=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\&tokenOut=0x39d1F90eF89C52dDA276194E9a832b484ee45574) ```javascript theme={null} // SDK Example const client = new EnsoClient({ apiKey: 'your-api-key' }); const routeData = await client.getRouteData({ fromAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', receiver: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', chainId: 98866, amountIn: ['1000000000'], slippage: '300', tokenIn: ['0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'], tokenOut: ['0x39d1F90eF89C52dDA276194E9a832b484ee45574'], routingStrategy: 'delegate' }); await sendSmartWallet(routeData.tx, routeData.gas); ``` *** ### Deposit PUSD into Rooster (nALPHA/PUSD) LP Deposit PUSD and convert it into a Rooster (nALPHA/PUSD) LP position. [**Try this route →**](https://happypath.enso.build?chainId=98866\&tokenIn=0xdddd73f5df1f0dc31373357beac77545dc5a6f3f\&tokenOut=0xfc3bd0e01b4e755aedd2a4087ccdb90c4d28f038) ```javascript theme={null} // SDK Example const client = new EnsoClient({ apiKey: 'your-api-key' }); const routeData = await client.getRouteData({ fromAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa960
프로젝트로 돌아가기