SyncSynthVault
Solidity version
0.8.21
Inheritance
Ownable2StepUpgradeable
of OpenZeppelin.ERC20PermitUpgradeable
of OpenZeppelin.ERC20PausableUpgradeable
of OpenZeppelin.IERC4626
of OpenZeppelin.
Global Variables
PermitParams
struct PermitParams {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
BPS_DIVIDER
uint256 constant BPS_DIVIDER = 10_000;
MAX_FEES
uint16 constant MAX_FEES = 3000; // 30%
State Variables
feesInBps
uint16 public feesInBps;
uint16
public
Performance fees are applied on the absolute returns of the underlying strategy.
vaultIsOpen
bool public vaultIsOpen; // vault is open or closed
bool
public
The locking status of the vault.
lastSavedBalance
uint256 public lastSavedBalance; // last saved balance
uint16
public
Performance fees are applied on the absolute returns of the underlying strategy.
Events
EpochStart
event EpochStart(
uint256 indexed timestamp,
uint256 lastSavedBalance,
uint256 totalShares
)
Emitted when an epoch starts.
timestamp
uint256 indexed
The block timestamp of the epoch starts.
lastSavedBalance
uint256
The lastSavedBalance
when the vault starts.
totalShares
uint256
The total number of shares when the vault starts.
EpochEnd
event EpochEnd(
uint256 indexed timestamp,
uint256 lastSavedBalance,
uint256 returnedAssets,
uint256 fees,
uint256 totalShares
)
Emitted when an epoch ends.
timestamp
uint256 indexed
The block timestamp of the epoch terminates.
lastSavedBalance
uint256
The lastSavedBalance
from the current epoch starts.
returnedAssets
uint256
The total amount of underlying assets returned to the vault before collecting fees.
fees
uint256
The amount of fees collected.
totalShares
uint256
The total amount of shares when the vault terminates.
FeesChanged
event FeesChanged(uint16 oldFees, uint16 newFees)
Emitted when fees are changed.
oldFees
uint16
The previous performance fees (in bps).
newFees
uint16
The newly applied performance fees (in bps).
returnedAssets
uint256
The total amount of underlying assets returned to the vault before collecting fees.
Errors
VaultIsClosed
error VaultIsClosed();
The vault is in a locked state. Emitted if the transaction cannot happen in this state.
VaultIsOpen
error VaultIsOpen()
The vault is in an open state. Emitted if the transaction cannot happen in this state.
CannotClaimAsset
error CannotClaimAsset()
Claiming the underlying assets is not allowed.
ERC4626ExceededMaxDeposit
error ERC4626ExceededMaxDeposit(
address receiver,
uint256 assets,
uint256 max
)
Attempt to deposit more underlying assets than the maximum allowed amount for receiver
.
receiver
address
The address
of the receiver
.
assets
uint256
The amount of underlying assets asked for deposit.
max
uint256
Number of shares (LP tokens) received in exchange for the specified amount of underlying assets.
ERC4626ExceededMaxMint
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max)
Attempt to mint more shares (LP tokens) than the maximum allowed amount for receiver
.
owner
address
The address
of the owner
.
shares
uint256
The amount of underlying assets asked to mint shares (LP tokens).
max
uint256
The maximum number of withdrawable shares (LP tokens).
ERC4626ExceededMaxWithdraw
error ERC4626ExceededMaxWithdraw(
address owner,
uint256 assets,
uint256 max
)
Attempt to withdraw more underlying assets than the maximum allowed amount for receiver
.
owner
address
The address
of the owner
.
assets
uint256
The number of underlying assets asked for withdrawal.
max
uint256
The maximum amount of withdrawable underlying assets.
ERC4626ExceededMaxRedeem
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max)
Attempt to redeem more shares(LP tokens) than the maximum allowed amount for receiver
.
owner
address
The address
of the owner
.
shares
uint256
The number of shares (LP tokens) asked to be redeemed.
max
uint256
The maximum number of redeemable shares (LP tokens).
Functions
asset
function asset() public view returns (address)
The asset
function is used to return the address
of the underlying asset.
address
address
of the underlying asset.
decimals
function decimals() public view override(ERC20, IERC20Metadata) returns (uint8)
See {IERC20-decimals}
. The _decimalShares
is equal to underlying asset decimals + decimalsOffset
. See Constructor for more details about this.
uint8
Amount of decimals of the share (LP) token.
totalAssets
function totalAssets() public view returns (uint256)
The totalAssets
function is used to calculate the theoretical total underlying assets owned by the vault. If the vault is locked, the last saved balance is added to the current balance.
uint256
Amount of the total underlying assets in the vault.
convertToShares
function convertToShares(uint256 assets) public view returns (uint256)
See {IERC4626-convertToShares}.
The convertToShares
function is used to calculate the number of shares (LP tokens) received in exchange for the specified amount of underlying assets.
assets
uint256
The amount of underlying assets to be converted into shares .
convertToAssets
function convertToAssets(uint256 shares) public view returns (uint256)
See {IERC4626-convertToAssets}.
The convertToAssets
function is used to calculate the amount of underlying assets received in exchange for the specified number of shares (LP tokens).
shares
uint256
The number of shares (LP tokens) to be converted into underlying assets.
maxDeposit
function maxMint(address) public view returns (uint256)
The maxDeposit
function is used to calculate the maximum deposit.
If the vault is locked or paused, users are not allowed to mint, the maxMint
is 0
.
_
address
The address
of the shares (LP tokens) receiver
.
maxMint
function maxMint(address) public view returns (uint256)
The maxMint
function is used to calculate the maximum number of shares (LP tokens) you can mint. If the vault is locked or paused, the maxMint
is 0
.
_
address
The address
of the receiver
.
maxWithdraw
function maxWithdraw(address owner) public view returns (uint256)
The maxWithdraw
function is used to calculate the maximum amount of withdrawable underlying assets. If the function is called during the lock period the maxWithdraw
is 0
.
owner
address
The address
of the owner
.
maxRedeem
function maxRedeem(address owner) public view returns (uint256)
The maxRedemm
function is used to calculate the maximum number of redeemable shares (LP tokens). If the function is called during the lock period, the maxRedeem
is 0
.
owner
address
The address
of the owner
.
previewDeposit
function previewDeposit(uint256 assets) public view returns (uint256)
The previewDeposit
function is used to calculate the number of shares (LP tokens) received in exchange for the specified underlying asset.
assets
uint256
The amount of underlying assets to be converted into shares (LP tokens).
previewMint
function previewMint(uint256 shares) public view returns (uint256)
The previewMint
function is used to calculate the amount of underlying assets received in exchange for the specified number of shares (LP tokens).
shares
uint256
The number of shares (LP tokens) to be converted into underlying assets.
previewWithdraw
function previewWithdraw(uint256 assets) public view returns (uint256)
The previewWithdraw
function is used to calculate the number of shares (LP tokens) received in exchange for the specified underlying asset.
assets
uint256
The amount of underlying assets to be converted into shares (LP tokens).
previewRedeem
function previewRedeem(uint256 shares) public view returns (uint256)
The previewRedeem
function is used to calculate the amount of underlying assets received in exchange for the specified number of shares (LP token).
shares
uint256
The number of shares (LP tokens) to be converted into underlying assets.
sharesBalanceInAsset
function sharesBalanceInAsset(address owner) public view returns (uint256)
Given the address of an owner, returns the amount of shares of an user, converted in assets.
The previewRedeem
function is used to calculate the amount of underlying assets received in exchange for the specified number of shares (LP token).
owner
address
The owner address
.
deposit
function deposit(uint256 assets, address receiver) public returns (uint256)
The deposit
function is used to deposit underlying assets into the vault.
assets
uint256
The amount of underlying assets to be converted into shares (LP tokens).
receiver
address
The address
of the shares (LP tokens) receiver
.
depositWithPermit
function depositWithPermit(
uint256 assets,
address receiver,
PermitParams calldata permitParams
) external returns (uint256)
The depositWithPermit
function is used to deposit underlying assets into the vault by using permit feature if the underlying asset support it.
assets
uint256
The amount of underlying assets to be converted into shares (LP tokens).
receiver
address
The address
of the shares (LP tokens) receiver
.
permitParams
PermitParams
Permit functionality parameters.
depositWithPermit
mint
function mint(uint256 shares, address receiver) public returns (uint256)
The mint
function is used to mint the specified number of shares (LP tokens) in exchange for the corresponding amount of underlying assets from owner
.
shares
uint256
The number of shares (LP tokens) to be converted into underlying assets.
receiver
address
The address
of the shares (LP tokens) receiver
.
withdraw
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256)
The withdraw
function is used to withdraw the specified amount of underlying assets in exchange for a proportional number of shares (LP tokens).
assets
uint256
The amount of underlying assets to be withdrawn.
receiver
address
The address
of the shares (LP tokens) receiver
.
owner
address
The address
of the owner
.
redeem
function redeem(uint256 shares, address receiver, address owner) external returns (uint256)
The redeem
function is used to redeem the specified number of shares (LP tokens) in exchange for the corresponding amount of underlying assets from owner
.
shares
uint256
The amount of shares to be redeemed.
receiver
address
The address
of the shares (LP tokens) receiver
.
owner
address
The address
of the owner
.
Last updated