This repo contains a the Margined Protocol a decentralized perpetual contract protocol on the Terra Blockchain.
Contract | Reference | Description |
---|---|---|
Margin Engine |
doc | Margin engine that manages users positions and the collateral management |
vAMM |
doc | Virtual AMM enabling users to take perpetual positions |
Price Feed |
doc | Integration contract for the data oracles and other data related logic |
Governance |
doc | TODO |
Factory |
doc | TODO |
- Rust v1.44.1+
wasm32-unknown-unknown
target- Docker
-
Install
rustup
via https://rustup.rs/ -
Run the following:
rustup default stable
rustup target add wasm32-unknown-unknown
- Make sure Docker is installed
Each contract contains Rust unit and integration tests embedded within the contract source directories. You can run:
cargo unit-test
cargo integration-test
Clone this repository and build the source code:
git clone [email protected]:margined-protocol/mrgnd-perpetuals.git
cd mrgnd-perpetuals
cargo build
- vAMM
- Initialise
- Owner, assets, etc
- Execute
- Init vAMM (define constant product func k)
- define the state of the new vAMM
- Long / Short
- SettleFunding
- Init vAMM (define constant product func k)
- Query
- Latest Price
- Initialise
- Margin Engine
- Initialise
- owner, vAMM, etc
- Execute
- New position / Close position
- New eligible collateral (maybe? potentially we only allow a single type? would make x-margin easier)
- Update vAmms, i.e. append, remove etc
- Update vAmms, i.e. append, remove etc
- Query
- Initialise
- Oracle
- PriceFeed contract that integrates against TeFi hub
- Wrapper for TeFi oracles which do calcs listed below
- TWAP
- ???
- Decimal Library
- General decimal calculation library for use around with my fixed point decimals
- Factory
- Governance
- General
- Testing framework improvements
- Wrapper for smart contract functions
- Setup files
- Better organisation
- Code comment documentation
- Code Coverage - cargo-tarpaulin
- Code linting
- Testing framework improvements