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

Hoxfix/v2.8.3 #101

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [2.8.3] - 2023-09-09
- Add tick checking when swap

## [2.8.2] - 2023-08-15

### Changed
Expand Down
8 changes: 4 additions & 4 deletions contracts/Exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
//
// STRUCT
//

struct InternalSwapResponse {
int256 base;
int256 quote;
Expand All @@ -74,7 +73,6 @@
//
// CONSTANT
//

uint256 internal constant _FULLY_CLOSED_RATIO = 1e18;
uint24 internal constant _MAX_TICK_CROSSED_WITHIN_BLOCK_CAP = 1000; // 10%
uint24 internal constant _MAX_PRICE_SPREAD_RATIO = 0.1e6; // 10% in decimal 6
Expand All @@ -83,7 +81,6 @@
//
// EXTERNAL NON-VIEW
//

function initialize(
address marketRegistryArg,
address orderBookArg,
Expand Down Expand Up @@ -226,7 +223,7 @@
// NOTE: the cached index twap is used for AccountBalance.MarkPrice calculation,
// not for funding rate calculation.
(, uint32 premiumInterval) = IClearingHouseConfig(_clearingHouseConfig).getMarkPriceConfig();
try IBaseToken(baseToken).cacheTwap(premiumInterval) {} catch {}

Check warning on line 226 in contracts/Exchange.sol

View workflow job for this annotation

GitHub Actions / lint

Code contains empty blocks

Check warning on line 226 in contracts/Exchange.sol

View workflow job for this annotation

GitHub Actions / lint

Code contains empty blocks

Check warning on line 226 in contracts/Exchange.sol

View workflow job for this annotation

GitHub Actions / lint

Code contains empty blocks

uint256 marketTwap;
uint256 indexTwap;
Expand Down Expand Up @@ -426,6 +423,10 @@
)
);

int24 tick = UniswapV3Broker.getTick(marketInfo.pool);
// tick mismatch
require(tick == replayResponse.tick, "EX_TKMM");

// avoid stack too deep
{
// check price band after swap
Expand Down Expand Up @@ -521,7 +522,6 @@
//
// INTERNAL VIEW
//

function _getSqrtMarketTwapX96(address baseToken, uint32 twapInterval) internal view returns (uint160) {
return UniswapV3Broker.getSqrtMarketTwapX96(IMarketRegistry(_marketRegistry).getPool(baseToken), twapInterval);
}
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@perp/curie-contract",
"version": "2.8.2",
"version": "2.8.3",
"description": "Perpetual Protocol Curie (V2) core contracts",
"license": "GPL-3.0-or-later",
"author": {
Expand Down
Loading