SyncSynthVault

Solidity version

0.8.21

Inheritance


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;

vaultIsOpen

bool public vaultIsOpen; // vault is open or closed

lastSavedBalance

uint256 public lastSavedBalance; // last saved balance

Events

EpochStart

event EpochStart(
    uint256 indexed timestamp,
    uint256 lastSavedBalance,
    uint256 totalShares
)

Emitted when an epoch starts.

EpochEnd

event EpochEnd(
    uint256 indexed timestamp,
    uint256 lastSavedBalance,
    uint256 returnedAssets,
    uint256 fees,
    uint256 totalShares
)

Emitted when an epoch ends.

FeesChanged

event FeesChanged(uint16 oldFees, uint16 newFees)

Emitted when fees are changed.


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.

ERC4626ExceededMaxMint

error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max)

Attempt to mint more shares (LP tokens) than the maximum allowed amount for receiver.

ERC4626ExceededMaxWithdraw

error ERC4626ExceededMaxWithdraw(
    address owner,
    uint256 assets,
    uint256 max
)

Attempt to withdraw more underlying assets than the maximum allowed amount for receiver.

ERC4626ExceededMaxRedeem

 error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max)

Attempt to redeem more shares(LP tokens) than the maximum allowed amount for receiver.


Functions

asset

function asset() public view returns (address)

The asset function is used to return the 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.

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.

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.

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).

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.

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.

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.

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.

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.

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).

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.

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).

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).

deposit

function deposit(uint256 assets, address receiver) public returns (uint256)

The deposit function is used to deposit underlying assets into the vault.

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.

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.

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).

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.

Last updated