Garden
Interface: IGarden.sol​

ERC-20 Functions

Gardens are fully composable (ERC-20). That means all the ERC-20 functions are available.
You can see all of them here.

Functions

The following functions can be called by public roles.

Deposit

Anyone can call this function for public gardens. In case of private gardens the user requires specific permissions to deposit.
This function allow a user to deposit the _amountIn of reserve asset into the garden.
1
function deposit(
2
uint256 _amountIn,
3
uint256 _minAmountOut,
4
address _to,
5
address _referrer
6
) external payable;
Copied!
Parameter
Description
uint256 _amountIn
Amount of the reserve asset to deposit by the contributor
uint256 _minAmountOut
Min amount of Garden shares to receive by contributor
address _to
Address to mint Garden shares to
address _referrer
The user that referred the deposit

Withdraw

Only garden members: Any garden member can call this function.
This function withdraws the reserve asset based on the garden tokens passed as _amountIn in the garden and sends it back to the _to address.
1
function withdraw(
2
uint256 _amountIn,
3
uint256 _minAmountOut,
4
address payable _to,
5
bool _withPenalty,
6
address _unwindStrategy
7
) external;
Copied!
Parameter
Description
uint256 _amountIn
Quantity of the garden token to withdraw
uint256 _minAmountOut
Min quantity of reserve asset to receive
address payable _to
Address to send component assets to
bool _withPenalty
Whether or not this is a withdrawal that triggers a liquidation
address _unwindStrategy
Strategy to unwind if any. Zero address otherwise

ClaimReturns

Only garden members: Any garden member can call this function.
This function allows a user to claim the rewards from the strategies that were active while the user was a member of the garden.
1
function claimReturns(address[] calldata _finalizedStrategies) external;
Copied!
Parameter
Description
address[] calldata _finalizedStrategies
Array of finalized strategies to claim rewards from
It must include all finalized strategies since the last claim.

ClaimAndStakeReturns

Only garden members: Any garden member can call this function.
This function allows a user to claim the rewards from the strategies that executed while a member of the garden and stakes these rewards into the Heart Garden.
1
function claimAndStakeReturns(uint256 _minAmountOut, address[] calldata _finalizedStrategies) external;
Copied!
Parameter
Description
uint256 _minAmountOut
Min quantity of Heart Garden tokens (hBABL) to receive
address[] calldata _finalizedStrategies
Array of finalized strategies to claim and stake rewards from

ClaimNFT

Any garden member can call this function.
This function allows any garden member to claim a garden NFT.
1
function claimNFT() external;
Copied!

MakeGardenPublic

Only a garden creator can call this function.
The function makes public a previously private garden.
1
function makeGardenPublic() external;
Copied!

TransferCreatorRights

Only a garden creator can call this function.
The function allows a garden creator to transfer his creator rights to another account. The original creator can also renounce its creator role by assigning it to address(0) in public gardens.
1
function transferCreatorRights(address _newCreator, uint8 _index) external;
Copied!
Parameter
Description
address _newCreator
New creator address
uint8 _index
Index of the extra creator in the array of 4 extra-creators (if any)

AddExtraCreators

Only the original garden creator can call this function.
The function adds extra creators. Can only be called if all the addresses in the extra-creators array are zero (0x).
1
function addExtraCreators(address[4] memory _newCreators) external;
Copied!
Parameter
Description
address[4] memory _newCreators
Addresses of the new extra creators

ResetHardlock

Only a garden creator can call this function.
This function allows the creator to reset the garden hardlock for all users.
1
function resetHardlock(uint256 _hardlockStartsAt) external;
Copied!
Parameter
Description
uint256 _hardlockStartsAt
New global hardlock starts at timestamp.
​

UpdateCreators

Only Governance or team multi-sig can call this function.
The function can update garden owners (original owner and extra creators) only if the original creator renounced (creator == address(0)).
1
function updateCreators(address _newCreator, address[4] memory _newCreators) external;
Copied!
Parameter
Description
address _newCreator
New creator address
address[4] memory _newCreators
Addresses of the new extra creators

SetPublicRights

Only a garden creator can call this function.
The function gives the right to create strategies and/or voting power to garden users in a public garden.
1
function setPublicRights(bool _publicStrategist, bool _publicStewards) external;
Copied!
Parameter
Description
bool _publicStrategist
Whether or not all garden members will get be able to suggest strategies
bool _publicStewards
Whether or not all garden members will be able to vote on proposals

