FulfillmentVault
Inherits: LiquidityVault, IFulfillmentVault
Title: FulfillmentVault
Author: @SocksNFlops
The FulfillmentVault contract used to fulfill orders on the protocol
State Variables
FulfillmentVaultStorageLocation
The storage location of the FulfillmentVault contract
keccak256(abi.encode(uint256(keccak256("buttonwood.storage.FulfillmentVault")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant FulfillmentVaultStorageLocation =
0x4b57f16710661390ada38fe64129442a589f51d339ba23973c82ad806b168200
Functions
receive
Allow the contract to receive network native tokens (HYPE bridged from Core)
receive() external payable;
_getFulfillmentVaultStorage
Gets the storage location of the FulfillmentVault contract
function _getFulfillmentVaultStorage() private pure returns (FulfillmentVaultStorage storage $);
Returns
| Name | Type | Description |
|---|---|---|
$ | FulfillmentVaultStorage | The storage location of the FulfillmentVault contract |
__FulfillmentVault_init
Initializes the FulfillmentVault contract and calls parent initializers
function __FulfillmentVault_init(
string memory name,
string memory symbol,
uint8 _decimals,
uint8 _decimalsOffset,
address _wrappedNativeToken,
address _generalManager
) internal onlyInitializing;
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the fulfillment vault |
symbol | string | The symbol of the fulfillment vault |
_decimals | uint8 | The decimals of the fulfillment vault |
_decimalsOffset | uint8 | The decimals offset for measuring internal precision of shares |
_wrappedNativeToken | address | The address of the wrapped native token |
_generalManager | address | The address of the general manager |
__FulfillmentVault_init_unchained
Initializes the FulfillmentVault contract only
function __FulfillmentVault_init_unchained(address _wrappedNativeToken, address _generalManager)
internal
onlyInitializing;
Parameters
| Name | Type | Description |
|---|---|---|
_wrappedNativeToken | address | The address of the wrapped native token |
_generalManager | address | The address of the general manager |
initialize
Initializes the FulfillmentVault contract
function initialize(
string memory name,
string memory symbol,
uint8 _decimals,
uint8 _decimalsOffset,
address _wrappedNativeToken,
address _generalManager,
address admin
) external initializer;
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the fulfillment vault |
symbol | string | The symbol of the fulfillment vault |
_decimals | uint8 | The decimals of the fulfillment vault |
_decimalsOffset | uint8 | The decimals offset for measuring internal precision of shares |
_wrappedNativeToken | address | The address of the wrapped native token |
_generalManager | address | The address of the general manager |
admin | address | The address of the admin for the fulfillment vault |
supportsInterface
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
function supportsInterface(bytes4 interfaceId) public view override(LiquidityVault) returns (bool);
_totalAssets
Both depositable and redeemable assets are the same asset, so we override totalAssets to return the balance of only the redeemable asset.
function _totalAssets() internal view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total assets of the vault |
wrappedNativeToken
Gets the address of the wrapped native token
function wrappedNativeToken() public view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the wrapped native token (i.e., whype: 0x555...) |
generalManager
Gets the address of the general manager
function generalManager() public view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the general manager |
orderPool
Gets the address of the order pool
function orderPool() public view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the order pool |
usdx
Gets the address of the USDX token
function usdx() public view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the USDX token |
nonce
Gets the ongoing nonce that generates distinct cloid values for exchanges on core
function nonce() public view override returns (uint128);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint128 | The ongoing nonce |
approveAssetToOrderPool
Approves an asset to the order pool
Does not need a keeper role or paused-state
function approveAssetToOrderPool(address asset) external;
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The address of the asset to approve |
wrapHype
Wraps entire hype balance of the fulfillment vault into whype
Does not need a keeper role or paused-state
function wrapHype() external;
unwrapHype
Unwraps entire whype balance of the fulfillment vault into hype
Does not need a keeper role or paused-state
function unwrapHype() external;
bridgeAssetFromCoreToEvm
Bridges an asset from core to evm
function bridgeAssetFromCoreToEvm(uint64 assetIndex, uint256 amount)
external
override
onlyRole(KEEPER_ROLE)
whenPaused;
Parameters
| Name | Type | Description |
|---|---|---|
assetIndex | uint64 | The index of the asset to bridge |
amount | uint256 | The amount of asset to bridge (in evm units) |
burnUsdx
Burns USDX into usdTokens for the purpose of transferring them to core
function burnUsdx(uint256 amount) external override onlyRole(KEEPER_ROLE) whenPaused;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of USDX to burn |
withdrawUsdTokenFromUsdx
Withdraws usdToken from usdx
function withdrawUsdTokenFromUsdx(address usdToken, uint256 amount)
external
override
onlyRole(KEEPER_ROLE)
whenPaused;
Parameters
| Name | Type | Description |
|---|---|---|
usdToken | address | The address of the usdToken to withdraw |
amount | uint256 | The amount of usdToken to withdraw |
depositUsdTokenToUsdx
Deposits usdToken into usdx
function depositUsdTokenToUsdx(address usdToken, uint256 amount) external override onlyRole(KEEPER_ROLE) whenPaused;
Parameters
| Name | Type | Description |
|---|---|---|
usdToken | address | The address of the usdToken to deposit |
amount | uint256 | The amount of usdToken to deposit |
bridgeAssetFromEvmToCore
Bridges assets from evm to core
function bridgeAssetFromEvmToCore(address asset, uint256 amount) external override onlyRole(KEEPER_ROLE) whenPaused;
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The address of the asset to bridge |
amount | uint256 | The amount of asset to bridge |
tradeOnCore
Trades tokens on core
function tradeOnCore(uint32 spotId, bool isBuy, uint64 limitPx, uint64 sz)
external
override
onlyRole(KEEPER_ROLE)
whenPaused;
Parameters
| Name | Type | Description |
|---|---|---|
spotId | uint32 | The spotId of the asset to trade (identifies the trading pair) |
isBuy | bool | Whether to buy or sell |
limitPx | uint64 | The limit price. Note, This is is (weiUnits - szUnits). For USDT and USDH, weiUnits is 1e6. |
sz | uint64 | The size of the trade. Note, this is in szUnits. For USDT and USDH, szUnits is 1e2. |
fillOrder
Fills an order from the order pool
function fillOrder(uint256 index, uint256[] memory hintPrevIds) external override onlyRole(KEEPER_ROLE) whenPaused;
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index of the order to fill |
hintPrevIds | uint256[] | The hint prev ids for the relevant mortgage queues. |
Structs
FulfillmentVaultStorage
The storage for the FulfillmentVault contract
Note: storage-location: erc7201:buttonwood.storage.FulfillmentVault
struct FulfillmentVaultStorage {
address _wrappedNativeToken;
address _generalManager;
address _usdx;
uint128 _nonce;
}
Properties
| Name | Type | Description |
|---|---|---|
_wrappedNativeToken | address | The address of the wrapped native token |
_generalManager | address | The address of the general manager |
_usdx | address | The address of the USDX token |
_nonce | uint128 | The ongoing nonce that generates distinct cloid values for exchanges on core |