OpenDAX v4 docs

Brokerage Smart Contracts

Brokerage custody contract

Every OpenDAX v4 brokerage functioning relies upon a custody smart contract that serves as an exchange vault. It locks users' funds when they deposit to the exchange and unlocks them to users' blockchain addresses at withdrawals. Along with the vault contract, OpenDAX v4 is powered by dedicated smart contracts that implement all needed operations.

VaultProxy smart contract

Each OpenDAX v4 instance has a VaultProxy contract created on deployment.
This smart contract provides funds custody by storing hashed withdraw/deposit requests so that they can not be used again (e.g. to prevent double withdrawal).
It also serves as a proxy: navigates requests to the globally defined VaultImpl contract.

VaultImpl smart contract

VaultImpl (Vault Implementation) provides all needed operational logic for VaultProxy. It's a common contract for all OpenDAX v4 instances. It contains custody logic: performs all operations on VaultProxy contracts' requests:
  • deposit
  • withdraw
  • migrate to a new VaultImpl version
For example, VaultImpl performs an operation and stores the hash of it in VaultProxy storage.

In practice

Vault contract deployment

The first mandatory step after OpenDAX v4 installation is the deployment of VaultProxy contract for the instance. A broker initiates the deployment via Installation Wizard, and Finex, the core engine of the installed OpenDAX, deploys VaultProxy for the instance.
The new VaultProxy already has a hardcoded address of a VaultImpl contract.

User deposits

VaultProxy is responsible for the assets' custody, VaultImpl for the logic of the operations, and Finex is the entity that navigates users’ requests.

User withdraws

Contract upgrade

VaultProxy only contains custody and delegation logic and remains unchanging.
VaultImpl contract that provides operations logic can be upgraded when needed.
If an update is available, each broker receives the notification and may choose to migrate their VaultProxy connection to a new, updated VaultImpl contract (or choose to stay with the previous VaultImpl version).
A new version of VaultImpl essentially makes a hardfork of the Yellow Network.
Previous versions of VaultImpl remain functional since some brokers may prefer to use them and not apply new features of a new VaultImpl contract. But if the broker uses Yellow Network, they need to upgrade.