Configure Adapters

What are adapters?

The Credit Account design enables active interaction with the DeFi ecosystem while borrowing — such as swapping tokens, depositing into vaults, claiming rewards, and more. However, allowing arbitrary operations poses security risks.

Adapters — modular contracts that enable secure, controlled interactions with external protocols.

Why do curators need to configure adapters?

Having adapters properly configured in the market is essential for allowing collateral swaps, 1-click leverage and other UX features of Gearbox protocol.

circle-info

Existing offchain infra (Front End, Liquidator) rely on router for finding paths from/to available collaterals. Router is not part of Gearbox protocol, therefore it’s not present in Bytecode repository. Router is used by Gearbox SDK to provide swap paths and it doesn’t interact with core contracts directly.

What protocols are already integrated?

Protocol
Supported actions

Uniswap, Sushiswap, Oku Trade V2arrow-up-right, V3arrow-up-right

Swaps

Swaps, Stableswap LP deposits

Swaps, LP deposits

Mellowarrow-up-right ERC4626 vaults, DVstETH

Instant deposits, Delayed withdrawals

Velodrome, Aerodrome V3, Stableswap

Swaps

Camelot, Thena (Algebra AMM dexes) V3

Swaps

Napier

PT Swaps, LP deposits

Convex

Staking LP, claiming rewards

Camelot, Thena, Quickswap (Algebra AMM) V3

Swaps

Trader Joe

Swaps

Infrared

Staking LP, claiming rewards

Sky

DAI - USDS conversion, Staking USDS for SKY

Lido

stETH - wstETH conversion

Instant deposits and withdrawals (whenever possible)

Deposit into Island, Swaps in pool

Uniswap V4

Swaps

InfiniFi

Instant deposits, Delayed withdrawals

All the source code and audit reports of the contracts can be found in Bytecode Repositoryarrow-up-right. Use search, click on the target contract and then View Source or View Report. All the Adapters can be found by searching for the ADAPTER domain in Bytecode Repository.

setup example (BNB chain: USD1 pool, USDX collateral)arrow-up-right

setup example (Ethereum chain: tBTC pool, uptBTC collateral)arrow-up-right

setup example (Ethereum chain: USDC pool, frxUSD/USDf collateral)arrow-up-right

chevron-rightUniswap, Sushiswap V2hashtag

Router configuration

For the router on the chain to support swaps, Uniswap V2 worker should be configured.

It requires passing the following addresses:

circle-exclamation
  • Configure adapter to whitelist pools:

  • Uni V2

    • Configuration requires specifying tokens from a pair

    • Sushi V2

      • Configuration requires specifying tokens from a pair

chevron-rightUniswap, Sushiswap, Pancakeswap, IguanaDEX, Oku trade V3hashtag

Router configuration

For the router on the chain to support swaps, Uniswap V3 worker should be configured.

It requires passing the following addresses:

circle-info

Router deployment must have bytecode of Uniswap's SwapRouter.solarrow-up-right contract. Sometimes it has only SwapRouter02arrow-up-right deployment specified. On some chains that was already solved by deploying required implementation of router (see below). If it's not, reach out to Gearbox contributors.

circle-exclamation
chevron-rightVelodrome, Aerodrome Concentrated Liquidity (Slipstream)hashtag

For the router on the chain to support swaps, Uniswap V3 worker should be configured.

It requires passing the following addresses:

chevron-rightCurve StableSwap, CryptoSwap and StableNGhashtag
  • How to understand what's the type of the pool of interest:

    1. Go to the block explorer page of Curve Address provider on a chain of interest: https://docs.curve.finance/deployments/integration/arrow-up-right

    2. Call Address Provider's get_address method with id = 7 to get address of MetaRegistry On Mainnet MetaRegistry is located herearrow-up-right.

    3. Call get_registry_handlers_by_pool of MetaRegistry, passing target pool address as argument.

    4. Check non-zero address from step 3. output. It usually has clues in first lines of its code.

circle-exclamation
  • If the pool is not Stable NG: &#xNAN;Select Curve V1 2/3/4 Assets adapter depending on the number of different tokens in target pool:

  • If the pool is Stable NG: &#xNAN;Select Curve StableNG adapter:

