Strategies
Interface

Interface and Spec

This documentation covers methods and events in the IStrategy.sol (opens in a new tab) interface. See Writing a Custom Strategy for more information on implementing your own strategies, including how to use the provided BaseStrategy.sol (opens in a new tab)

Functions

initialize

function initialize(uint256 _poolId, bytes memory _data) external

Used when createPool is called to set up the strategy. This function should emit an Initialized and a PoolActive event.

Parameters

nametypedescription
_poolIduint256poolId assigned by Allo when the pool is created
_databytesAny initial data required by the strategy. BaseStrategy.sol does not require any data.

registerRecipient

function registerRecipient(bytes memory _data, address _sender) external payable returns (address)

registerRecipient is called by Allo.sol to add new recipients to the pool. This function must return a recipientId address. This function should emit a Registered event.

Parameters

nametypedescription
_databytesAny data required by the strategy to register the recipient.
_senderaddressAddress that made the call to Allo.sol.

allocate

function allocate(bytes memory _data, address _sender) external payable

allocate is called by Allo.sol to make allocations to a recipient. This function should emit an Allocated event.

Parameters

nametypedescription
_databytesAny data required by the strategy to allocate to a recipient.
_senderaddressAddress that made the call to Allo.sol.

distribute

function distribute(address[] memory _recipientIds, bytes memory _data, address _sender) external

distribute is used to distribute tokens to recipients. This function should emit a Distributed event.

Parameters

nametypedescription
_recipientIdsaddress[]Array of recipient addresses to distribute tokens to.
_databytesAny data required by the strategy to distribute tokens.
_senderaddressAddress that made the call to Allo.sol.

Views

IStrategy.sol exposes the following views:

namedescription
getAllo()Returns the address of the Allo contract.
getPoolId()Returns the PoolId for this strategy.
getStrategyId()Returns the id of the strategy.
isValidAllocator(address _allocator)Returns a boolean indicating whether provided address is a valid allocator.
isPoolActive()Returns a boolean indicating whether pool is active.
getPoolAmount()Returns the amount of funding in the pool.
getRecipientStatus()Returns a the status of a recipient.
getPayouts(address[] memory _recipientIds, bytes[] memory _data)Returns a PayoutSummary[] for the provided recipientIds.