-
Notifications
You must be signed in to change notification settings - Fork 19
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
Remove absolute position update #512
base: v2.4
Are you sure you want to change the base?
Remove absolute position update #512
Conversation
…30-remove-absolute-position-update
This one looks like it's on the right track now 👍 |
…30-remove-absolute-position-update
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.
Looks pretty good; just a few nits inline.
expect((await market.pendingOrders(user.address, 2)).protection).to.eq(1) | ||
}) | ||
|
||
it('liquidates a user with close', async () => { |
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.
Note to self: We can no longer liquidate with update
, only close
, explaining why two tests are no longer needed 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.
Appreciate the cleanup.
@@ -761,16 +760,16 @@ export function RunManagerTests(name: string, getFixture: (overrides?: CallOverr | |||
expect(canExecuteBefore).to.be.false | |||
|
|||
// time passes, other users interact with market | |||
let positionA = (await market.positions(userA.address)).maker | |||
let positionC = (await market.positions(userC.address)).short | |||
let positionADelta |
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.
nit: I would have named this positionDeltaA
to prevent jumbling uppercase letters together.
/// @param timestamp The current timestamp | ||
/// @param position The current position | ||
/// @param makerAmount The magnitude and direction of maker position | ||
/// @param takerAmount The magnitude and direction of taker position | ||
/// @param collateral The change in the collateral | ||
/// @param protect Whether the order is protected |
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.
/// @param protect Whether the order is protected | |
/// @param protect True when liquidating the position |
@@ -80,12 +80,13 @@ library OrderLib { | |||
(UFixed6Lib.ZERO, UFixed6Lib.ZERO, UFixed6Lib.ZERO, UFixed6Lib.ZERO, UFixed6Lib.ZERO, UFixed6Lib.ZERO); | |||
} | |||
|
|||
/// @notice Creates a new order from the an intent order request | |||
/// @notice Creates a new order from the an intent and delta order request |
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.
from the an intent and delta
doesn't sound right. If this from
method is really used for both use cases, it could read from an intent or delta
.
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
newOrder.makerReferral = makerAmount.abs().mul(referralFee); | ||
newOrder.takerReferral = takerAmount.abs().mul(referralFee); | ||
newOrder.protection = protect ? 1 : 0; |
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.
do we need to change the order here? might want to leave in the original slot just to reduce the changeset.
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.
I think it happened while merging, reverting to old order.
/// @param collateral The collateral delta of the order (positive for deposit, negative for withdrawal) | ||
/// @param referrer The referrer of the order | ||
function update( | ||
address account, | ||
Fixed6 amount, | ||
Fixed6 takerAmount, |
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.
what if we went the other direction for these and named them taker
and maker
like you did in the Trigger Order code for both overloads? might be a little more succint.
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.
In the trigger orders i have used makerDelta
and takerDelta
. I think taker and maker are used in multiInvoker here. I agree that it will be more succinct but I like takerAmount
more than taker
as it helps with readability and think that we should rename to takerAmount
in multiInvoker
as well.
.muldiv(marketContext.registration.leverage, marketContext.latestPrice.abs()) | ||
.max(marketContext.minPosition) | ||
.min(marketContext.maxPosition); | ||
target.position = _getTargetPosition(marketContext, marketAssets); |
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.
Instead of pulling this out into it's own function what if we did:
- change
target.position
toUFixed6 newMaker
. - add new line
target.position = Fixed6Lib.from(newMaker).sub(Fixed6Lib.from(marketContext.currentAccountPosition.maker));
/// @dev The new position | ||
UFixed6 position; | ||
/// @dev The amount of change in position | ||
Fixed6 position; |
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 we should change the name of this field to taker
? not that's not representing a absolute position anymore?
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.
I think you mean change this to maker
? Maybe we can change this to makerDelta
or positionDelta
?
[Periphery] Unit Test Coverage ReportCoverage after merging prateek/pe-1630-remove-absolute-position-update into v2.4 will be
Coverage Report
|
[Core] Integration Test Coverage ReportCoverage after merging prateek/pe-1630-remove-absolute-position-update into v2.4 will be
Coverage Report
|
Code Size Diff:View Report
|
Gas Report Diff:View Report
|
[Periphery] Integration Test Coverage ReportCoverage after merging prateek/pe-1630-remove-absolute-position-update into v2.4 will be
Coverage Report
|
[Periphery] Combined Test Coverage ReportCoverage after merging prateek/pe-1630-remove-absolute-position-update into v2.4 will be
Coverage Report
|
[Core] Unit Test Coverage ReportCoverage after merging prateek/pe-1630-remove-absolute-position-update into v2.4 will be
Coverage Report
|
[Core] Combined Test Coverage ReportCoverage after merging prateek/pe-1630-remove-absolute-position-update into v2.4 will be
Coverage Report
|
Issues addressed: