Giter Site home page Giter Site logo

dydxprotocol / perpetual Goto Github PK

View Code? Open in Web Editor NEW
171.0 171.0 66.0 1.5 MB

Ethereum Smart Contracts and TypeScript library used for the dYdX Perpetual Contracts

License: Apache License 2.0

JavaScript 2.24% Dockerfile 0.06% TypeScript 68.05% Shell 0.10% Python 1.21% Solidity 28.34%

perpetual's People

Contributors

antoniojuliano avatar brendanchou avatar kenadia avatar samweinberg23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

perpetual's Issues

Set up testing contracts and modules

  • In contracts/test/v1/ set up test contracts for the Funder, Oracle, Trader, and Vault.
  • In src/lib/modules/ set up a Testing.ts file that helps us set the values for these contracts. You can use https://github.com/dydxprotocol/solo/blob/master/src/modules/testing/Testing.ts for inspiration
  • This file should be used in src/Perpetual.ts
  • Deploy these files in the migrations/2_deploy.js file if the network is a test network
  • Write a setup file/function in test/helpers/ that helps set these as the contracts that are used by the protocol. We can use this at the start of most tests

Decide if we should add a boolean flag to Liquidator to check positive/negative balance

One very strange edge case that could happen here is the sign of the position could be different when the transaction is sent, and when it is mined, so as a liquidator you could get the opposite of the trade you want (you could sell when you thought you were going to buy)

Maybe it's worth including a flag in the data as to what side the maker intends to take

Fix solc optimization when using sol-trace

When we run tests with ENABLE_SOL_TRACE the sol-trace library will do its own compilation step when running truffle test. I had to disable compiler optimization when compiling with Truffle to get the source maps used by sol-trace to match up with the Truffle-compiled contracts.

It seems like the optimizer setting in compiler.json is not being respected, even though the file is definitely read by @0x/sol-compiler and the useDockerisedSolc option is used.

See:

Remove SolTrace changes

#25 adds contracts/Imports.sol to get sol-trace to compile successfully when running tests with ENABLE_SOL_TRACE=true.

The problem seems to be that @0x/sol-compiler doesn't detect sources in the same way as Truffle, and doesn't include these files when generating the config object passed as input to solc.

Ideally we can get rid of Imports.sol and fix this maybe either through configuration of the compiler via compiler.sol or by patching @0x/sol-compiler.

See:

Create LiquidatorProxy

Intelligently set the amount to liquidate such that the liquidating account does not become underwater after the liquidation

Decide if an amount is necessary to pass in to Deleverager

Antonio: "Is there a reason we need to allow the sender to specify the amount at all? Why not just always use Math.min(makerBalance.position, takerBalance.position)?"

I think it's fine as it gives more flexibility, but I'll let you make the decision Ken

Add deleveraging

If an account has a negativeValue that is greater than it's positive value, then it is underwater. The Deleveraging contract should allow anyone to take one of these accounts and have it be subsumed by any other account that has the opposite position. This contract will be a P1Trader contract. The deleveraging should not be allowed to make either account "go past zero" in terms of their position size.

  • Contract
  • JS Component
  • Tests

Coverage for Perpetual

solidity-coverage 0.6.x doesn't work with Solidity 0.6.0

solidity-coverage 0.7.x runs through truffle test which uses mocha which doesn't play nice with typescript, so we would have to compile the tests into a different folder and then run truffle test in there. We could move everything over to use mocha instead of jest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.