triangle-exclamation
  • Adapter arguments:

    • Target Address

      • The address of the pool

    • LP token

      • The address of the pool's LP token (may be different from pool itself)

    • Base Pool Address

    • Crypto Swap or PancakeSwap pool

      • If Type of Pool is Crypto Swap (a.k.a Twocrypto/ Tricrypto) checkout this box.

  • ETH Gateway deployments:

chevron-rightPancakeSwap/ IguanaDEX StableSwaphashtag
circle-exclamation
  • Select Curve V1 2 Assets adapter:

    • Target Address

      • The address of the pool

    • LP token

      • The address of the pool's LP token (can be retreived by calling token() method of pool contract)

    • Base Pool Address

      • Not applicable to PancakeSwap. Leave untouched.

    • Crypto Swap or PancakeSwap pool

      • Checkout this checkbox.

chevron-rightPendlehashtag

Router configuration

For the router on the chain to support swaps, Pendle worker should be configured.

It requires passing the following addresses:

  • routerStatic

Adapter configuration

circle-exclamation
  • Configure adapter to whitelist pools: &#xNAN;Configuration requires specifying market address and input/output tokens

  • Market:

  • Input token: Select a token that is in the "1 SY Equals To" row on the screenshot above ^

  • Pendle token: Target PT token

chevron-rightFluid DEXhashtag

Router configuration

For the router on the chain to support swaps, Fluid worker should be configured.

It requires passing the following addresses:

  • fluidDexResolver

circle-exclamation
  • Add Fluid DEX adapter (requires providing DEX address)

triangle-exclamation
circle-info

DEX addresses have names in the similar format: Dex_wstUSR_USDT. Search the name based on required tokens above.

  • ETH Gateway deployments:

    • Mainnet:

      • Dex_wstETH_ETH: 0x9f294BF3201533B652aFb6B10c0385972C28a16f

      • ezETH_ETH: 0xa59fc0102b7c2aee66e237ee15cb56ad58a97b2e

      • rsETH_ETH: 0xb219cE3Fa907edCb375B7375F3C50d920e244bba

      • weETH_ETH:

        0x0A226E0efa6FCF26837441d623210A9464349200

chevron-rightERC4626hashtag

Takes ERC4626 Vault Address as parameter. Target vault must be added as Asset to Market and as Collateral to Credit Manager.

circle-exclamation

Operates using deposit, withdraw, mint and redeem functions of ERC4626 standard. Allows performing swaps from the vault’s asset token into ERC4626 vault share token.

circle-info

Sometimes tokens look very much like ERC4626 but with overwritten methods, like those implementing timelocked deposits and withdrawals. Note that this adapter works with vanilla standard methods only. e.g. sUSDe can be minted from USDe using ERC4626 deposit interface, but has timelocked withdrawals.

chevron-rightKodiak Islandhashtag

Router configuration

For the router on the chain to support swaps, Kodiak Island worker should be configured.

It requires passing:

  • _kodiakIslandRouter - 0x679a7C63FC83b6A4D9C1F931891d705483d4791F

  • _kodiakSwapRouter - 0xEd158C4b336A6FCb5B193A5570e3a571f6cbe690

  • _kodiakQuoter - 0x644C8D6E501f7C994B74F5ceA96abe65d0BA662B

Takes Gateway Address as parameter. On Berachain it's 0x8d41361d340515d1cdd8c369ca7b5c79f6b2e9c9.

After adding adapter, click configure to whitelist particular Islands.

circle-exclamation
chevron-rightConvex-staked Curve LPhashtag
circle-exclamation

Add Convex Base Reward Pool adapter.

  • Base Reward Pool Address:

    • Rewards contract address from Convex pool Info.

  • Staked phantom token:

    • Staked Phantom Token can be found by its symbol. If the Curve LP token has symbol frxUSDUSDf, then Convex deposit token will have symbol stkcvxfrxUSDUSDf.

Add Convex Booster adapter

circle-check
circle-info

Booster address is single across all chains and is suggested as default option.

Update Convex booster Pool IDs

circle-info

After each new Convex pool is added, Booster pool ids should be updated.

chevron-rightBalancer V2hashtag

Router configuration

For the router on the chain to support swaps, Balancer V2 worker should be configured.

Configuration requires passing:

  • BalancerQueries

Balancer deployment addresses can be found herearrow-up-right.

Adapter configuration

circle-exclamation
  • Finding Pool LP Token Address:

  • Configure adapter to whitelist pools:

  • Configuration requires specifying PoolID which can be found on Balancer UI

