This repository contains the smart contracts source code and configuration files for the Primex Finance protocol. The repository uses Hardhat as a development environment for compilation, testing and deployment.
Primex Finance is a non-custodial prime brokerage protocol that connects lenders with traders, enabling traders to utilize lender liquidity for leveraged spot trading on existing DEXs like Uniswap, Balancer, Curve, and more. On Primex, traders can also benefit from CEX-like trader tooling and interfaces.
Audited by Halborn, Quantstamp, Resonance Security.
You can find all audit reports in the audits repository.
- node.js v18
- yarn
cd src
yarn install
Some scripts may require additional environment variables. You can install them by adding a .env
file to the ./src
folder (see env.template).
Hardhat default generated accounts are used for testing and deployment to the localhost.
Add a .env
file to the ./src
folder (see env.template)
By geth keystore:
KEYSTORE_DIR=<PATH_TO_YOUR_KEYSTORE_DIR>
ADDRESS=<KEY_PUB_ADDRESS>
PASSWORD=<PASSWORD>
By private key:
PRIVATE_KEY=<PRIVATE_KEY>
Run tests:
cd src
yarn test
Run coverage:
COVERAGE=true
cd src
yarn hardhat coverage
- unit tests
./src/test/unit/
- integration tests
./src/test/integration/
- functional tests
./src/test/
Docs:
cd src
yarn hardhat node --no-deploy
yarn hardhat deployFull:devnode1 --network localhost
cd src
# Network list you can find in the instruction (./docs/developmentSetup.md)
yarn hardhat deployCore --network <network_name>
Default config:
HOST_ADDR=<rpc_endpoint>
cd src
yarn hardhat deployFull:devnode1 --network host
Custom config: Env contracts setup tasks
HOST_ADDR=<rpc_endpoint>
cd src
# Deploy env contracts
yarn hardhat setup:deployEnv --network host [--flags ...]
# Deploy core and testnet services
yarn hardhat deployCoreAndTestnetServices --network host
The Primex protocol will be deployed in phases. Each phase has a separate task. Tasks can be found here
First phase:
HOST_ADDR=<rpc_endpoint>
cd src
yarn hardhat setup:phase-1 --network <network_name>
When working on a project, you must adhere to the development rules described below. All of these rules are necessary to improve the development experience.
- Git flow - git usage rules