Aloe Protocol
Search…
⌃K

AloeBlend.sol

https://github.com/aloelabs/aloe-blend/blob/master/contracts/AloeBlend.sol
The information provided by Aloe Labs, Inc. (“we,” “us” or “our”) on docs.aloe.capital (the “Site”) is for general informational purposes only. All information on the Site is provided in good faith, however we make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability or completeness of any information on the Site.
Under no circumstance shall we have any liability to you for any loss or damage of any kind incurred as a result of the use of the site or reliance on any information provided on the site. Your use of the site and your reliance on any information on the site is solely at your own risk.

Actions

Deposits tokens in proportion to the vault's current holdings. These tokens sit in the vault and are not used as liquidity until the next rebalance.

Arguments

  • amount0Max Max amount of TOKEN0 to deposit
  • amount1Max Max amount of TOKEN1 to deposit
  • amount0Min Ensure amount0 is greater than this, otherwise revert
  • amount1Min Ensure amount1 is greater than this, otherwise revert

Return Values

  • shares Number of shares minted
  • amount0 Amount of TOKEN0 deposited
  • amount1 Amount of TOKEN1 deposited
function deposit(
uint256 amount0Max,
uint256 amount1Max,
uint256 amount0Min,
uint256 amount1Min
)
external
returns (
uint256 shares,
uint256 amount0,
uint256 amount1
);
Withdraws tokens in proportion to the vault's current holdings.

Arguments

  • shares Shares that the caller would like to exchange for underlying tokens
  • amount0Min Revert if resulting amount0 is smaller than this
  • amount1Min Revert if resulting amount1 is smaller than this

Return Values

  • amount0 Amount of TOKEN0 sent to caller
  • amount1 Amount of TOKEN1 sent to caller
function withdraw(
uint256 shares,
uint256 amount0Min,
uint256 amount1Min
) external returns (uint256 amount0, uint256 amount1);
Rebalances the vault to maintain an inventory ratio between 49%:51% and 51%:49%.
Pro tip: rewardToken may be something other than TOKEN0 or TOKEN1, in which case the available maintenance budget is equal to the contract's balance. Note that this will revert unless both silos report that removal of rewardToken is allowed. For example, a Compound silo should block removal of its cTokens.

Arguments

  • rewardToken The ERC20 token in which the reward should be denominated. If rewardToken is the 0 address, no reward will be given. Otherwise, the reward is based on (a) time elapsed since primary position last moved, and (b) the contract's estimate of how much each unit of gas costs. Since (b) is fully determined by past contract interactions and is known to all participants, (a) creates a Dutch Auction for calling this function
function rebalance(address rewardToken) external;

Derived State

Calculates the rebalance urgency, which scales linearly with block.timestamp - packedSlot.recenterTimestamp.
Will be 0 immediately after the primary Uniswap position is recentered, and 100000 after 24 hours. As this value grows, so does the reward available to actors that call rebalance(rewardToken).

Return Values

  • urgency How badly the vault wants its rebalance(rewardToken) function to be called
function getRebalanceUrgency() external view returns (uint32 urgency);
Estimates the vault's liabilities to users -- in other words, how much would be paid out if all holders redeemed their shares at once.
Underestimates the true payout unless both silos and Uniswap positions have just been poked. Also assumes that the maximum amount will accrue to the maintenance budget during the next rebalance(rewardToken). If it takes less than that for the budget to reach capacity, then the values reported here may increase after calling rebalance(rewardToken).

Return Values

  • inventory0 The amount of TOKEN0 underlying all shares
  • inventory1 The amount of TOKEN1 underlying all shares
function getInventory() external view returns (uint256 inventory0, uint256 inventory1);

State

A variety of key parameters used frequently in the vault's code, stored in a single slot to save gas.
Pro tip: If lower and upper bounds of a Uniswap position are equal, then the vault hasn't deposited liquidity to it.

Return Values

  • primaryLower The primary position's lower tick bound
  • primaryUpper The primary position's upper tick bound
  • limitLower The limit order's lower tick bound
  • limitUpper The limit order's upper tick bound
  • recenterTimestamp The block.timestamp from the last time the primary position was moved
  • maxRebalanceGas The (approximate) maximum amount of gas that has ever been used to rebalance(rewardToken) this vault
  • maintenanceIsSustainable Whether maintenanceBudget0 or maintenanceBudget1 has filled up according to K
  • locked Whether the vault is currently locked to reentrancy
function packedSlot()
external
view
returns (
int24 primaryLower,
int24 primaryUpper,
int24 limitLower,
int24 limitUpper,
uint48 recenterTimestamp,
uint32 maxRebalanceGas,
bool maintenanceIsSustainable,
bool locked
);
The amount of TOKEN0 that was in silo0 last time maintenanceBudget0 was updated
function silo0Basis() external view returns (uint256);
The amount of TOKEN1 that was in silo1 last time maintenanceBudget1 was updated
function silo1Basis() external view returns (uint256);
The amount of TOKEN0 available for rebalance(TOKEN0) rewards
function maintenanceBudget0() external view returns (uint256);
The amount of TOKEN1 available for rebalance(TOKEN1) rewards
function maintenanceBudget1() external view returns (uint256);
The contract's opinion on the fair value of 1e4 units of gas, denominated in token.
The value reported here is an average over 14 samples. Nominally there is 1 sample per day, but actual timing isn't stored. Please do not use this as more than a low fidelity approximation/proxy for truth.

Arguments

  • token The ERC20 token for which the average gas price should be retrieved. Most likely populated for TOKEN0 and TOKEN1, but no guarantees. May also be populated for something like COMP if a Compound silo is being used.

Return Values

  • gasPrice The amount of token that may motivate expenditure of 1e4 units of gas
function gasPrices(address token) external view returns (uint256 gasPrice);

Immutables

Type
Name
Description
uint24
RECENTERING_INTERVAL
The nominal time (in seconds) that the primary Uniswap position should stay in one place before being recentered.
int24
MIN_WIDTH
The minimum width (in ticks) of the primary Uniswap position.
int24
MAX_WIDTH
The maximum width (in ticks) of the primary Uniswap position.
uint8
K
The maintenance budget buffer multiplier. The vault will attempt to build up a maintenance budget equal to the average cost of rebalance incentivization, multiplied by K.
uint8
L
If the maintenance budget drops below [its maximum size ➗ this value], maintenanceIsSustainable will become false. During the next rebalance, this will cause the primary Uniswap position to expand to its maximum width -- de-risking the vault until it has time to rebuild the maintenance budget.
uint8
B
The number of standard deviations (from volatilityOracle) to +/- from mean when choosing range for primary Uniswap position.
uint8
D
The constraint factor for new gas price observations. The new observation cannot be less than (1 - 1/D) times the previous average.
uint8
MAINTENANCE_FEE
The denominator applied to all earnings to determine what portion goes to maintenance budget. For example, if this is 10, then at most 1/10th of all revenue will be added to the maintenance budget.
uint256
FLOAT_PERCENTAGE
The percentage of funds (in basis points) that will be left in the contract after the primary Uniswap position is recentered. If your share of the pool is <<< than this, withdrawals will be more gas efficient. Also makes it less gassy to place limit orders.
IVolatilityOracle
volatilityOracle
The volatility oracle used to decide position width.
ISilo
silo0
The silo where excess TOKEN0 is stored to earn yield.
ISilo
silo1
The silo where excess TOKEN1 is stored to earn yield.