Skip to content

Commit

Permalink
Merge pull request #96 from perpetual-protocol/release/v2.8.1-rc
Browse files Browse the repository at this point in the history
Release/v2.8.1
  • Loading branch information
vinta authored Jul 25, 2023
2 parents 3ce8b81 + b76c3a4 commit de09aa8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [2.8.1] - 2023-07-24

### Changed

- Change MarkPrice's marketPrice to 15-second market TWAP.

## [2.8.0] - 2023-06-19
### Changed
- Apply the `sqrtPriceLimitX96` config when closing a position.
Expand Down
4 changes: 3 additions & 1 deletion contracts/AccountBalance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ contract AccountBalance is IAccountBalance, BlockContext, ClearingHouseCallee, A
IClearingHouseConfig clearingHouseConfig = IClearingHouseConfig(_clearingHouseConfig);
(uint32 marketTwapInterval, uint32 premiumInterval) = clearingHouseConfig.getMarkPriceConfig();

uint256 marketPrice = _getMarketPrice(baseToken, 0);
// previously, marketPrice is _getMarketPrice(baseToken, 0) which is relatively easy to be manipulated,
// so we change to 15-second twap
uint256 marketPrice = _getMarketPrice(baseToken, 15);
uint256 marketTwap = _getMarketPrice(baseToken, marketTwapInterval);
int256 premium =
_getMarketPrice(baseToken, premiumInterval).toInt256().sub(
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@perp/curie-contract",
"version": "2.8.0",
"version": "2.8.1",
"description": "Perpetual Protocol Curie (V2) core contracts",
"license": "GPL-3.0-or-later",
"author": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"typechain-openzeppelin": "typechain --target ethers-v5 --out-dir ./typechain/openzeppelin './node_modules/@openzeppelin/contracts/build/contracts/**/*.json'",
"typechain-perp-oracle": "typechain --target ethers-v5 --out-dir ./typechain/perp-oracle './node_modules/@perp/perp-oracle-contract/artifacts/contracts/**/*.json'",
"clean": "rm -rf typechain && rm -rf artifacts && rm -rf cache",
"test": "hardhat --max-memory 8096 test",
"test": "NODE_OPTIONS='--max-old-space-size=8192' hardhat --max-memory 8192 test",
"parallel-test": "hardhat test --parallel",
"foundry-test": "forge test",
"foundry-build-uniswap": "forge build --contracts node_modules/@uniswap/v3-core/contracts/UniswapV3Factory.sol",
Expand Down
5 changes: 2 additions & 3 deletions test/foundry/accountBalance/AccountBalance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ contract AccountBalanceTest is IAccountBalanceEvent, Setup {
function test_getMarkPrice_should_return_index_price_with_premium_if_mark_price_enabled() public {
(uint32 marketTwapInterval, uint32 premiumInterval) = clearingHouseConfig.getMarkPriceConfig();

// mock current market price, price = 100
uint256 sqrtPrice = 10;
_mockMarketPrice(address(pool), sqrtPrice);
// mock market twap(15sec): price = 100, tick = 46080
_mockMarketTwap(address(pool), 15, 46080);

// mock market twap(30min): price = 95, tick = 45541
_mockMarketTwap(address(pool), marketTwapInterval, 45541);
Expand Down

0 comments on commit de09aa8

Please sign in to comment.