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.
The strategy must be inactive
Parameter | Description |
---|---|
| Address of the token to sweep |
| Overrides slippage setting |
UpdateParams
Only the Strategist can call this function
This function updates specific strategy parameters.
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 |
---|---|
| An array of garden member who voted on strategy |
| An array of votes by on strategy by garden members |
| 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 |
---|---|
| The capital to allocate to this strategy |
| 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 |
---|---|
| The fee paid to keeper to compensate the gas cost |
| URL with the JSON for the strategy to grant NFT to the strategist |
| 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 |
---|---|
| The amount of capital to unwind |
| 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 |
---|---|
| The keeper fee |
SetData
Only the garden can call this function
Sets the data for the operations of this strategy.
Parameter | Description |
---|---|
| An array with the op types |
| Addresses with the integration for each op |
| 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 |
---|---|
| Token to exchange |
| Amount of tokens to send |
| Token to receive |
| 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 |
---|---|
| Whether is a deposit or withdraw |
| 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 of the smart contract to call |
| Quantity of Ether to provide the call (typically 0) |
| Encoded function selector and arguments |
| 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 |
---|---|
| Spender address to be allowed |
| Asset address |
| 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 |
---|---|
| Garden address |
| Strategist address |
| Length of the array of addresses with the integration for each op |
| Stake of the strategist in this strategy |
| Total positive votes for the strategy |
| Total negative votes for the strategy |
| Capital allocated for the strategy in reserveAsset |
| Capital returned by the strategy after finalization in reserveAsset |
| Duration of the strategy (in seconds) |
| Expected positive % profit (i.e. 5%) in 18 decimals precision. |
| Amount of max capital to allocate to the strategy |
| Address of the strategyNFT |
| Timestamp when the strategy was created |
| Net Asset Value of the strategy in reserveAsset |
GetStrategyState
Function to get the state of the strategy.
Parameter | Description |
---|---|
| Address of the strategy |
| Whether or not the strategy is active |
| Whether or not the strategy data is set |
| Whether or not the strategy has finalized |
| Timestamp of initial execution (0 if still not executed) |
| Timestamp of strategy finalization (0 if still not finalized) |
| Timestamp of last strategy update |
GetStrategyRewardsContext
Function to get all relevant context strategy data required for BABL mining program calculations.
Parameter | Description |
---|---|
| Address of the strategist |
| Context data. See below. |
| 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