Skip to content

Commit ac15313

Browse files
committed
signed commit
1 parent b588ae4 commit ac15313

File tree

12 files changed

+44
-27
lines changed

12 files changed

+44
-27
lines changed

test/e2e/instances/setup/AdvancedSetup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const advancedSetup: TestSetupData = {
4747
tickSpacing: "396140812571321687967719751680",
4848
validationHook: "0x0000000000000000000000000000000000000000" as Address,
4949
floorPrice: "79228162514264337593543950336000",
50+
requiredCurrencyRaised: "0",
5051
},
5152

5253
additionalTokens: [

test/e2e/instances/setup/ERC20Setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const erc20Setup: TestSetupData = {
3737
tickSpacing: 100n,
3838
validationHook: "0x0000000000000000000000000000000000000000" as Address,
3939
floorPrice: "79228162514264337593543950336000",
40+
requiredCurrencyRaised: "0",
4041
},
4142

4243
additionalTokens: [

test/e2e/instances/setup/ExtendedSetup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const extendedSetup: TestSetupData = {
100100
tickSpacing: "69324642199981300000000", // From params - large value as string
101101
validationHook: "0x0000000000000000000000000000000000000000" as Address,
102102
floorPrice: "6932464219998130000000000", // 0.0000875 ETH in Q96 format
103+
requiredCurrencyRaised: "0",
103104
// Using the exact hex string from the params file
104105
auctionStepsData:
105106
"0x00000000000189c0325aa000000000010000000000001c2007a12000000000010000000000001c2007a12000000000010000000000001c200f424000000000010000000000001c200f424000000000010000000000001c200f424000000000010000000000001c202932e00000000001",

test/e2e/instances/setup/SimpleSetup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const simpleSetup: TestSetupData = {
3232
tickSpacing: 100n,
3333
validationHook: "0x0000000000000000000000000000000000000000" as Address,
3434
floorPrice: "79228162514264337593543950336000",
35+
requiredCurrencyRaised: "0",
3536
},
3637

3738
additionalTokens: [

test/e2e/instances/setup/VariationSetup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const variationSetup: TestSetupData = {
3737
tickSpacing: 100n,
3838
validationHook: "0x0000000000000000000000000000000000000000" as Address,
3939
floorPrice: 79228162514264337593543950336000n,
40+
requiredCurrencyRaised: "0",
4041
},
4142

4243
additionalTokens: [

test/e2e/schemas/TestSetupSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface AuctionParameters {
5050
tickSpacing: bigint | string;
5151
validationHook: Address;
5252
floorPrice: bigint | string;
53-
requiredCurrencyRaised?: string; // Optional: minimum currency that must be raised
53+
requiredCurrencyRaised: bigint | string;
5454
auctionStepsData?: string | StepData[]; // Optional: raw hex string or array of steps
5555
}
5656

test/e2e/src/AssertionEngine.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { Contract } from "ethers";
1313
import { TokenContract } from "./types";
1414
import { AuctionDeployer } from "./AuctionDeployer";
15-
import { ZERO_ADDRESS, LOG_PREFIXES, ERROR_MESSAGES, TYPES, TYPE_FIELD } from "./constants";
15+
import { ZERO_ADDRESS, LOG_PREFIXES, ERROR_MESSAGES, TYPES, ONE_MILLION } from "./constants";
1616
import { CheckpointStruct } from "../../../typechain-types/out/Auction";
1717
import { resolveTokenAddress } from "./utils";
1818
import hre from "hardhat";
@@ -91,12 +91,12 @@ export class AssertionEngine {
9191
// Percentage: convert to ratio and apply to expected (e.g., "5%" -> 5% of expected)
9292
const percentage = parseFloat(varianceStr.slice(0, -1));
9393
const ratio = percentage / 100;
94-
varianceAmount = (expected * BigInt(Math.floor(ratio * 1000000))) / 1000000n;
94+
varianceAmount = (expected * BigInt(Math.floor(ratio * ONE_MILLION))) / BigInt(ONE_MILLION);
9595
} else {
9696
if (varianceStr.includes(".")) {
9797
const numericValue = parseFloat(varianceStr);
9898
// Ratio: treat as percentage in decimal form (e.g., "0.05" -> 5% of expected)
99-
varianceAmount = (expected * BigInt(Math.floor(numericValue * 1000000))) / 1000000n;
99+
varianceAmount = (expected * BigInt(Math.floor(numericValue * ONE_MILLION))) / BigInt(ONE_MILLION);
100100
} else {
101101
// Raw amount: use as absolute tolerance (e.g., "100000000000000000")
102102
varianceAmount = BigInt(varianceStr);
@@ -437,13 +437,7 @@ export class AssertionEngine {
437437
return true; // No args to check, just event name match is enough
438438
}
439439
for (const [, expectedValue] of Object.entries(expectedArgs)) {
440-
let contains = false;
441-
softMatchLoop: for (let i = 0; i < actualArgs.length; i++) {
442-
if (actualArgs[i].toString() == expectedValue.toString()) {
443-
contains = true;
444-
break softMatchLoop;
445-
}
446-
}
440+
let contains = actualArgs.some((value: any) => value == expectedValue).length > 0;
447441
if (!contains) {
448442
return false;
449443
}
@@ -479,6 +473,12 @@ export class AssertionEngine {
479473
* @returns BidderState object containing address, tokenBalance, and currencyBalance
480474
*/
481475
async getBidderState(bidderAddress: Address): Promise<BidderState> {
476+
if (this.token == undefined) {
477+
throw new Error(ERROR_MESSAGES.TOKEN_UNSET);
478+
}
479+
if (this.currency === undefined) {
480+
throw new Error(ERROR_MESSAGES.CURRENCY_UNSET);
481+
}
482482
const tokenBalance = this.token ? await this.token.balanceOf(bidderAddress) : 0n;
483483
const currencyBalance = this.currency ? await this.currency.balanceOf(bidderAddress) : 0n;
484484

test/e2e/src/AuctionDeployer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ export class AuctionDeployer {
320320
typeof auctionParameters.floorPrice === "string"
321321
? BigInt(auctionParameters.floorPrice)
322322
: auctionParameters.floorPrice,
323+
requiredCurrencyRaised: auctionParameters.requiredCurrencyRaised,
323324
auctionStepsData: auctionStepsData,
324325
};
325326
}
@@ -385,7 +386,7 @@ export class AuctionDeployer {
385386
tickSpacing: config.tickSpacing,
386387
validationHook: config.validationHook,
387388
floorPrice: typeof config.floorPrice === "string" ? BigInt(config.floorPrice) : config.floorPrice,
388-
requiredCurrencyRaised: config.requiredCurrencyRaised || 0,
389+
requiredCurrencyRaised: config.requiredCurrencyRaised,
389390
auctionStepsData: config.auctionStepsData,
390391
};
391392

test/e2e/src/BidSimulator.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
UINT_48_MAX,
99
LOG_PREFIXES,
1010
ERROR_MESSAGES,
11+
ONE_MILLION,
1112
} from "./constants";
1213
import { IAllowanceTransfer } from "../../../typechain-types/test/e2e/artifacts/permit2/src/interfaces/IAllowanceTransfer";
1314
import { TransactionInfo } from "./types";
@@ -115,8 +116,8 @@ export class BidSimulator {
115116
const factor = Math.pow(recurringBid.amountFactor, i);
116117
// Use BigInt arithmetic to avoid scientific notation conversion
117118
const originalValue = BigInt(recurringBid.amount.value.toString());
118-
const factorScaled = Math.floor(factor * 1000000); // Scale factor to avoid decimals
119-
const adjustedValue = (originalValue * BigInt(factorScaled)) / BigInt(1000000);
119+
const factorScaled = Math.floor(factor * ONE_MILLION); // Scale factor to avoid decimals
120+
const adjustedValue = (originalValue * BigInt(factorScaled)) / BigInt(ONE_MILLION);
120121
adjustedAmount = {
121122
...recurringBid.amount,
122123
value: adjustedValue.toString(),
@@ -127,8 +128,8 @@ export class BidSimulator {
127128
const factor = recurringBid.priceFactor * i;
128129
// Use BigInt arithmetic to avoid scientific notation conversion
129130
const originalValue = BigInt(recurringBid.price.value.toString());
130-
const factorScaled = Math.floor(factor * 1000000); // Scale factor to avoid decimals
131-
const adjustedValue = (originalValue * BigInt(factorScaled)) / BigInt(1000000);
131+
const factorScaled = Math.floor(factor * ONE_MILLION); // Scale factor to avoid decimals
132+
const adjustedValue = (originalValue * BigInt(factorScaled)) / BigInt(ONE_MILLION);
132133
adjustedPrice = {
133134
...recurringBid.price,
134135
value: adjustedValue.toString(),
@@ -442,6 +443,8 @@ export class BidSimulator {
442443
let tx = await this.auction.getFunction("sweepUnsoldTokens").populateTransaction();
443444
let msg = ` Sweeping unsold tokens`;
444445
transactionInfos.push({ tx, from: null, msg });
446+
} else {
447+
throw new Error(ERROR_MESSAGES.INVALID_ACTION_METHOD);
445448
}
446449
}
447450
}

test/e2e/src/SingleTestRunner.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,14 @@ export class SingleTestRunner {
166166
// Don't add final state as a checkpoint - only use checkpoints from actual events
167167
// The contract only validates hints against stored checkpoints from CheckpointUpdated events
168168
let calculatedCurrencyRaised = -1;
169-
// Exit and claim all bids if auction graduated
170-
if (finalState.isGraduated) {
171-
calculatedCurrencyRaised = await this.exitAndClaimAllBids(
172-
auction,
173-
setupData,
174-
currencyToken,
175-
bidSimulator.getReverseLabelMap(),
176-
);
177-
}
169+
// Exit and claim all bids
170+
calculatedCurrencyRaised = await this.exitAndClaimAllBids(
171+
auction,
172+
setupData,
173+
currencyToken,
174+
bidSimulator.getReverseLabelMap(),
175+
finalState.isGraduated,
176+
);
178177

179178
// Log balances for all funded accounts (after claiming)
180179
await this.logAccountBalances(setupData, this.deployer, auctionedToken);
@@ -413,6 +412,7 @@ export class SingleTestRunner {
413412
setupData: TestSetupData,
414413
currencyToken: TokenContract | null,
415414
reverseLabelMap: Map<string, string>,
415+
isGraduated: boolean,
416416
): Promise<number> {
417417
let calculatedCurrencyRaised = 0;
418418
console.log("\n🎫 Exiting and claiming all bids...");
@@ -519,6 +519,10 @@ export class SingleTestRunner {
519519
calculatedCurrencyRaised += Number(bid.amount - refundAmount) / 10 ** currencyDecimals;
520520
}
521521

522+
if (!isGraduated) {
523+
continue; // Skip claiming if auction didn't graduate
524+
}
525+
522526
// Claim all tokens in batch
523527
const unfilteredBidIds = bids.map((b) => b.bidId);
524528
const bidIds = unfilteredBidIds.filter((bidId) => shouldClaimBid.get(bidId));

0 commit comments

Comments
 (0)