-
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?
Changes from 28 commits
46a8952
2781eea
388dcb7
a362d40
50da105
e830d03
a509791
f390103
574cc30
74e1564
bd95dea
255fb28
5570684
7efa228
71db5bf
722ede7
9191e0e
3404c09
2675308
58c2f0b
7fb6985
3856ad8
09cb5cb
4774f86
5713d01
81650f0
6f00446
6564682
f3b02b1
3cd9189
0878a92
84f256c
62c630c
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ on: | |
branches: | ||
- main | ||
- v2.4 | ||
- prateek/pe-1629-remove-magic-values | ||
workflow_dispatch: | ||
|
||
env: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 an intent or delta order request | ||
/// @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 True when liquidating the position | ||
/// @param referralFee The referral fee | ||
/// @return newOrder The resulting order | ||
function from( | ||
|
@@ -100,9 +101,9 @@ library OrderLib { | |
newOrder.timestamp = timestamp; | ||
newOrder.collateral = collateral; | ||
newOrder.orders = makerAmount.isZero() && takerAmount.isZero() ? 0 : 1; | ||
newOrder.protection = protect ? 1 : 0; | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think it happened while merging, reverting to old order. |
||
|
||
// If the order is not counter to the current position, it is opening | ||
if (takerAmount.sign() == 0 || position.skew().sign() == 0 || position.skew().sign() == takerAmount.sign()) { | ||
|
@@ -119,51 +120,6 @@ library OrderLib { | |
newOrder.makerNeg = makerAmount.min(Fixed6Lib.ZERO).abs(); | ||
prateekdefi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/// @notice Creates a new order from the current position and an update request | ||
/// @param timestamp The current timestamp | ||
/// @param position The current position | ||
/// @param collateral The change in the collateral | ||
/// @param newMaker The new maker | ||
/// @param newLong The new long | ||
/// @param newShort The new short | ||
/// @param protect Whether to protect the order | ||
/// @param referralFee The referral fee | ||
/// @return newOrder The resulting order | ||
function from( | ||
uint256 timestamp, | ||
Position memory position, | ||
Fixed6 collateral, | ||
UFixed6 newMaker, | ||
UFixed6 newLong, | ||
UFixed6 newShort, | ||
bool protect, | ||
UFixed6 referralFee | ||
) internal pure returns (Order memory newOrder) { | ||
(Fixed6 makerAmount, Fixed6 longAmount, Fixed6 shortAmount) = ( | ||
Fixed6Lib.from(newMaker).sub(Fixed6Lib.from(position.maker)), | ||
Fixed6Lib.from(newLong).sub(Fixed6Lib.from(position.long)), | ||
Fixed6Lib.from(newShort).sub(Fixed6Lib.from(position.short)) | ||
); | ||
|
||
UFixed6 referral = makerAmount.abs().add(longAmount.abs()).add(shortAmount.abs()).mul(referralFee); | ||
|
||
newOrder = Order( | ||
timestamp, | ||
0, | ||
collateral, | ||
makerAmount.max(Fixed6Lib.ZERO).abs(), | ||
makerAmount.min(Fixed6Lib.ZERO).abs(), | ||
longAmount.max(Fixed6Lib.ZERO).abs(), | ||
longAmount.min(Fixed6Lib.ZERO).abs(), | ||
shortAmount.max(Fixed6Lib.ZERO).abs(), | ||
shortAmount.min(Fixed6Lib.ZERO).abs(), | ||
protect ? 1 : 0, | ||
makerAmount.isZero() ? UFixed6Lib.ZERO : referral, | ||
makerAmount.isZero() ? referral : UFixed6Lib.ZERO | ||
); | ||
if (!isEmpty(newOrder)) newOrder.orders = 1; | ||
} | ||
|
||
/// @notice Returns whether the order increases any of the account's positions | ||
/// @return Whether the order increases any of the account's positions | ||
function increasesPosition(Order memory self) internal pure returns (bool) { | ||
|
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
andmaker
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
andtakerDelta
. I think taker and maker are used in multiInvoker here. I agree that it will be more succinct but I liketakerAmount
more thantaker
as it helps with readability and think that we should rename totakerAmount
inmultiInvoker
as well.