Skip to content
Open
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
4 changes: 2 additions & 2 deletions test/simulation/PrecompileSim.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ contract PrecompileSim {
}

if (address(this) == ACCOUNT_MARGIN_SUMMARY_PRECOMPILE_ADDRESS) {
(uint16 perp_dex_index, address user) = abi.decode(data, (uint16, address));
return abi.encode(_hyperCore.readAccountMarginSummary(perp_dex_index, user));
address user = abi.decode(data, (address));
return abi.encode(_hyperCore.readAccountMarginSummary(user));
}

return _makeRpcCall(address(this), data);
Expand Down
7 changes: 0 additions & 7 deletions test/simulation/hyper-core/CoreExecution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ contract CoreExecution is CoreView {
uint64 avgEntryPrice = _accounts[sender].positions[perpIndex].entryNtl / uint64(-szi);
int64 pnl = int64(action.sz) * (int64(avgEntryPrice) - int64(_markPx));

uint64 closedMargin =
(uint64(action.sz) * _accounts[sender].positions[perpIndex].entryNtl / uint64(-szi)) / leverage;

_accounts[sender].perpBalance = pnl > 0
? _accounts[sender].perpBalance + uint64(pnl)
: _accounts[sender].perpBalance - uint64(-pnl);
Expand All @@ -150,7 +147,6 @@ contract CoreExecution is CoreView {
: _accounts[sender].perpBalance - uint64(-pnl);

uint64 newLongSize = uint64(newSzi);
uint64 newMargin = newLongSize * _markPx / leverage;

_accounts[sender].positions[perpIndex].szi = newSzi;
_accounts[sender].positions[perpIndex].entryNtl = newLongSize * _markPx;
Expand Down Expand Up @@ -200,8 +196,6 @@ contract CoreExecution is CoreView {
if (newSzi >= 0) {
uint64 avgEntryPrice = _accounts[sender].positions[perpIndex].entryNtl / uint64(szi);
int64 pnl = int64(action.sz) * (int64(_markPx) - int64(avgEntryPrice));
uint64 closedMargin =
(uint64(action.sz) * _accounts[sender].positions[perpIndex].entryNtl / uint64(szi)) / leverage;

_accounts[sender].perpBalance = pnl > 0
? _accounts[sender].perpBalance + uint64(pnl)
Expand All @@ -217,7 +211,6 @@ contract CoreExecution is CoreView {
: _accounts[sender].perpBalance - uint64(-pnl);

uint64 newShortSize = uint64(-newSzi);
uint64 newMargin = newShortSize * _markPx / leverage;

_accounts[sender].positions[perpIndex].szi = newSzi;
_accounts[sender].positions[perpIndex].entryNtl = newShortSize * _markPx;
Expand Down
2 changes: 1 addition & 1 deletion test/simulation/hyper-core/CoreView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract CoreView is CoreState {
return _accounts[account].activated;
}

function readAccountMarginSummary(uint16 perp_dex_index, address user)
function readAccountMarginSummary(address user)
public
returns (PrecompileLib.AccountMarginSummary memory)
{
Expand Down