Building A Strategy
Strategies will soon be deprecated in favour of Solvers.
You can start building your first strategy by forking the starter repo and reading through the sample code to get started.
In this section, we explain some core concepts that will help with building your first strategy.
Placing and updating positions
Haiko strategies rely on a push rather than pull architecture for position updates.
Rather than periodically submitting updates to the contract, positions are updated only when a swap is executed (and crucially, before the swap occurs).
The lifecycle of a swap is as follows:
User submits swap via
MarketManager
MarketManager
callsupdate_positions()
and passes the execution context to theStrategy
contractStrategy executes logic to place, update or withdraw positions
Strategy passes execution context back to
MarketManager
MarketManager
executes swap
Deploying a strategy
Strategies are deployed by creating a market and registering the strategy to that market upon deployment. At the moment, each market can have at most one strategy to limit the gas costs of swap execution.
Strategies must first be whitelisted by the protocol owner in order to be deployed.
Deposits, withdrawals and fees
Strategy writers are free to implement proprietary logic for enabling third-party LP deposits and withdrawals, and charging associated fees on these actions.
While official Haiko strategies will charge a small fee on withdrawals, this is not prescribed for third party strategies, but rather left at the discretion of strategy builders.
Last updated