CrystalVaultFactory

Autogenerated from Solidity sources.

Functions

weth

function weth() external view returns (address)

Returns protocol configuration data or system constants without modifying on-chain state.

Return Values

Name
Type
Description

weth

address

Contract or wallet address


eth

function eth() external view returns (address)

Returns protocol configuration data or system constants without modifying on-chain state.

Return Values

Name
Type
Description

eth

address

Contract or wallet address


gov

function gov() external view returns (address)

Returns the governance/controller address for this factory

Return Values

Name
Type
Description

address

Contract or wallet address


crystal

function crystal() external view returns (address)

Returns the address of the main Crystal contract this factory is paired with.

Return Values

Name
Type
Description

address

Contract or wallet address


allVaults

function allVaults(uint256) external view returns (address)

Returns the vault address at a given index in the factory’s list.

Parameters

Name
Type
Description

uint256

Numeric value

Return Values

Name
Type
Description

address

Contract or wallet address


allVaultsLength

function allVaultsLength() external view returns (uint256)

Returns the amount of vaults the facotry is tracking

Return Values

Name
Type
Description

uint256

Unsigned integer value


getVault

function getVault(address vault) external view returns (address quoteAsset, address baseAsset, address owner, uint256 totalShares, uint256 maxShares, uint40 lockup, bool decreaseOnWithdraw, bool locked, bool closed, ICrystalVault.VaultMetaData metadata)

Returns a full snapshot of a vault’s configuration and status: assets, owner, share counts, lockup, the “decrease on withdraw” flag, locked/closed flags, and the vault’s metadata.

Parameters

Name
Type
Description

vault

address

Vault contract address

Return Values

Name
Type
Description

quoteAsset

address

Quote token address

baseAsset

address

Base token address

owner

address

Vault owner address

totalShares

uint256

Total shares in vault

maxShares

uint256

Maximum allowed shares

lockup

uint40

Lockup period in seconds

decreaseOnWithdraw

bool

Whether to decrease position on withdrawal

locked

bool

Whether vault is locked

closed

bool

Whether vault is closed

metadata

ICrystalVault.VaultMetaData

Vault metadata


minSize

function minSize(address token) external view returns (uint256)

Returns the minimum valid trade size for a given token.

Parameters

Name
Type
Description

token

address

Token contract address

Return Values

Name
Type
Description

uint256

Unsigned integer value


defaultQuoteMin

function defaultQuoteMin() external view returns (uint256)

Returns the default minimum amount for the quote asset.

Return Values

Name
Type
Description

uint256

Unsigned integer value


defaultBaseMin

function defaultBaseMin() external view returns (uint256)

Returns the default minimum amount for the base asset

Return Values

Name
Type
Description

uint256

Unsigned integer value


maxOrderCap

function maxOrderCap() external view returns (uint16)

Returns a factory-level cap for a single order/operation, expressed as a uint16 (exact interpretation depends on the vault implementation).

Return Values

Name
Type
Description

uint16

Numeric result


maxLockup

function maxLockup() external view returns (uint40)

Returns the maximum lockup duration the factory allows for any vault.

Return Values

Name
Type
Description

uint40

Numeric result


previewDeposit

function previewDeposit(address vault, uint256 amountQuoteDesired, uint256 amountBaseDesired) external view returns (uint256 shares, uint256 amountQuote, uint256 amountBase)

Estimates how many shares would be minted and how much of each asset would actually be used if you deposited with those desired amounts, without changing state.

Parameters

Name
Type
Description

vault

address

Vault contract address

amountQuoteDesired

uint256

Desired quote token amount

amountBaseDesired

uint256

Desired base token amount

Return Values

Name
Type
Description

shares

uint256

Number of vault shares

amountQuote

uint256

Quote token amount

amountBase

uint256

Base token amount


previewWithdrawal

function previewWithdrawal(address vault, uint256 shares) external view returns (uint256 amountQuote, uint256 amountBase)

Estimates how many quote/base tokens you would receive for redeeming that number of shares, without changing state.

Parameters

Name
Type
Description

vault

address

Vault contract address

shares

uint256

Number of vault shares

Return Values

Name
Type
Description

amountQuote

uint256

Quote token amount

amountBase

uint256

Base token amount


balanceOf

function balanceOf(address vault, address user) external view returns (uint256 shares, uint256 amountQuote, uint256 amountBase)

