-
Notifications
You must be signed in to change notification settings - Fork 58
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
Max oi cap #1669
Max oi cap #1669
Changes from 10 commits
b8ff0d7
2f6be99
223b7f8
50309d2
ecacae3
4929977
e291b23
7273a63
ce949b4
989f968
cb25f91
d52da02
d435394
84639ea
422b7b4
250ec19
badf232
c596d8e
e9f7068
b634b9e
c57fec9
60c76c4
18ae444
cc4a682
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ describe('Market - size test', () => { | |
name: 'Ether', | ||
token: 'snxETH', | ||
price: bn(2000), | ||
maxMarketValue: bn(9999999), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of needing to pass it in everywhere, in the |
||
}, | ||
], | ||
traderAccountIds: [2, 3], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ describe('Commit Offchain Async Order test', () => { | |
token: 'snxETH', | ||
price: bn(1000), | ||
fundingParams: { skewScale: bn(100_000), maxFundingVelocity: bn(0) }, | ||
maxMarketValue: bn(5000), | ||
}, | ||
], | ||
traderAccountIds: [2, 3], | ||
|
@@ -86,6 +87,28 @@ describe('Commit Offchain Async Order test', () => { | |
'InsufficientMargin' | ||
); | ||
}); | ||
|
||
it('reverts if max market value is reached', async () => { | ||
await depositCollateral({ | ||
accountId: () => 2, | ||
collaterals: [{ snxUSDAmount: () => bn(100_000) }], | ||
systems, | ||
trader: trader1, | ||
}); | ||
await assertRevert( | ||
systems() | ||
.PerpsMarket.connect(trader1()) | ||
.commitOrder({ | ||
marketId: ethMarketId, | ||
accountId: 2, | ||
sizeDelta: bn(90_000), | ||
settlementStrategyId: 0, | ||
acceptablePrice: bn(1450), // 5% slippage | ||
trackingCode: ethers.constants.HashZero, | ||
}), | ||
`MaxOpenInterestReached(${ethMarketId}, ${bn(5000).toString()})` | ||
); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately, there are many other cases to be tested here. see review comment for other scenarios |
||
}); | ||
|
||
const restoreToCommit = snapshotCheckpoint(provider); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let the
validatePositionSize
just revert instead of it returning a bool.that function needs to be refactored; but first would write the tests and make sure its working properly.