Strategy

Interface: IStrategy.sol

Functions

The following functions can be called by any user or public roles.

Sweep

Public: Anyone can call this function.

This function converts any token sent to the strategy into the reserve asset and sends it to the garden.

function sweep(address _token, uint256 _newSlippage) external;

The strategy must be inactive

Parameter
Description

address _token

Address of the token to sweep

uint256 _newSlippage

Overrides slippage setting

UpdateParams

Only the Strategist can call this function

This function updates specific strategy parameters.

function updateParams(uint256[5] calldata _params) external;
Parameter
Description

Array of 5 parameters. See below.

Definition of strategy parameters:

New duration value must be equal or less than the original duration.

DeleteCandidateStrategy

Only the Strategist can call this function

This function deletes a candidate strategy.

Privileged Functions

The following functions can only be executed by protocol privileged roles.

ResolveVoting

Only the protocol Keeper can call this function

This function adds off-chain gas-less voting results on-chain.

Parameters
Description

address[] calldata _voters

An array of garden member who voted on strategy

int256[] calldata _votes

An array of votes by on strategy by garden members

uint256 _fee

The fee paid to keeper to compensate the gas cost

ExecuteStrategy

Only the protocol Keeper can call this function

This function executes a strategy that has been activated and gone through the cooldown period.

Parameter
Description

uint256 _capital

The capital to allocate to this strategy

uint256 _fee

The fee paid to keeper to compensate the gas cost

FinalizeStrategy

Only the protocol Keeper can call this function

This function exits from an executed strategy. Returns balance back to the garden and sets the capital aside for withdrawals in ETH. Pays the keeper and updates the reserve asset position accordingly.

Parameter
Description

uint256 _fee

The fee paid to keeper to compensate the gas cost

string memory _tokenURI

URL with the JSON for the strategy to grant NFT to the strategist

uint256 _minReserveOut

Minimum reserve asset to get during strategy finalization

UnwindStrategy

Only the protocol Keeper can call this function

This function partially unwinds a strategy. Triggered from a penalty withdrawal in the Garden.

Parameter
Description

uint256 _amountToUnwind

The amount of capital to unwind

uint256 _strategyNAV

NAV of the strategy to unwind

ExpireStrategy

Only the protocol Keeper can call this function

This function expires a candidate that has spent more than CANDIDATE_PERIOD seconds without reaching quorum.

Parameter
Description

uint256 _fee

The keeper fee

SetData

Only the garden can call this function

Sets the data for the operations of this strategy.

Parameter
Description

uint8[] calldata _opTypes

An array with the op types

address[] calldata _opIntegrations

Addresses with the integration for each op

bytes memory _opEncodedData

64 bytes of operations metadata per operation (size of 64 * numOps)

Definition of types of operations:

Trade

Only a valid operation can call this function

Function that calculates the price using the oracle and executes a trade. Must call the exchange to get the price and pass minReceiveQuantity accordingly.

Parameter
Description

address _sendToken

Token to exchange

uint256 _sendQuantity

Amount of tokens to send

address _receiveToken

Token to receive

uint256 _overrideSlippage

Slippage to override (if any)

HandleWeth

Only a valid operation can call this function

Function that deposits or withdraws WETH from an operation in this context.

Parameter
Description

bool _isDeposit

Whether is a deposit or withdraw

uint256 _wethAmount

Amount to deposit or withdraw

InvokeFromIntegration

Only a valid integration can call this function

Helper to invoke a call to an external contract from integrations in the strategy context.

Parameter
Description

address _target

Address of the smart contract to call

uint256 _value

Quantity of Ether to provide the call (typically 0)

bytes calldata _data

Encoded function selector and arguments

return value

Bytes encoded return value

InvokeApprove

Only a valid integration can call this function

Helper to invoke Approve on ERC20 from integrations in the strategy context.

Parameter
Description

address _spender

Spender address to be allowed

address _asset

Asset address

uint256 _quantity

Amount to approve

View functions

The following functions can be called by anyone without a transaction to retrieve information from the strategy.

GetNAV

Function to get the strategy Net Asset Value (NAV) in reserveAsset.

OpEncodedData

Function to get encoded operation data (in bytes) where each consecutive 64 bytes are reserved for each operation metadata. Metadata is usually including operation addresses and values needed for those operations.

GetOperationsCount

Function to get the number of operations used by the strategy.

GetOperationByIndex

Function to get the operation data by index.

GetStrategyDetails

Function to get the details of the strategy.

Parameter
Description

address garden

Garden address

address strategist

Strategist address

uint256 opIntLength

Length of the array of addresses with the integration for each op

uint256 stake

Stake of the strategist in this strategy

uint256 totalPositiveVotes

Total positive votes for the strategy

uint256 totalNegativeVotes

Total negative votes for the strategy

uint256 capitalAllocated

Capital allocated for the strategy in reserveAsset

uint256 capitalReturned

Capital returned by the strategy after finalization in reserveAsset

uint256 duration

Duration of the strategy (in seconds)

uint256 expectedReturn

Expected positive % profit (i.e. 5%) in 18 decimals precision.

uint256 maxCapitalRequested

Amount of max capital to allocate to the strategy

address strategyNFT

Address of the strategyNFT

uint256 enteredAt

Timestamp when the strategy was created

uint256 nav

Net Asset Value of the strategy in reserveAsset

GetStrategyState

Function to get the state of the strategy.

Parameter
Description

address strategy

Address of the strategy

bool active

Whether or not the strategy is active

bool dataSet

Whether or not the strategy data is set

bool finalized

Whether or not the strategy has finalized

uint256 executedAt

Timestamp of initial execution (0 if still not executed)

uint256 exitedAt

Timestamp of strategy finalization (0 if still not finalized)

uint256 updatedAt

Timestamp of last strategy update

GetStrategyRewardsContext

Function to get all relevant context strategy data required for BABL mining program calculations.

Parameter
Description

address strategist

Address of the strategist

uin256[] memory data

Context data. See below.

bool[] memory boolData

Boolean context data. See below.

Definition of strategy context data:

IsStrategyActive

Function to check whether or not the strategy is active.

GetUserVotes

Function to get specific user votes for a user.

Strategist

Function to get the strategist address.

EnteredAt

Function to get the timestamp when the strategy was created.

EnteredCooldownAt

Function to get the timestamp when the strategy reached quorum.

Other view functions are the following:

Stake

Function to get the stake of the strategist in the strategy.

StrategyRewards

Function to get the assigned strategyRewards from BABL Mining program for the strategy.

MaxCapitalRequested

Function to get the max capital requested for the strategy in reserveAsset.

MaxAllocationPercentage

Function to get the maximum capital allocation percentage (%).

MaxTradeSlippagePercentage

Function to get the maximum trading slippage in % with 18 decimals precision.

MaxGasFeePercentage

Function to get the maximum gas fee percentage to limit the execution cost for the strategy-keeper.

ExpectedReturn

Function to get the expected return or expected profits in % with 18 decimals precision (i.e. 5% 5e16)

Duration

Function to get the duration of the strategy (in seconds).

TotalPositiveVotes

Function to get the total positive votes of the strategy.

TotalNegativeVotes

Function to get the total negative votes of the strategy.

CapitalReturned

Function to get the capital returned in reserveAsset.

CapitalAllocated

Function to get the capital allocated in reserveAsset.

Garden

Function to get the garden address the strategy belongs to.

Last updated

Was this helpful?