Returns a user’s share balance in the vault, plus the user’s corresponding underlying quote/base amounts attributable to those shares.

Parameters

Name
Type
Description

vault

address

Vault contract address

user

address

User wallet address

Return Values

Name
Type
Description

shares

uint256

Number of vault shares

amountQuote

uint256

Quote token amount

amountBase

uint256

Base token amount


Events

VaultDeployed

event VaultDeployed(indexed address vault, address quoteAsset, address baseAsset, address owner, uint256 maxShares, uint256 lockup, bool decreaseOnWithdraw, ICrystalVault.VaultMetaData metadata);

Emitted when a new vault contract is deployed and initialized with configuration parameters.

Parameters

Name
Type
Description

vault

indexed address

Vault address

quoteAsset

address

Quote token address

baseAsset

address

Base token address

owner

address

Vault owner address

maxShares

uint256

Maximum allowed shares

lockup

uint256

Lockup period in seconds

decreaseOnWithdraw

bool

Whether to decrease position on withdrawal

metadata

ICrystalVault.VaultMetaData

Vault metadata


Deposit

event Deposit(indexed address vault, indexed address sender, uint256 shares, uint256 quoteAmount, uint256 baseAmount);

Emitted when a user deposited into a vault; shows who, how many shares were minted, and the quote/base amounts contributed.

Parameters

Name
Type
Description

vault

indexed address

Vault address

sender

indexed address

Address initiating the action

shares

uint256

Number of vault shares

quoteAmount

uint256

Numeric value

baseAmount

uint256

Numeric value


Withdraw

event Withdraw(indexed address vault, indexed address sender, uint256 shares, uint256 quoteAmount, uint256 baseAmount);

Emitted when a user redeemed shares; shows who, how many shares were burned, and the quote/base amounts returned.

Parameters

Name
Type
Description

vault

indexed address

Vault address

sender

indexed address

Address initiating the action

shares

uint256

Number of vault shares

quoteAmount

uint256

Numeric value

baseAmount

uint256

Numeric value


MaxSharesChanged

event MaxSharesChanged(indexed address vault, uint256 maxShares);

Vault’s maximum share limit was updated.

Parameters

Name
Type
Description

vault

indexed address

Vault address

maxShares

uint256

Maximum allowed shares


LockupChanged

event LockupChanged(indexed address vault, uint256 lockup);

The vault’s lockup duration setting was updated.

Parameters

Name
Type
Description

vault

indexed address

Vault address

lockup

uint256

Lockup period in seconds


DecreaseOnWithdrawChanged

event DecreaseOnWithdrawChanged(indexed address vault, bool newDecrease);

Emitted when vault toggled or updated its “decrease on withdraw” setting.

Parameters

Name
Type
Description

vault

indexed address

Vault address

newDecrease

bool

New decrease on withdraw setting


Locked

event Locked(indexed address vault);

Emitted when a vault’s lock state changes: locked.

Parameters

Name
Type
Description

vault

indexed address

Vault address


Unlocked

event Unlocked(indexed address vault);

Emitted when a vault’s lock state changes: unlocked.

Parameters

Name
Type
Description

vault

indexed address

Vault address


Closed

event Closed(indexed address vault);

Emitted when a vault is permanently closed to all actions.

Parameters

Name
Type
Description

vault

indexed address

Vault address


Structs

Vault

struct Vault {
    address quoteAsset;
    address baseAsset;
    address owner;
    uint256 totalShares;
    uint256 maxShares;
    uint40 lockup;
    bool decreaseOnWithdraw;
    bool locked;
    bool closed;
    ICrystalVault.VaultMetaData metadata;
}

Describes one vault’s setup and status: which two assets it holds, who owns it, total and maximum shares, any lockup period, whether a “decrease on withdraw” rule is enabled, current lock/close flags, and human-readable metadata supplied by the vault (VaultMetaData).

Parameters

Name
Type
Description

quoteAsset

address

Quote token address

baseAsset

address

Base token address

owner

address

Vault owner address

totalShares

uint256

Total shares in vault

maxShares

uint256

Maximum allowed shares

lockup

uint40

Lockup period in seconds

decreaseOnWithdraw

bool

Whether to decrease position on withdrawal

locked

bool

Whether vault is locked

closed

bool

Whether vault is closed

metadata

ICrystalVault.VaultMetaData

Vault metadata

Last updated