Skip to content

Commit

Permalink
Partial Collateralization & Liquidation (#382)
Browse files Browse the repository at this point in the history
* Controller modifications for partial collateralization (#368)

* update OpenVaultArgs; set vault type; add vaultLatestUpdate

* fix build

* fix tests

* fix integration tests

* add vault type to event

* increase tests coverage

* update comment

Co-authored-by: aparnakr <aparnalocked@gmail.com>

Co-authored-by: aparnakr <aparnalocked@gmail.com>

* Update chainlink interface to V3 (#369)

* update chainlink interface to V3

* add decimals() scaling

* Chainlink historical price (#370)

* update OpenVaultArgs; set vault type; add vaultLatestUpdate

* fix build

* fix tests

* fix integration tests

* add vault type to event

* increase tests coverage

* update chainlink interface to V3

* add historical price function

* fix integration tests

* add tests

* add more tests

* typo

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* add decimals() scaling

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* fix the controller harness (#373)

* Partial collateralization margin check (#371)

* update OpenVaultArgs; set vault type; add vaultLatestUpdate

* fix build

* fix tests

* fix integration tests

* add vault type to event

* increase tests coverage

* update chainlink interface to V3

* add historical price function

* fix integration tests

* add tests

* add more tests

* add sync function

* just checking that vault is not under water at settling, and boom encountered stack tooo deep :p

* change variables scope

* add vault type to getVault()

* fix tests to work with the getVault() modification

* update getVault() to return latestUpdateTimestamp; add test for sync()

* add owner functions

* fix typo

* set oracle deviation value

* fix build

* add vaultType to getExcessCollateral

* check margin if naked vault and not expired yet

* fix tests

* add _findUpperBoundValue()

* add getter functions

* add test coverage

* improve coverage

* typo

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* add decimals() scaling

* re-order functions; increase coverage

* _getNakedMarginRequired()

* _getNakedMarginRequired() test

* re-run CI

* update package-lock.json

* lint contracts

* lint test files

* improve coverage

* more margin required tests

* more margin required tests

* fix bug

* call tests

* improve comment

* add view function to get required margin for specific product

* add backward compatibility for openVault action

* more tests

* refactor _getProductHash

* refactor

* test settling undercollateralized vault

* tests for removing collateral from expired positions

* updated harness

* remove console.log()

* clean

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>
Co-authored-by: Shelly Grossman <shellygr151@gmail.com>

* Opyn liquidation (#378)

* update OpenVaultArgs; set vault type; add vaultLatestUpdate

* fix build

* fix tests

* fix integration tests

* add vault type to event

* increase tests coverage

* update chainlink interface to V3

* add historical price function

* fix integration tests

* add tests

* add more tests

* add sync function

* just checking that vault is not under water at settling, and boom encountered stack tooo deep :p

* change variables scope

* add vault type to getVault()

* fix tests to work with the getVault() modification

* update getVault() to return latestUpdateTimestamp; add test for sync()

* add owner functions

* fix typo

* set oracle deviation value

* fix build

* add vaultType to getExcessCollateral

* check margin if naked vault and not expired yet

* fix tests

* add _findUpperBoundValue()

* add getter functions

* add test coverage

* improve coverage

* typo

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* add decimals() scaling

* re-order functions; increase coverage

* _getNakedMarginRequired()

* _getNakedMarginRequired() test

* re-run CI

* update package-lock.json

* lint contracts

* lint test files

* improve coverage

* more margin required tests

* more margin required tests

* fix bug

* call tests

* improve comment

* add view function to get required margin for specific product

* add backward compatibility for openVault action

* more tests

* refactor _getProductHash

* refactor

* test settling undercollateralized vault

* add liquidate action args

* liquidate action args tests

* get liquidation price; check if vault is liquidatable

* add comments

* init tests

* liquidate

* fix tests

* more tests

* add comments

* liquidation price testing

* more tests

* change AUCTION_TIME scaling

* tests

* tests

* fix calculation; more tests

* fix collateral to sell calculation

* full liquidation tests

* partially liquidation test

* add function description

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* rename var; refactor util function

* natspec comments

* clean tests

* require dust amount is greater than zero

* set bignumber config

* fix coverage

* update circleci config

* fix tests

* clean code

* clean

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clean

* fix build

* add requirement for spot shock value

* fix typo

* cap liquidation price

* fix capping

* fix tests

* add tests for call position

* add natspec comment

* fix timestamp check

* fix tests

* fix tests

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* Gamma partial collateralization: integration tests (#381)

* update OpenVaultArgs; set vault type; add vaultLatestUpdate

* fix build

* fix tests

* fix integration tests

* add vault type to event

* increase tests coverage

* update chainlink interface to V3

* add historical price function

* fix integration tests

* add tests

* add more tests

* add sync function

* just checking that vault is not under water at settling, and boom encountered stack tooo deep :p

* change variables scope

* add vault type to getVault()

* fix tests to work with the getVault() modification

* update getVault() to return latestUpdateTimestamp; add test for sync()

* add owner functions

* fix typo

* set oracle deviation value

* fix build

* add vaultType to getExcessCollateral

* check margin if naked vault and not expired yet

* fix tests

* add _findUpperBoundValue()

* add getter functions

* add test coverage

* improve coverage

* typo

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* add decimals() scaling

* re-order functions; increase coverage

* _getNakedMarginRequired()

* _getNakedMarginRequired() test

* re-run CI

* update package-lock.json

* lint contracts

* lint test files

* improve coverage

* more margin required tests

* more margin required tests

* fix bug

* call tests

* improve comment

* add view function to get required margin for specific product

* add backward compatibility for openVault action

* more tests

* refactor _getProductHash

* refactor

* test settling undercollateralized vault

* add liquidate action args

* liquidate action args tests

* get liquidation price; check if vault is liquidatable

* add comments

* init tests

* liquidate

* fix tests

* more tests

* add comments

* liquidation price testing

* more tests

* change AUCTION_TIME scaling

* tests

* tests

* fix calculation; more tests

* fix collateral to sell calculation

* full liquidation tests

* partially liquidation test

* add function description

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clear

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* rename var; refactor util function

* natspec comments

* clean tests

* require dust amount is greater than zero

* set bignumber config

* fix coverage

* update circleci config

* fix tests

* clean code

* clean

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* clean

* fix build

* add requirement for spot shock value

* fix typo

* cap liquidation price

* fix capping

* fix tests

* add tests for call position

* clean

* add natspec comment

* add natspec comment

* init integration tests

* more tests

* fix timestamp check

* more tests

* fix tests

* fix tests

* more tests

* init call integration tests

* more tests

* fix tests

* more tests

* add more tests for put and call naked margin positions

* chore: undo vault type changes

* fix tests

* fix unit tests

* fix integration tests for call

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* Merge setProductTimeToExpiry() & setTimeToExpiryValue() into setUpperBoundValues() (#385)

* add setUpperBoundValues()

* update tests

* fix unit tests

* fix integration tests

* integration-tests:fix collateral check after liquidation

* assert liquidation price is greater than zero when testing liquidation scenarios

* clean

* unit tests:setUpperBoundValues()

* improve margin calculator coverage

* fix integration tests

* updateUpperBoundValue()

* improve updateUpperBoundValue() coverage

* Improve comments in Calculator & Controller (#389)

* improve comments

* Improve comment in Controller

* fix build failing

* remove unused code

* remove LiquidationStatus struct (#390)

* improve comments

* Improve comment in Controller

* fix build failing

* remove LiquidationStatus struct

* revert package.json change

* Fix wrong sign

* improve comments

* Improve comment in Controller

* fix build failing

* remove unused code

* remove LiquidationStatus struct

* revert package.json change

* Fix wrong sign

Co-authored-by: Haythem Sellami <sellamihaythem96@gmail.com>

* Fix tests (#396)

* fix tests

* update error delta

* Refactor marginVault to reduce # of SLOAD (#380)

* refactor marginVault to reduce # of SLOAD

* Apply change to addCollateral and removeCollateral

* Simplify remove logic

* keep the old if block

* remove duplicated logic in _getCashValue and _getExpiredCashValue (#394)

* update _isMarginableLong() verification order (#398)

* Add donate feature (#399)

* add donate()

* add tests

* fix tests

* add function comment

* rm BigNumber rounding mode config in MarginCalculator liquidation unit test

* rm BigNumber config settings

* Disable withdrawing collateral after expiry (#397)

* undo _withdrawCollateral() changes and update revert messages

* update error messages

* update tests:

* Update error code

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* Add public getMarginRequired() (#400)

* add external _getMarginRequired()

* update getMarginRequired()

* rename variables (#401)

* chore: update comment

* chore:clean & update comments

* Update yearn pricer (#402)

* fix yearn pricer to work with the new OpynPricerInterface

* update revert message

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

Co-authored-by: Anton Cheng <antonassocareer@gmail.com>

* Refactor: Rename state variables, events, & external functions (#403)

* refactor: productToTimeToExpiry -> timesToExpiryForProduct

* refactor: ProductTimeToExpiryAdded -> TimeToExpiryAdded

* refactor: getProductTimeToExpiry -> getTimesToExpiry

* refactor: timeToExpiryToMaxPrice -> maxPriceAtTimeToExpiry

* refactor: TimeToExpiryValueAdded -> MaxPriceAdded

* refactor: getTimeToExpiryValue -> getMaxPrice

* docs: misc spotShock mapping comment update

* fix compiler warnings & move to core folder

* Fix certora contracts path (#404)

* fix: contracts path

* fix harness contracts path

Co-authored-by: aparnakr <aparnalocked@gmail.com>
Co-authored-by: Anton Cheng <antonassocareer@gmail.com>
Co-authored-by: Shelly Grossman <shellygr151@gmail.com>
Co-authored-by: CruzMolina <7537712+CruzMolina@users.noreply.github.com>
Co-authored-by: Cruz Molina <cruz.adam.molina@gmail.com>
  • Loading branch information
6 people committed May 7, 2021
1 parent ae562c4 commit 9a75da2
Show file tree
Hide file tree
Showing 83 changed files with 7,255 additions and 2,231 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ workflows:
- coverage:
context: COVERALLS_REPO_TOKEN
requires:
- unit-test
- integration-test
- gas-report:
context: COVERALLS_REPO_TOKEN
Expand Down
537 changes: 0 additions & 537 deletions contracts/MarginCalculator.sol

This file was deleted.

6 changes: 3 additions & 3 deletions contracts/AddressBook.sol → contracts/core/AddressBook.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* SPDX-License-Identifier: UNLICENSED
*/
pragma solidity 0.6.10;
pragma solidity =0.6.10;

import {Ownable} from "./packages/oz/Ownable.sol";
import {OwnedUpgradeabilityProxy} from "./packages/oz/upgradeability/OwnedUpgradeabilityProxy.sol";
import {Ownable} from "../packages/oz/Ownable.sol";
import {OwnedUpgradeabilityProxy} from "../packages/oz/upgradeability/OwnedUpgradeabilityProxy.sol";

/**
* @author Opyn Team
Expand Down
419 changes: 313 additions & 106 deletions contracts/Controller.sol → contracts/core/Controller.sol

Large diffs are not rendered by default.

Loading

0 comments on commit 9a75da2

Please sign in to comment.