Skip to main content

FulfillmentVault

Git Source

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

NameTypeDescription
$FulfillmentVaultStorageThe 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

NameTypeDescription
namestringThe name of the fulfillment vault
symbolstringThe symbol of the fulfillment vault
_decimalsuint8The decimals of the fulfillment vault
_decimalsOffsetuint8The decimals offset for measuring internal precision of shares
_wrappedNativeTokenaddressThe address of the wrapped native token
_generalManageraddressThe address of the general manager

__FulfillmentVault_init_unchained

Initializes the FulfillmentVault contract only

function __FulfillmentVault_init_unchained(address _wrappedNativeToken, address _generalManager)
internal
onlyInitializing;

Parameters

NameTypeDescription
_wrappedNativeTokenaddressThe address of the wrapped native token
_generalManageraddressThe 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

NameTypeDescription
namestringThe name of the fulfillment vault
symbolstringThe symbol of the fulfillment vault
_decimalsuint8The decimals of the fulfillment vault
_decimalsOffsetuint8The decimals offset for measuring internal precision of shares
_wrappedNativeTokenaddressThe address of the wrapped native token
_generalManageraddressThe address of the general manager
adminaddressThe 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

NameTypeDescription
<none>uint256The total assets of the vault

wrappedNativeToken

Gets the address of the wrapped native token

function wrappedNativeToken() public view override returns (address);

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
<none>addressThe address of the general manager

orderPool

Gets the address of the order pool

function orderPool() public view override returns (address);

Returns

NameTypeDescription
<none>addressThe address of the order pool

usdx

Gets the address of the USDX token

function usdx() public view override returns (address);

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
<none>uint128The 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

NameTypeDescription
assetaddressThe 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

NameTypeDescription
assetIndexuint64The index of the asset to bridge
amountuint256The 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

NameTypeDescription
amountuint256The amount of USDX to burn

withdrawUsdTokenFromUsdx

Withdraws usdToken from usdx

function withdrawUsdTokenFromUsdx(address usdToken, uint256 amount)
external
override
onlyRole(KEEPER_ROLE)
whenPaused;

Parameters

NameTypeDescription
usdTokenaddressThe address of the usdToken to withdraw
amountuint256The amount of usdToken to withdraw

depositUsdTokenToUsdx

Deposits usdToken into usdx

function depositUsdTokenToUsdx(address usdToken, uint256 amount) external override onlyRole(KEEPER_ROLE) whenPaused;

Parameters

NameTypeDescription
usdTokenaddressThe address of the usdToken to deposit
amountuint256The 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

NameTypeDescription
assetaddressThe address of the asset to bridge
amountuint256The 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

NameTypeDescription
spotIduint32The spotId of the asset to trade (identifies the trading pair)
isBuyboolWhether to buy or sell
limitPxuint64The limit price. Note, This is is (weiUnits - szUnits). For USDT and USDH, weiUnits is 1e6.
szuint64The 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

NameTypeDescription
indexuint256The index of the order to fill
hintPrevIdsuint256[]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

NameTypeDescription
_wrappedNativeTokenaddressThe address of the wrapped native token
_generalManageraddressThe address of the general manager
_usdxaddressThe address of the USDX token
_nonceuint128The ongoing nonce that generates distinct cloid values for exchanges on core