Skip to main content
The defindex-strategy adapter maps each DeFindex vault to a controller supply account for one underlying asset. The strategy calls the controller. The DeFindex vault implements share accounting and inflation protection. Read Vault integrations for lending balances, nested authorization, rounding, and account lifecycle.

Deploy an instance

Deploy one strategy instance per asset, hub, and spoke combination. The same Wasm can be reused with different constructor arguments:
A missing or incorrectly typed argument raises #401 NotInitialized. The constructor verifies that the configured market has an index, resolves the pool address through the controller, and stores the configuration. Each vault gets its own lending account. The adapter records that id in VaultAccount(vault_address); vaults do not share an account.

Call the strategy API

The adapter implements DeFindexStrategyTrait with five entrypoints. It exposes no account-id lookup view. Deposit and withdrawal return collateral balances, not vault shares. An existing balance or unsolicited supply is included in a deposit’s returned total; do not treat that total as the deposit increment.

Deposit and withdraw

A deposit measures tokens received from from, resolves the vault’s account, and authorizes its token transfer to the pool. It calls controller.supply with the stored id or 0, persists the returned id, and returns the resulting collateral balance. See the supply authorization recipe. Resolve the account before authorizing the pool transfer. After a full withdrawal, the next deposit can recreate the account and use its current authorization tree. Withdrawal reads the account balance and rejects requests above it. An amount exactly equal to that balance is converted to the controller’s 0 full-close sentinel. The pool pays to directly; no strategy token-transfer authorization is needed. A full withdrawal clears the vault mapping. The controller’s full-close payout rounds down, so a request for the displayed balance can pay one native unit less. The adapter returns the remaining collateral balance rather than the amount paid.

Read harvest events

harvest emits HarvestEvent at ["strategy", "harvest"]. Its price_per_share is the configured market’s supply index rescaled from RAY to 12 decimals:
The event’s amount is always 0. Harvest moves no funds and changes no position balances. It renews the strategy instance’s storage lifetime and emits the event. Vault share accounting remains the vault’s responsibility.

Preserve the vault-to-account mapping

VaultAccount(vault) is the adapter’s only link to that vault’s collateral. There is no entrypoint for assigning a replacement id. Clearing a mapping while its account remains live makes those funds unreachable through the adapter. Account resolution distinguishes three outcomes:
A failed controller lookup is not evidence that the account is absent. Preserve this distinction when adapting the strategy; never clear a live account’s only mapping because a lookup failed.
The constructor and all five methods renew instance storage. Mapping writes and successful live-account resolution renew the mapping. Harvest renews the instance only; it does not renew vault mappings. Maintain the vault and lending account storage described in Vault integrations.

Handle adapter errors

These codes belong to the adapter’s own error enum, separate from protocol error enums:

Verify an adapted strategy

Test deposit, balance, and withdrawal round trips; third-party payout; accrued interest; and account recreation after a full exit. Preserve the three-way lookup behavior and storage renewal. Test the vault’s inflation guard and share accounting separately from the adapter. See the Controller ABI for the underlying lending calls and Interest and revenue for supply-index accounting.