Skip to content

Commit

Permalink
remove expectIntentEq
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekdefi committed Oct 14, 2024
1 parent 55cc497 commit 78a6133
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 67 deletions.
19 changes: 0 additions & 19 deletions packages/common/testutil/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,25 +165,6 @@ export interface SettlementContext {
orderOracleVersion: OracleVersion
}

export interface Common {
account: string
signer: string
domain: string
nonce: BigNumberish
group: BigNumberish
expiry: BigNumberish
}

export interface Intent {
amount: BigNumberish
price: BigNumberish
fee: BigNumberish
originator: string
solver: string
collateralization: BigNumberish
common: Common
}

export function expectCheckpointEq(a: Checkpoint, b: Checkpoint): void {
expect(a.tradeFee).to.equal(b.tradeFee, 'Checkpoint:TradeFee')
expect(a.settlementFee).to.equal(b.settlementFee, 'Checkpoint:SettlementFee')
Expand Down
2 changes: 0 additions & 2 deletions packages/perennial/test/integration/core/fees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
PositionProcessedEventObject,
} from '../../../types/generated/contracts/Market'
import { impersonateWithBalance } from '../../../../common/testutil/impersonate'
import { expectIntentEq } from '../../unit/market/Market.test'
import { Verifier__factory } from '../../../../perennial-verifier/types/generated'
import { signIntent } from '../../../../perennial-verifier/test/helpers/erc712'

Expand Down Expand Up @@ -2494,7 +2493,6 @@ describe('Fees', () => {
await market.settle(userC.address)
await market.settle(userD.address)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 1,
Expand Down
46 changes: 0 additions & 46 deletions packages/perennial/test/unit/market/Market.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
DEFAULT_GUARANTEE,
DEFAULT_ORACLE_RECEIPT,
expectGuaranteeEq,
Intent,
} from '../../../../common/testutil/types'
import {
IMarket,
Expand All @@ -54,8 +53,6 @@ import {
RiskParameterStruct,
} from '../../../types/generated/contracts/Market'

import { parse } from 'path'

const { ethers } = HRE

const POSITION = parse6decimal('10.000')
Expand Down Expand Up @@ -20622,7 +20619,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 1,
Expand Down Expand Up @@ -20869,7 +20865,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 1,
Expand Down Expand Up @@ -21116,7 +21111,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 1,
Expand Down Expand Up @@ -21362,7 +21356,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 1,
Expand Down Expand Up @@ -21957,7 +21950,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 1,
Expand Down Expand Up @@ -22253,8 +22245,6 @@ describe('Market', () => {
await settle(market, user)
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
})

it('opens long position and fills another long position and settles later with fee (above/long)', async () => {
Expand Down Expand Up @@ -22407,7 +22397,6 @@ describe('Market', () => {
const expectedLongInterest = expectedInterest.mul(3).div(4)
const expectedFundingFee = BigNumber.from(3320)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 1,
Expand Down Expand Up @@ -22688,7 +22677,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 2,
Expand Down Expand Up @@ -22950,7 +22938,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 2,
Expand Down Expand Up @@ -23212,7 +23199,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 2,
Expand Down Expand Up @@ -23475,7 +23461,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 2,
Expand Down Expand Up @@ -23744,7 +23729,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 2,
Expand Down Expand Up @@ -24013,7 +23997,6 @@ describe('Market', () => {
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
expectLocalEq(await market.locals(user.address), {
...DEFAULT_LOCAL,
currentId: 2,
Expand Down Expand Up @@ -24325,8 +24308,6 @@ describe('Market', () => {
await settle(market, user)
await settle(market, userB)
await settle(market, userC)

expectIntentEq(intent, user.address, userC.address, market)
})
})

Expand Down Expand Up @@ -24967,30 +24948,3 @@ describe('Market', () => {
})
})
})

export async function expectIntentEq(intent: Intent, taker: string, maker: string, market: Market) {
const takerPosition = await market.positions(taker)
const takerLong = takerPosition.long
const takerShort = takerPosition.short

const makerPosition = await market.positions(maker)
const makerLong = makerPosition.long
const makerShort = makerPosition.short

const takerOrder = await market.pendingOrders(taker, (await market.locals(taker)).latestId)
const makerOrder = await market.pendingOrders(maker, (await market.locals(maker)).latestId)

expect(takerOrder.longPos).to.equal(takerLong, 'Order:LongPos')
expect(takerOrder.shortPos).to.equal(takerShort, 'Order:ShortPos')

expect(makerOrder.longPos).to.equal(makerLong, 'Order:LongPos')
expect(makerOrder.shortPos).to.equal(makerShort, 'Order:ShortPos')

if (intent.amount > 0) {
expect(intent.amount).to.equal(takerLong, 'Intent:Amount')
expect(intent.amount).to.equal(makerShort, 'Intent:Amount')
} else {
expect(intent.amount).to.equal(takerShort, 'Intent:Amount')
expect(intent.amount).to.equal(makerLong, 'Intent:Amount')
}
}

0 comments on commit 78a6133

Please sign in to comment.