Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add public getMarginRequired() #400

Merged
merged 2 commits into from
May 6, 2021

Conversation

haythemsellami
Copy link
Member

@haythemsellami haythemsellami commented May 5, 2021

Task: Add public getMarginRequired()

High Level Description

Add external getMarginRequired() function.

Code

  • Unit test 100% coverage
  • Does your code follow the naming and code documentation guidelines?

Documentation

  • Is your code up to date with the spec?
  • Have you added your tests to the testing doc?

@haythemsellami haythemsellami changed the base branch from master to feature/v2.0.0 May 5, 2021 12:36
@haythemsellami haythemsellami self-assigned this May 5, 2021
@haythemsellami haythemsellami added the gamma-v2.0.0 Opyn partial collateralization label May 5, 2021
Copy link
Contributor

@antoncoding antoncoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been giving some thoughts, I think it make more sense to not asking the user to put in VaultDetails as an argument, as the _getVaultDetails function is not public.

In this external function, we should simply get detail first, and that call the internal function.

contracts/MarginCalculator.sol Outdated Show resolved Hide resolved
@haythemsellami haythemsellami merged commit d21639d into feature/v2.0.0 May 6, 2021
@haythemsellami haythemsellami deleted the chore/public-_getMarginRequired branch May 6, 2021 09:36
haythemsellami pushed a commit that referenced this pull request May 7, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gamma-v2.0.0 Opyn partial collateralization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants