Custody What is Custody? In our project, we allow user to connect their Metamask wallet onto our platform, providing them a more secure environment for their assets. Users can then deposit funds onto the custody wallet. This deposit to the custody wallet will then open a state channel off-chain. By following nitro protocols on the state channel, we can then have instant finality to user balances after each transaction. This allows the user to have locked balances and make partial/full withdrawals from the custody wallet, back to the Metamask.
Smart Contracts IVault IVault is the interface to implement custody
Contents Functions getLastId
📋
Get last ledger id (deposits and withdrawals id).
Declaration function getLastId( ) external returns (uint256)
Returns: Type Description uint256
Ledger id.
Events Deposited
📋
Deposited event
Params: Param Type Indexed Description id
uint256 ✅ Ledger id account
address ✅ Account address asset
address ✅ Asset address to deposit amount
uint256 Quantity of assets to be deposited
Withdrawn
📋
Withdrawn event
Params: Param Type Indexed Description id
uint256 ✅ Ledger id account
address ✅ Account address asset
address ✅ Asset address to deposit amount
uint256 Quantity of assets to be deposited
SimpleVault Custody smart contracts aim to provide a secure trading environment by holding the assets on the erc20 chain so that the user and broker can freely trade off-chain.
Contents Globals Var Type Description BROKER_ROLE bytes32 Broker role identifier value WITHDRAW_TYPE bytes32 Withdrawal type identifier value
Modifiers onlyValidMovingFundParams
📋
Modifier to check information required for deposits and withdrawals.
Declaration modifier onlyValidMovingFundParams( address account )
Args: Arg Type Description account
address Account address to check
Functions initialize
📋
The constructor function sets the contract name and broker's address.
Declaration function initialize( string name_, address broker_ ) public initializer
Modifiers: Args: Arg Type Description name_
string Contract name broker_
address Broker name
name
📋
Get contract name.
Declaration function name( ) public returns (string)
Returns: Type Description string
Contract name
changeBroker
📋
Change broker address who signed the withdrawal signature.
Declaration function changeBroker( address newBroker ) external onlyRole
Modifiers: Args: Arg Type Description newBroker
address Broker address
getLastId
📋
Get last ledger id (deposits and withdrawals id).
Declaration function getLastId( ) external returns (uint256)
Returns: Type Description uint256
Ledger id.
deposit
📋
Deposit the asset with given amount into custody
Declaration function deposit( address asset, uint256 amount ) public returns (bool)
Args: Arg Type Description asset
address Asset address to deposit amount
uint256 Quantity of assets to be deposited
Returns: Type Description bool
Return 'true' when deposited
_deposit
📋
Internal deposit process and increment ledger id
Declaration function _deposit( address account, address asset, uint256 amount ) internal onlyValidMovingFundParams returns (bool)
Modifiers: Modifier onlyValidMovingFundParams
Args: Arg Type Description account
address Account address asset
address Asset address to deposit amount
uint256 Quantity of assets to be deposited
Returns: Type Description bool
Return 'true' when deposited
withdraw
📋
Withdraw the asset with given payload to the caller
Declaration function withdraw( bytes payload, bytes signature ) public returns (bool)
Args: Arg Type Description payload
bytes Withdrawal payload consists of rid (unique identifier id), deadline, destination, and the list of withdrawal asset and amount signature
bytes Broker signature
Returns: Type Description bool
Return 'true' when withdrawn
_withdraw
📋
Internal withdraw process and increment ledger id
Declaration function _withdraw( address account, bytes payload, bytes signature ) internal onlyValidMovingFundParams returns (bool)
Modifiers: Modifier onlyValidMovingFundParams
Args: Arg Type Description account
address Account address payload
bytes Withdrawal payload consists of rid (unique identifier id), deadline, destination, and the list of withdrawal asset and amount signature
bytes Broker signature
Returns: Type Description bool
Return 'true' when withdrawn
_transferAssetFrom
📋
Transfers the given amount of this AssetHolders's asset type from a supplied ethereum address.
Declaration function _transferAssetFrom( address asset, address from, uint256 amount ) internal
Args: Arg Type Description asset
address Asset address to transfer from
address Ethereum address to be credited amount
uint256 Quantity of assets to be transferred
_transferAssetTo
📋
Transfers the given amount of this AssetHolders's asset type to a supplied ethereum address.
Declaration function _transferAssetTo( address asset, address destination, uint256 amount ) internal
Args: Arg Type Description asset
address Asset address to transfer destination
address Ethereum address to be credited amount
uint256 Quantity of assets to be transferred