Skip to main content

ISablierBobAdapter

Git Source

Inherits: IComptrollerable, IERC165

Title: ISablierBobAdapter

Base interface for adapters used by the SablierBob protocol for generating yield.

Functions

MAX_FEE

Returns the maximum yield fee, denominated in UD60x18, where 1e18 = 100%.

This is a constant state variable.

function MAX_FEE() external view returns (UD60x18);

SABLIER_BOB

Returns the address of the SablierBob contract.

This is an immutable state variable.

function SABLIER_BOB() external view returns (address);

feeOnYield

Returns the current global fee on yield for new vaults, denominated in UD60x18, where 1e18 = 100%.

function feeOnYield() external view returns (UD60x18);

getTotalYieldBearingTokenBalance

Returns the total amount of yield-bearing tokens held in a vault.

function getTotalYieldBearingTokenBalance(uint256 vaultId) external view returns (uint128);

Parameters

NameTypeDescription
vaultIduint256The ID of the vault.

Returns

NameTypeDescription
<none>uint128The total amount of yield-bearing tokens in the vault.

getVaultYieldFee

Returns the yield fee stored for a specific vault.

function getVaultYieldFee(uint256 vaultId) external view returns (UD60x18);

Parameters

NameTypeDescription
vaultIduint256The ID of the vault.

Returns

NameTypeDescription
<none>UD60x18The yield fee for the vault denominated in UD60x18, where 1e18 = 100%.

getYieldBearingTokenBalanceFor

Returns the amount of yield-bearing tokens held for a specific user in a vault.

function getYieldBearingTokenBalanceFor(uint256 vaultId, address user) external view returns (uint128);

Parameters

NameTypeDescription
vaultIduint256The ID of the vault.
useraddressThe address of the user.

Returns

NameTypeDescription
<none>uint128The amount of yield-bearing tokens the user has claim to.

processRedemption

Processes a user's token redemption by calculating the transfer amount, clearing the user's yield-bearing token balance, and returning the amounts. Notes:

  • The user's yield-bearing token balance is decremented after calculating the transfer amount. This does not decrement the vault total as it is used in the calculation of the transfer amount for other users. Requirements:
  • The caller must be the SablierBob contract.
function processRedemption(
uint256 vaultId,
address user,
uint128 shareBalance
)
external
returns (uint128 transferAmount, uint128 feeAmountDeductedFromYield);

Parameters

NameTypeDescription
vaultIduint256The ID of the vault.
useraddressThe address of the user.
shareBalanceuint128The user's share balance in the vault.

Returns

NameTypeDescription
transferAmountuint128The amount to transfer to the user.
feeAmountDeductedFromYielduint128The fee amount taken from the yield.

registerVault

Register a new vault with the adapter and snapshot the current fee on yield. Requirements:

  • The caller must be the SablierBob contract.
function registerVault(uint256 vaultId) external;

Parameters

NameTypeDescription
vaultIduint256The ID of the newly created vault.

setYieldFee

Sets the fee on yield for future vaults.

Emits a SetYieldFee event. Notes:

  • This only affects future vaults, fee is not updated for existing vaults. Requirements:
  • The caller must be the comptroller.
  • newFee must not exceed MAX_FEE.
function setYieldFee(UD60x18 newFee) external;

Parameters

NameTypeDescription
newFeeUD60x18The new yield fee as UD60x18 where 1e18 = 100%.

stake

Stakes tokens deposited by a user in a vault, converting them to yield-bearing tokens.

Emits a Stake event. Requirements:

  • The caller must be the SablierBob contract.
  • The tokens must have been transferred to this contract.
function stake(uint256 vaultId, address user, uint256 amount) external;

Parameters

NameTypeDescription
vaultIduint256The ID of the vault.
useraddressThe address of the user depositing the tokens.
amountuint256The amount of tokens to stake.

unstakeFullAmount

Converts all yield-bearing tokens in a vault back to deposit tokens after settlement.

Emits an UnstakeFullAmount event. Notes:

  • This should only be called once per vault after settlement. Requirements:
  • The caller must be the SablierBob contract.
function unstakeFullAmount(uint256 vaultId)
external
returns (uint128 wrappedTokenBalance, uint128 amountReceivedFromUnstaking);

Parameters

NameTypeDescription
vaultIduint256The ID of the vault.

Returns

NameTypeDescription
wrappedTokenBalanceuint128The total amount of yield-bearing tokens that were in the vault.
amountReceivedFromUnstakinguint128The total amount of tokens received from unstaking the yield-bearing tokens.

updateStakedTokenBalance

Updates staked token balance of a user when vault shares are transferred. Requirements:

  • The caller must be the SablierBob contract.
  • userShareBalanceBeforeTransfer must not be zero.
  • The calculated wstETH transfer amount must not be zero.
function updateStakedTokenBalance(
uint256 vaultId,
address from,
address to,
uint256 shareAmountTransferred,
uint256 userShareBalanceBeforeTransfer
)
external;

Parameters

NameTypeDescription
vaultIduint256The ID of the vault.
fromaddressThe address transferring vault shares.
toaddressThe address receiving vault shares.
shareAmountTransferreduint256The number of vault shares being transferred.
userShareBalanceBeforeTransferuint256The sender's vault share balance before the transfer.

Events

SetYieldFee

Emitted when the comptroller sets a new yield fee.

event SetYieldFee(UD60x18 previousFee, UD60x18 newFee);

Stake

Emitted when tokens are staked for a user in a vault.

event Stake(uint256 indexed vaultId, address indexed user, uint256 depositAmount, uint256 wrappedStakedAmount);

TransferStakedTokens

Emitted when staked token attribution is transferred between users.

event TransferStakedTokens(uint256 indexed vaultId, address indexed from, address indexed to, uint256 amount);

UnstakeFullAmount

Emitted when all staked tokens in a vault are converted back to the deposit token.

event UnstakeFullAmount(uint256 indexed vaultId, uint128 totalStakedAmount, uint128 amountReceivedFromUnstaking);