DelegateVotes

Only a garden creator can call this function.
The function allows a garden holding a governance token to delegate its voting power into a delegatee.
1
function delegateVotes(address _token, address _delegatee) external;
Copied!
Parameter
Description
address _token
Address of BABL or any other ERC20Comp related governance token
address _delegatee
Address to delegate token voting power into

UpdateGardenParams

Only a garden creator can call this function.
The function updates relevant garden params.
1
function updateGardenParams(uint256[12] memory _newParams) external;
Copied!
Parameter
Description
uint256[12] memory _newParams
New params. See below.
Definition of the garden parameters:
1
_newParams[0...11] are described in order:
2
​
3
* @param _maxDepositLimit Max deposit limit in reserve asset units
4
* @param _minLiquidityAsset Number that represents min amount of liquidity denominated in reserve asset
5
* @param _depositHardlock Number that represents the time deposits are locked for
6
* an user after the deposit. In seconds.
7
* @param _minContribution Min contribution to the garden in reserve asset units
8
* @param _strategyCooldownPeriod How long after the strategy has been activated, will it be ready
9
* to be executed. In seconds.
10
* @param _minVotesQuorum Percentage of votes needed to activate an strategy (0.01% = 1e14, 1% = 1e16)
11
* @param _minStrategyDuration Min duration of an strategy. In seconds.
12
* @param _maxStrategyDuration Max duration of an strategy. In seconds.
13
* @param _minVoters The minimum amount of voters needed for quorum.
14
* @param _pricePerShareDecayRate Decay rate of price per share. 1e18= 100%
15
* @param _pricePerShareDelta Base slippage for price per share. 1e18= 100%
16
* @param _canMintNftAfter Can mint NFT after being a member for X secs.
17
Copied!

AddStrategy

Only a strategist of a garden can call this function.
This function creates a new strategy calling the factory and adds it to the array.
1
function addStrategy(
2
string memory _name,
3
string memory _symbol,
4
uint256[] calldata _stratParams,
5
uint8[] calldata _opTypes,
6
address[] calldata _opIntegrations,
7
bytes calldata _opEncodedDatas
8
) external;
Copied!
Parameter
Description
string memory _name
Name of the strategy
string memory _symbol
Symbol of the strategy
uint256[] calldata _stratParams
Num params for the strategy
uint8[] callData _opTypes
Type for every operation in the strategy
address[] calldata _opIntegrations
Integrations to pass for each operation in order. One per operation.
bytes calldata _opEncodedDatas
64 bytes of operations metadata per operation (size of 64 * numOps)
Definition of the strategy parameters:
1
_stratParams[0]: maxCapitalRequested
2
_stratParams[1]: stake,
3
_stratParams[2]: duration,
4
_stratParams[3]: expectedReturn,
5
_stratParams[4]: maxPercentAllocation,
6
_stratParams[5]: maxGasFeePercentage,
7
_stratParams[6]: maxSlippagePercentage,
Copied!
Definition of operation types (opTypes):
1
// 0 = BuyOperation
2
// 1 = LiquidityOperation
3
// 2 = VaultOperation
4
// 3 = LendOperation
5
// 4 = BorrowOperation
6
// 5 = CustomOperation
Copied!
Integration addresses can be found in the deployments section.

ExpireCandidateStrategy

Only the strategist can call this function.
The function removes an expired candidate strategy from the strategy array.
1
function expireCandidateStrategy() external;
Copied!

Privileged Functions

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

FinalizeStrategy

Only a strategy can call this function.
When the strategy ends, this function saves returns and rewards, and marks the strategy as finalized.
1
function finalizeStrategy(
2
uint256 _rewards,
3
int256 _returns,
4
uint256 _burningAmount
5
) external;
Copied!
Parameter
Description
uint256 _rewards
Amount of Reserve Asset profits to set aside for strategist and stewards roles (if any)
int256 _returns
Strategy returns. It can include profits or losses.
uint256 _burningAmount
The amount of strategist stake to burn in case of strategy losses.

AllocateCapitalToStrategy

Only a strategy can call this function.
This function allocates garden capital to a strategy.
1
function allocateCapitalToStrategy(uint256 _capital) external;
Copied!
Parameter
Description
uint256 _capital
Amount of capital to allocate to the strategy.

PayKeeper

