This repository shows how to interact with the hydro v2 margin smart contract.
1. Read or Monitor Contract Status
This example shows how to read data from contract.
npm install npm run example
2. Contract Structure and Moving Assets
The hydro v2 margin contract supports three primary functions: spot trading, margin trading, and lending. To avoid collision of actions between these areas, each of these functions actually has a separate balance within the contract (referred to as "Accounts"). Additionally, you can also interact with the hydro margin contract through an external Ethereum wallet (such as MetaMask).
The following table highlights this division of asset allocation for interacting with the hydro v2 margin contract:
|Ethereum Wallet||Private Wallet||Your personal wallet. eg: MetaMask.|
|Trading Balance||Hydro Contract||Balances here can be withdrawn at any time. Can be used to place orders for spot trading.|
|Margin Balance||Hydro Contract||Balances here can be used as collateral to borrow assets into the corresponding market for margin trading. Each market has a separate margin balance (ETH-DAI margin balances are separate from ETH-USDT margin balances)|
|Funding Balance||Hydro Contract||Balances in funding pools earn interest. Traders can borrow funds from here for margin trading.|
There are 7 unique actions defined in the hydro v2 margin contract for moving your assets between your external wallet and the hydro accounts. These actions are:
Transfer, described in the table below.
|Action||How Assets Are Moved|
The following picture depicts a high level overview of how asset moving actions interact with each area of the contract:
This code example will show you how to move your funds and how to combine these actions.
3. Participating in auctions
Hydro Margin liquidations are handled through the form of dutch auctions. We will provide more detailed guides on participating in these auctions in the future, but for now if you'd like to get involved please check out the following code example:
Full List of Functions
All external functions are listed in this file.