Skip to content

Commit

Permalink
✅ Add interface to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBorders committed Dec 5, 2023
1 parent 32d3793 commit 543a34c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 5 deletions.
3 changes: 2 additions & 1 deletion test/AsyncOrder.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.20;

import {Bootstrap, IPerpsMarketProxy} from "test/utils/Bootstrap.sol";
import {Bootstrap} from "test/utils/Bootstrap.sol";
import {IPerpsMarketProxy} from "src/interfaces/synthetix/IPerpsMarketProxy.sol";
import {SynthetixMock} from "test/utils/mocks/SynthetixMock.sol";

contract AsyncOrderTest is Bootstrap, SynthetixMock {
Expand Down
3 changes: 2 additions & 1 deletion test/ConditionalOrder.t.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.20;

import {Bootstrap, IPerpsMarketProxy} from "test/utils/Bootstrap.sol";
import {Bootstrap} from "test/utils/Bootstrap.sol";
import {ConditionalOrderSignature} from
"test/utils/ConditionalOrderSignature.sol";
import {IEngine} from "src/interfaces/IEngine.sol";
import {IPerpsMarketProxy} from "src/interfaces/synthetix/IPerpsMarketProxy.sol";
import {PythMock} from "test/utils/mocks/PythMock.sol";
import {SynthetixMock} from "test/utils/mocks/SynthetixMock.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/utils/Bootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Setup
} from "script/Deploy.s.sol";
import {IERC20} from "src/interfaces/tokens/IERC20.sol";
import {IPerpsMarketProxy} from "src/interfaces/synthetix/IPerpsMarketProxy.sol";
import {IPerpsMarketProxy} from "test/utils/interfaces/IPerpsMarketProxy.sol";
import {ISpotMarketProxy} from "src/interfaces/synthetix/ISpotMarketProxy.sol";
import {IPyth} from "src/interfaces/oracles/IPyth.sol";
import {SynthMinter} from "test/utils/SynthMinter.sol";
Expand Down
88 changes: 88 additions & 0 deletions test/utils/interfaces/IPerpsMarketProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.20;

interface IPerpsMarketProxy {
function createAccount() external returns (uint128 accountId);

function getAccountOwner(uint128 accountId)
external
view
returns (address owner);

function grantPermission(
uint128 accountId,
bytes32 permission,
address user
) external;

function hasPermission(uint128 accountId, bytes32 permission, address user)
external
view
returns (bool hasPermission);

function isAuthorized(uint128 accountId, bytes32 permission, address target)
external
view
returns (bool isAuthorized);

struct Data {
uint256 settlementTime;
OrderCommitmentRequest request;
}

struct OrderCommitmentRequest {
uint128 marketId;
uint128 accountId;
int128 sizeDelta;
uint128 settlementStrategyId;
uint256 acceptablePrice;
bytes32 trackingCode;
address referrer;
}

function commitOrder(OrderCommitmentRequest memory commitment)
external
returns (Data memory retOrder, uint256 fees);

function requiredMarginForOrder(
uint128 accountId,
uint128 marketId,
int128 sizeDelta
) external view returns (uint256 requiredMargin);

function computeOrderFees(uint128 marketId, int128 sizeDelta)
external
view
returns (uint256 orderFees, uint256 fillPrice);

function modifyCollateral(
uint128 accountId,
uint128 synthMarketId,
int256 amountDelta
) external;

function getCollateralAmount(uint128 accountId, uint128 synthMarketId)
external
view
returns (uint256);

function totalCollateralValue(uint128 accountId)
external
view
returns (uint256);

function getOpenPosition(uint128 accountId, uint128 marketId)
external
view
returns (int256 totalPnl, int256 accruedFunding, int128 positionSize);

function getAvailableMargin(uint128 accountId)
external
view
returns (int256 availableMargin);

function getMaxMarketSize(uint128 marketId)
external
view
returns (uint256 maxMarketSize);
}
3 changes: 1 addition & 2 deletions test/utils/mocks/SynthetixMock.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.20;

import {EIP7412} from "src/utils/EIP7412.sol";
import {IPerpsMarketProxy} from "src/interfaces/synthetix/IPerpsMarketProxy.sol";
import {IPerpsMarketProxy} from "test/utils/interfaces/IPerpsMarketProxy.sol";
import {Test} from "lib/forge-std/src/Test.sol";

contract SynthetixMock is Test {
Expand Down

0 comments on commit 543a34c

Please sign in to comment.