Only the garden or a strategy can call this function.
The function pays gas costs back to the keeper from executing transactions including any past debt.
1
function payKeeper(address payable _keeper, uint256 _fee) external;
Copied!
Parameter
Description
address payable _keeper
Keeper that executed the transaction
uint256 _fee
The fee paid to keeper to compensate the gas cost

VerifyGarden

Only governance or team multi-sig can call this function.
This function can mark a garden as verified.
1
function verifyGarden(uint256 _verifiedCategory) external;
Copied!
Parameter
Description
uint256 _verifiedCategory
1 for verified gardens, 0 otherwise. Additional categories will use different numbering in the future.

DepositBySig

Only the protocol Keeper can call this function.
This function allows the user to deposit into a garden by using signature-based gas-less transactions (meta-tx).
1
function depositBySig(
2
uint256 _amountIn,
3
uint256 _minAmountOut,
4
uint256 _nonce,
5
uint256 _maxFee,
6
address _to,
7
uint256 _pricePerShare,
8
uint256 _fee,
9
address _signer,
10
address _referrer,
11
bytes memory signature
12
) external;
Copied!
Parameter
Description
uint256 _amountIn
Amount of the reserve asset that is received from contributor.
uint256 _minAmountOut
Min amount of Garden shares to receive by contributor.
uint256 _nonce
Current nonce to prevent replay attacks.
uint256 _maxFee
Max fee user is willing to pay keeper. Fee is substracted from the user wallet approved amount unless it is subsidized totally or partially by the garden or treasury. Fee is expressed in reserve asset.
uint256 _to
Address to mint shares to.
uint256 _pricePerShare
Price per share of the garden calculated off-chain by Keeper.
uint256 _fee
Actual fee keeper demands. Have to be less than _maxFee.
address _signer
The user to who signed the signature.
address _referrer
The user that referred the deposit.
bytes memory _signature
Signature by the user to verify deposit params

WithdrawBySig

Only the protocol Keeper can call this function.
This function allows the user to withdraw from a garden by using signature based gas-less transaction (meta-tx).
1
function withdrawBySig(
2
uint256 _amountIn,
3
uint256 _minAmountOut,
4
uint256 _nonce,
5
uint256 _maxFee,
6
bool _withPenalty,
7
address _unwindStrategy,
8
uint256 _pricePerShare,
9
uint256 _strategyNAV,
10
uint256 _fee,
11
address _signer,
12
bytes memory signature
13
) external;
Copied!
Parameter
Description
uint256 _amountIn
Quantity of the garden tokens to withdraw.
uint256 _minAmountOut
Min quantity of reserve asset to receive.
uint256 _nonce
Current nonce to prevent replay attacks.
uint256 _maxFee
Max fee user is willing to pay keeper. Fee is substracted from the withdrawn amount. Fee is expressed in reserve asset.
bool _withPenalty
Whether or not this is an immediate withdrawal.
address _unwindStrategy
Strategy to unwind (if any)
uint256 _pricePerShare
Price per share of the garden calculated off-chain by Keeper.
uint256 _strategyNAV
NAV of the strategy to unwind
uint256 _fee
Actual fee keeper demands. Have to be less than _maxFee.
address _signer
The user to who signed the signature.
bytes memory _signature
Signature by the user to verify deposit params

ClaimRewardsBySig

Only the protocol Keeper can call this function.
This function allows the user to claim their rewards of a garden by using signature based gas-less transaction (meta-tx).
1
function claimRewardsBySig(
2
uint256 _babl,
3
uint256 _profits,
4
uint256 _nonce,
5
uint256 _maxFee,
6
uint256 _fee,
7
address _signer,
8
bytes memory _signature
9
) external;
Copied!
Parameter
Description
uint256 _babl
BABL rewards from mining program.
uint256 _profits
Profit rewards in reserve asset.
uint256 _nonce
Current nonce to prevent replay attacks.
uint256 _maxFee
Max fee user is willing to pay keeper. Fee is substracted from the user wallet approved amount. Fee is expressed in reserve asset.
uint256 _fee
Actual fee keeper demands. Have to be less than _maxFee.
address _signer
The user who signed the signature.
bytes memory _signature
Signature by the user to verify claim params.

ClaimAndStakeRewardsBySig

