User docs
Search
K

Token Adapters

The following details the steps necessary for integrating a new adapter into the Alchemix V2 protocol.

Token Adapter Governance Process

There are three steps, including 2 separate AIPs (Alchemix Improvement Proposals), needed to get an adapter approved and connected in an Alchemix V2 debt system. The first AIP is technically optional, as both AIPs could be condensed into a single AIP if the integration developer is comfortable putting in the development work upfront without pre-approval.
The Community Governance Process details the general governance steps that should be followed for each AIP.

Step 1

Propose the new yield source for integration, and request grant funding.
The purpose of this step is for the integrator/proposer to verify that the Alchemix DAO wants to integrate the proposed yield strategy. Additionally, the integrator/proposer can request a pre-approved grant of ALCX tokens, to be paid out when the Adapter is deployed in step 2.
A template for Step 1 proposals will be provided in the future.

Step 2

Write, deploy and verify the ITokenAdapter compliant adapter. See Technical Requirements below.

Step 3

Propose integration of the new yield source using the new adapter.
The following parameters need to be approved in at least one of the two AIPs:
  • Target network (eg. ETH Mainnet, Optimism, etc…)
  • Yield bearing asset name & address (include etherscan & github links)
  • Collateral asset name & address (include etherscan & github links)
  • Maximum Loss expressed in basis-points, eg. 50 for 0.5%) more info
  • Deposit cap (expressed in units of underlying collateral) more info
  • Credit unlock blocks (how long after a harvest does it take for the yield to be distributed to depositors) more info
The following needs to be approved as well, once development and deployment are complete:
  • Adapter name & address
  • Multisig transaction details that should be executed by the Alchemix dev multisig, detailed here
NOTE: To be clear, all of the above bullet points only need to be approved ONCE by governance. It is up to the the builder whether or not they want pre-approval before creating and deploying the new adapter, or if they want to make a single AIP for approval once the adapter is built, deployed, and verified.

Technical Requirements

  1. 1.
    Build a token adapter that is compliant with the ITokenAdapter interface, along with a set of unit & integration tests, and make a pr against the master branch of the Alchemix V2 Repo.
  2. 2.
    Once the pr is approved and merged by the core team, deploy the contract to the target network.
  3. 3.
    Make a pr against the master branch of the deployments repo that includes the artifacts from the deployment (json file containing, at a minimum, the abi & address of the deployed adapter).

Dev Multisig Transactions

Relevant addresses for already-deployed Alchemix contracts can be found in the deployments repo.

Enable a new adapter

  1. 1.
    TARGET_ALCHEMIST_ADDRESS.addYieldToken(YIELD_TOKEN_ADDRESS, (ADAPTER_ADDRESS, MAXIMUM_LOSS, MAXIMUM_EXPECTED_VALUE, CREDIT_UNLOCK_BLOCKS));
    1. 1.
      YIELD_TOKEN_ADDRESS = the address of the yield token being integrated
    2. 2.
      ADAPTER_ADDRESS = the address of the newly deployed adapter
    3. 3.
      MAXIMUM_LOSS = the maximum loss value (in bps) from the AIP
    4. 4.
      MAXIMUM_EXPECTED_VALUE = the deposit cap value (in units of underlying collateral) from the AIP
    5. 5.
      CREDIT_UNLOCK_BLOCKS = the credit unlock blocks value from the AIP
  2. 2.
    TARGET_ALCHEMIST_ADDRESS.setYieldTokenEnabled(YIELD_TOKEN_ADDRESS, true);
    1. 1.
      YIELD_TOKEN_ADDRESS = the address of the yield token being integrated

Upgrade an adapter

(If the newly deployed adapter is an upgraded adapter for an existing yield token)
  1. 1.
    TARGET_ALCHEMIST_ADDRESS.setTokenAdapter(YIELD_TOKEN_ADDRESS, ADAPTER_ADDRESS);
    1. 1.
      YIELD_TOKEN_ADDRESS = the address of the yield token being integrated
    2. 2.
      ADAPTER_ADDRESS = the address of the newly deployed adapter

Create a harvest job for the Alchemix Keeper

  1. 1.
    HARVEST_RESOLVER_ADDRESS.addHarvestJob(true, YIELD_TOKEN_ADDRESS, ALCHEMIST_ADDRESS, MINIMUM_HARVEST_AMOUNT, MINIMUM_DELAY, SLIPPAGE_BPS);
    1. 1.
      details on these parameters can be found here
    2. 2.
      MINIMUM_HARVEST_AMOUNT should be set to a value that can be expected to be harvested every 1-2 days
    3. 3.
      MINIMUM_DELAY should be set to 1-2 days