chevron-rightBalancer V3hashtag

Router configuration

For the router on the chain to support swaps, Balancer V3 worker should be configured.

Configuration requires passing:

Balancer deployment addresses can be found herearrow-up-right.

BalancerV3MultiActionQueries deployments:

  • Plasma

    • 0x1a9B1bfD35fA3932493b5f4F20Cb16b2B88Cc0C8

  • Mainnet

    • 0x0BA8417d19D87b7b5C9dA8762ba505d61D1bF1E7

  • Optimism

    • 0x1b8a4BA520C7789D7bE7476960B8Cdd42e57d928

Adapter configuration

  • Add BalancerV3 adapter (requires providing Gateway address):

  • Gateway deployment addresses:

    • Ethereum:

      • v3.10 (outdated) 0x21f55223de449224e8bdf4f59452e072bdf7af57

      • v3.11 (up to date) 0x8A57c21234ddc225499843F6A073dd374c952560

    • Plasma:

      • v3.10 (outdated) 0xd5c89297ad23e12d7f0ff24112418dbe9ebeae56

      • v3.11 (up to date) 0x55109bA88c396008cfBe9F27Ad97A7e1e4394f6F

    • Optimism:

      • v3.11 (up to date) 0x77b2dfc344072fa242f2d03893ccbdbb0ef47b7c

circle-exclamation
circle-info

What are wa-tokens? It's erc4626 vaults representing positions staked in Aave pools. To support swaps from wstETH through waEthLidowstETH/rstETH boosted Balancer pool, you need to include wa-token as collateral and add erc4626 adapter with wa-token address as vault which will process swaps from wstETH to waEthLidowstETH.

  • Finding Pool LP Token Address:

  • Configure adapter to whitelist pools:

  • Configuration requires specifying Pool Address which can be found on Balancer UI

chevron-rightMellow ERC4626hashtag

Router configuration

For the router on the chain to support swaps, Mellow worker should be configured. Reach out to contributors for support.

circle-exclamation

Add Mellow ERC4626 adapter:

  • Vault address

    • Select a corresponding Mellow vault (LRT itself) that was previously added as collateral.

  • Phantom Token

    • A token that tracks user's position in withdrawal queue and allows unstaking LRT right from the Credit Account.

Add Mellow claimer adapter:

This adapter allows claiming unstaked tokens after the redemption request was processed.

Mellow Claimer is a contract deployed by Mellow. Deployment addresses can be found here: https://docs.mellow.finance/multi-deployments#navigationarrow-up-right

Configure Mellow Claimer Adapter

  • Multi vault

    • Mellow LRT itself

  • Phantom token

    • A token that tracks user's position in withdrawal queue and allows unstaking LRT right from the Credit Account.

chevron-rightMidas (direct deposits & redemptions)hashtag

Midas risks:

- If Midas rejects a withdrawal request, a credit account that has the request rejected will have its phantom token balance locked and non-claimable. This means that de-facto the account has bad debt (that cannot be liquidated) until the situation is resolved manually

- A gateway has a function to manually process a cancelled request by paying an amount of at least pendingTokenOutAmount for the respective credit account (the function can be called by anyone). This will allow the credit account to claim a withdrawal as if it was normally processed

- It's best to forbid the withdrawal phantom token if there is a rejected request to Gearbox CA, since Midas might accidentally refund the withdrawal to the CA itself, leading to double counting. Forbidding the token will prevent the user to borrow and withdraw more against their collateral in this case.

circle-exclamation

Gateway addresses:

  • Plasma

    • Hyperithm Curator: 0xB375DF6a1D7a1c172e65D4FBDA2d3caa144Bf8e7

Phantom token addresses:

  • Plasma

    • Hyperithm Curator: 0x0835e60e9A56734cEE76e3953c3BE0635Fcb71d5

chevron-rightVelodrome, Aerodrome V1 & V2 (Basic volatile and Basic stable)hashtag

For the router on the chain to support swaps, Velodrome worker should be configured.

It requires passing the following addresses:

  • Router

  • Add Velodrome V2 adapter (requires providing Router address):

chevron-rightUniswap V4hashtag

Router configuration

For the router on the chain to support swaps, Uniswap V3 worker should be configured.

It requires passing the following addresses:

circle-exclamation
  • Configure adapter to whitelist Configuration requires specifying tokens and fee from a pair

Last updated