Only the protocol Keeper can call this function.
This function allows the user to claim their rewards of a garden and stake all BABL rewards into the Heart Garden by using signature based gas-less transaction (meta-tx).
1
function claimAndStakeRewardsBySig(
2
uint256 _babl,
3
uint256 _profits,
4
uint256 _minAmountOut,
5
uint256 _nonce,
6
uint256 _nonceHeart,
7
uint256 _maxFee,
8
uint256 _pricePerShare,
9
uint256 _fee,
10
address _signer,
11
bytes memory _signature
12
) external;
Copied!
Parameter
Description
uint256 _babl
BABL rewards from mining program.
uint256 _profits
Profit rewards in reserve asset.
uint256 _minAmountOut
Minimum hBABL as part of the Heart Garden BABL staking.
uint256 _nonce
Current nonce of user in the claiming garden at to prevent replay attacks.
uint256 _nonceHeart
Current nonce of user in Heart Garden to prevent replay attacks.
uint256 _maxFee
Max fee user is willing to pay keeper. Fee is substracted from the user wallet approved amount. Fee is expressed in reserve asset.
uint256 _fee
Actual fee keeper demands. Have to be less than _maxFee.
uint256 _pricePerShare
Price per share of Heart Garden.
address _signer
The user who signed the signature.
bytes memory _signature
Signature by the user to verify claim and stake params.

StakeBySig

Only a garden can call this function.
This function allows a garden to stake user BABL rewards on behalf of the user into the Heart Garden by using signature based gas-less transaction (meta-tx) as well as EIP-1271.​
1
function stakeBySig(
2
uint256 _amountIn,
3
uint256 _profits,
4
uint256 _minAmountOut,
5
uint256 _nonce,
6
uint256 _nonceHeart,
7
uint256 _maxFee,
8
address _to,
9
uint256 _pricePerShare,
10
address _signer,
11
bytes memory _signature
12
) external;
Copied!
Parameter
Description
uint256 _amountIn
Amount of BABL that is going to be staked by contributor
uint256 _profits
Profit rewards in reserve asset.
uint256 _minAmountOut
Minimum hBABL as part of the Heart Garden BABL staking.
uint256 _nonce
Current nonce of user in the claiming garden at to prevent replay attacks.
uint256 _nonceHeart
Current nonce in heart garden to prevent replay attacks.
uint256 _maxFee
Max fee user is willing to pay keeper. Fee is substracted from the user wallet approved amount. Fee is expressed in reserve asset.
address _to
Address to mint shares to.
uint256 _pricePerShare
Price per share of the garden calculated off-chain by Keeper.
address _signer
The garden who signed the stake operation using EIP-1271.
bytes memory _signature
Signature by the user to verify claim and stake params.

View Functions

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

PrivateGarden

Function to check if the garden is private (true) or public (false).
1
function privateGarden() external view returns (bool);
Copied!

PublicStrategist

Function to check if all garden members have strategist role (true means that all garden members have strategist role).
1
function publicStrategists() external view returns (bool);
Copied!

PublicStewards

Function to check if all garden members have voting privileges (true means all garden members can vote).
1
function publicStewards() external view returns (bool);
Copied!

Controller

Function to retrieve the controller smart-contract address.
1
function controller() external view returns (IBabController);
Copied!

Creator

Function to retrieve the garden original creator address.
1
function creator() external view returns (address);
Copied!

IsGardenStrategy

Function to check whether or not the strategy belongs to the garden (true or false).
1
function isGardenStrategy(address _strategy) external view returns (bool);
Copied!

GetContributor

Function to retrieve contributor information.
1
function getContributor(address _contributor)
2
external
3
view
4
returns (
5
uint256 lastDepositAt,
6
uint256 initialDepositAt,
7
uint256 claimedAt,
8
uint256 claimedBABL,
9
uint256 claimedRewards,
10
uint256 withdrawnSince,
11
uint256 totalDeposits,
12
uint256 nonce,
13
uint256 lockedBalance
14
);
Copied!
Parameter
Description
address _contributor
Garden member address
uint256 lastDepositAt
Timestamp of the last deposit
uint256 initialDepositAt
Timestamp of the initial deposit
uint256 claimedAt
Timestamp of the last claim
uint256 claimedBABL
Total amount of claimed BABL
uint256 claimedRewards
Total amount of claimed rewards
uint256 withdrawnSince
Total amount of withdrawals
uint256 totalDeposits
Total amount of deposits
uint256 nonce
Contributor nonce to avoid replay attacks
uint256 lockedBalance
Locked balance of the contributor

ReserveAsset

