sorianog / solo

dYdX V2 Margin Trading Protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ethereum Smart Contracts and TypeScript library used for the dYdX Solo Trading Protocol. Currently used by

Full Documentation at

Table of Contents


Check out our full documentation at


npm i -s @dydxprotocol/solo


The current contract addresses can be found in deployed.json.

Contract Name Description
SoloMargin Main dYdX contract
PayableProxyForSoloMargin WETH wrapper proxy
DoubleExponentInterestSetter Sets interest rates
PolynomialInterestSetter Sets interest rates
Expiry Handles account expiries
ExpiryV2 Handles account expiries (version 2)
FinalSettlement Handles final settlement of all accounts
DaiPriceOracle Price oracle for DAI or SAI
WethPriceOracle Price oracle for WETH
UsdcPriceOracle Price oracle for USDC
AdminImpl SoloMargin library containing admin functions
OperationImpl SoloMargin library containing operation functions
LiquidatorProxyV1ForSoloMargin Proxy contract for liquidating other accounts
LimitOrders Contract for making limit orders using dYdX funds
StopLimitOrders Contract for making stop limit orders using dYdX funds
CanonicalOrders Contract for making canonical limit and canonical stop-limit orders using dYdX funds
SignedOperationProxy Contract for sending signed operations on behalf of another account owner
Refunder Allows sending of funds to other accounts
DaiMigrator Converts SAI positions to DAI positions


Independent Audits

The smart contracts were audited independently by both Zeppelin Solutions and Bramah Systems.

Zeppelin Solutions Audit Report

Bramah Systems Audit Report

Code Coverage

All production smart contracts are tested and have 100% line and branch coverage.

Vulnerability Disclosure Policy

The disclosure of security vulnerabilities helps us ensure the security of our users.

How to report a security vulnerability?

If you believe you’ve found a security vulnerability in one of our contracts or platforms, send it to us by emailing Please include the following details with your report:

  • A description of the location and potential impact of the vulnerability.

  • A detailed description of the steps required to reproduce the vulnerability.


Any vulnerability not previously disclosed by us or our independent auditors in their reports.


We require that all reporters:

  • Make every effort to avoid privacy violations, degradation of user experience, disruption to production systems, and destruction of data during security testing.

  • Use the identified communication channels to report vulnerability information to us.

  • Keep information about any vulnerabilities you’ve discovered confidential between yourself and dYdX until we’ve had 30 days to resolve the issue.

If you follow these guidelines when reporting an issue to us, we commit to:

  • Not pursue or support any legal action related to your findings.

  • Work with you to understand and resolve the issue quickly (including an initial confirmation of your report within 72 hours of submission).

  • Grant a monetary reward based on the OWASP risk assessment methodology.


Compile Contracts

Requires a running docker engine.

npm run build

Compile TypeScript

npm run build:js


Requires a running docker engine.

Start test node:

docker-compose up

Deploy contracts to test node & run tests:

npm test

Just run tests (contracts must already be deployed to test node):

npm run test_only

Just deploy contracts to test node:

npm run deploy_test





dYdX V2 Margin Trading Protocol

License:Apache License 2.0


Language:TypeScript 78.1%Language:Solidity 18.3%Language:JavaScript 2.7%Language:Python 0.8%Language:Shell 0.1%Language:Dockerfile 0.0%