-
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
MarketUpdated event #1697
MarketUpdated event #1697
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1697 +/- ##
=======================================
Coverage 72.77% 72.77%
=======================================
Files 57 57
Lines 720 720
Branches 236 236
=======================================
Hits 524 524
Misses 167 167
Partials 29 29
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Note that for an event to be emitted from a library, it needs to be defined in two places: - The library itself, and - The interface of the contract that is using the library.
A bit of a journey but I think I got there in the end.
Learned that if you want to emit an event from a storage library you need to define it:
Doing this we pushed the AsyncOrderModule over the size limit, so I created a new |
- Creating a AsyncOrderViewModule
66b462e
to
0282bcd
Compare
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.
LGTM
markets/perps-market/contracts/modules/AsyncOrderViewModule.sol
Outdated
Show resolved
Hide resolved
const pSkew = wei(skew).div(skewScale); | ||
const pSkewBounded = Wei.max(Wei.min(pSkew, wei(1)), wei(-1)); | ||
|
||
return pSkewBounded.mul(maxFundingVelocity); |
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.
maybe returns bignumber via .toBN()
here?
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.
Coming from the frontend we usually keep everything in Wei and just toBN
before sending to ethers contract call. Wei usually makes math and most things easier.
But we do seem to like/use BigNumber more in contract tests, so I guess it make sense to return bn.
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.
ok cool yeah fair enough!
c1ca838
to
853fe55
Compare
853fe55
to
0f26123
Compare
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.
awesome! tyty
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
interface IMarketEvents { |
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.
any others around that we can throw in here maybe? 👀
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.
Most modules will have their events defined in their own interface. I had a look, didn't see any clear ones to move
@@ -131,6 +131,7 @@ library AsyncOrder { | |||
uint initialRequiredMargin; | |||
uint totalRequiredMargin; | |||
Position.Data newPosition; | |||
bytes32 trackingCode; |
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.
still need this?
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.
Yea, without it we get "Stack too deep." Just at the limit now 😓
hmm some tests failed; seems legitimate? |
It does looks like that.. Looking now, pretty sure I ran it locally... |
Was a fluke :(... Reran fixed it |
Include market skew and market size in the settle order event