Function to get the address of the garden reserveAsset.
1
function reserveAsset() external view returns (address);
Copied!

VerifiedCategory

Function to get whether or not governance has verified the garden and the category.
1
function verifiedCategory() external view returns (uint256);
Copied!

HardlockStartsAt

Function to get the timestamp that overrides the depositLock with a global hard lock.
1
function hardlockStartsAt() external view returns (uint256);
Copied!

CanMintNftAfter

Function to get the delay required (in seconds) before a garden member can mint a garden NFT since its initial deposit.
1
function canMintNftAfter() external view returns (uint256);
Copied!

TotalContributors

Function to get the total number of contributors in the garden.
1
function totalContributors() external view returns (uint256);
Copied!

GardenInitializedAt

Function to get the timestamp of the garden creation.
1
function gardenInitializedAt() external view returns (uint256);
Copied!

MinContribution

Function to get the minimum contribution amount required by the garden.
1
function minContribution() external view returns (uint256);
Copied!

DepositHardlock

Function to get the minimum required delay (in seconds) between a deposit and a withdrawal (i.e. 1 second to avoid flashloans).
1
function depositHardlock() external view returns (uint256);
Copied!

MinLiquidityAsset

Function to get the minimum liquidity required for an asset to be tradable by this garden.
1
function minLiquidityAsset() external view returns (uint256);
Copied!

MinStrategyDuration

Function to get the minimum strategy duration (in seconds).
1
function minStrategyDuration() external view returns (uint256);
Copied!

MaxStrategyDuration

Function to get the maximum strategy duration (in seconds).
1
function maxStrategyDuration() external view returns (uint256);
Copied!

ReserveAssetRewardsSetAside

Function to get the number of profits denominated in the reserve asset that are set aside (reserved) for strategies and voters. LP profit rewards are auto-compounded.
1
function reserveAssetRewardsSetAside() external view returns (uint256);
Copied!

AbsoluteReturns

Function to get the garden absolute returns value.
1
function absoluteReturns() external view returns (int256);
Copied!

TotalStake

Function to get the total stake from strategists in all the strategies.
1
function totalStake() external view returns (uint256);
Copied!

MinVotesQuorum

Function to get the minimum quorum (1e18 = 100%) needed to approve and execute a strategy.
1
function minVotesQuorum() external view returns (uint256);
Copied!

MinVoters

Function to get the minimum voters to approve and execute a strategy.
1
function minVoters() external view returns (uint256);
Copied!

MaxDepositLimit

function to get the maximum deposit limit of a garden.
1
function maxDepositLimit() external view returns (uint256);
Copied!

StrategyCooldownPeriod

Function to get how long the strategy will wait in seconds to execute after being approved.
1
function strategyCooldownPeriod() external view returns (uint256);
Copied!

GetStrategies

Function to get an array of current strategies.
1
function getStrategies() external view returns (address[] memory);
Copied!

ExtraCreators

Function to get the address of an extra creator within the array of extraCreators. As param, it needs the index from 0 to 3 as there is a maximum of 4 extra creators.
1
function extraCreators(uint256 index) external view returns (address);
Copied!

GetFinalizedStrategies

Function to get an array of all finalized strategies.
1
function getFinalizedStrategies() external view returns (address[] memory);
Copied!

StrategyMapping

Function to check all active strategies in the garden.
1
function strategyMapping(address _strategy) external view returns (bool);
Copied!

KeeperDebt

Function to get current debt to be paid to the Keeper.
1
function keeperDebt() external view returns (uint256);
Copied!

TotalKeeperFees

Function to get the total fees paid to Keeper.
1
function totalKeeperFees() external view returns (uint256);
Copied!

LastPricePerShare

Function to get the last recorded price per share of the garden during deposit or withdrawal operation.
1
function lastPricePerShare() external view returns (uint256);
Copied!

LastPricePerShareTS

Function to get the last recorded time of the deposit or withdraw in seconds.
1
function lastPricePerShareTS() external view returns (uint256);
Copied!

PricePerShareDecayRate

Function to get the decay rate of the slippage for pricePerShare over time.
1
function pricePerShareDecayRate() external view returns (uint256);
Copied!

PricePerShareDelta

Function to get the base slippage for pricePerShare of the garden.
1
function pricePerShareDelta() external view returns (uint256);
Copied!

Name

Function to get the name of the garden token.
1
function name() external view returns (string memory);
Copied!