Skip to content

Commit

Permalink
upgrading hardhat
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Oct 10, 2024
1 parent ad43b9f commit 4cfbf4d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 46 deletions.
81 changes: 43 additions & 38 deletions test/helpers/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,7 @@ class Data {
// console.log("this.contracts: " + JSON.stringify(this.contracts, null, 2));
receipt.logs.forEach((log) => {
// console.log("log.address: " + log.address);
if (log.address == this.token0.target) {
// console.log("token0: " + this.token0.target);
const event = this.token0.interface.parseLog(log);
if (event.name == "Transfer") {
const [from, to, tokens] = event.args;
console.log(" + " + this.getShortAccountName(log.address) + " " + event.name + "(" +
"from: " + this.getShortAccountName(from) +
", to: " + this.getShortAccountName(to) +
", tokens: " + ethers.formatUnits(tokens, this.decimals0) + ")"
);
} else if (event.name == "Approval") {
const [owner, spender, tokens] = event.args;
console.log(" + " + this.getShortAccountName(log.address) + " " + event.name + "(" +
"owner: " + this.getShortAccountName(owner) +
", spender: " + this.getShortAccountName(spender) +
", tokens: " + ethers.formatUnits(tokens, this.decimals0) + ")"
);
}
// console.log("event.args: " + JSON.stringify(event.args));
} else if (log.address == this.token1.target) {
const event = this.token1.interface.parseLog(log);
if (event.name == "Transfer") {
const [from, to, tokens] = event.args;
console.log(" + " + this.getShortAccountName(log.address) + " " + event.name + "(" +
"from: " + this.getShortAccountName(from) +
", to: " + this.getShortAccountName(to) +
", tokens: " + ethers.formatUnits(tokens, this.decimals0) + ")"
);
} else if (event.name == "Approval") {
const [owner, spender, tokens] = event.args;
console.log(" + " + this.getShortAccountName(log.address) + " " + event.name + "(" +
"owner: " + this.getShortAccountName(owner) +
", spender: " + this.getShortAccountName(spender) +
", tokens: " + ethers.formatUnits(tokens, this.decimals0) + ")"
);
}
} else if (log.address == this.weth.target) {
if (log.address == this.token0.target || log.address == this.token1.target || log.address == this.weth.target) {
// console.log("weth: " + this.token0.target);
const event = this.weth.interface.parseLog(log);
if (event.name == "Transfer") {
Expand Down Expand Up @@ -156,7 +120,48 @@ class Data {
}
} else if (log.address == this.chadex.target) {
const event = this.chadex.interface.parseLog(log);
console.log(" + CHADEX " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
// event OrderRemoved(PairKey indexed pairKey, OrderKey indexed orderKey, Account indexed maker, BuySell buySell, Price price, Tokens baseTokens, Unixtime timestamp);
// event OrderUpdated(PairKey indexed pairKey, OrderKey indexed orderKey, Account indexed maker, BuySell buySell, Price price, Unixtime expiry, Tokens baseTokens, Unixtime timestamp);
// event Trade(TradeResult tradeResult);
// event TradeSummary(PairKey indexed pairKey, Account indexed taker, BuySell buySell, Price price, Tokens baseTokens, Tokens quoteTokens, Tokens tokensOnOrder, Unixtime timestamp);
// event Message(address indexed from, address indexed to, bytes32 indexed pairKey, bytes32 orderKey, string topic, string text, Unixtime timestamp);
if (event.name == "PairAdded") {
// event PairAdded(PairKey indexed pairKey, Account maker, Token indexed base, Token indexed quote, Decimals[2] decimalss, Unixtime timestamp);
const [pairKey, maker, base, quote, decimalss, timestamp] = event.args;
console.log(" + " + this.getShortAccountName(log.address) + " " + event.name + "(" +
"pairKey: " + pairKey.substring(0, 20) +
", maker: " + this.getShortAccountName(maker) +
", base: " + this.getShortAccountName(base) +
", quote: " + this.getShortAccountName(quote) +
", decimalss: " + JSON.stringify(decimalss.map(e => parseInt(e))) +
", timestamp: " + timestamp + ")"
);
} else if (event.name == "OrderAdded") {
// event OrderAdded(PairKey indexed pairKey, OrderKey indexed orderKey, Account indexed maker, BuySell buySell, Price price, Unixtime expiry, Tokens baseTokens, Tokens quoteTokens, Unixtime timestamp);
const [pairKey, orderKey, maker, buySell, price, expiry, baseTokens, quoteTokens, timestamp] = event.args;
console.log(" + " + this.getShortAccountName(log.address) + " " + event.name + "(" +
"pairKey: " + pairKey.substring(0, 20) +
", orderKey: " + orderKey.substring(0, 20) +
", maker: " + this.getShortAccountName(maker) +
", buySell: " + buySell +
", price: " + price.toString() +
", expiry: " + expiry +
", baseTokens: " + baseTokens +
", quoteTokens: " + quoteTokens +
", timestamp: " + timestamp + ")"
);
console.log(" + CHADEX.OrderAdded " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
} else if (event.name == "OrderRemoved") {
console.log(" + CHADEX.OrderRemoved " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
} else if (event.name == "OrderUpdated") {
console.log(" + CHADEX.OrderUpdated " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
} else if (event.name == "Trade") {
console.log(" + CHADEX.Trade " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
} else if (event.name == "TradeSummary") {
console.log(" + CHADEX.TradeSummary " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
} else if (event.name == "Message") {
console.log(" + CHADEX.Message " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
}
} else {
console.log(" + " + this.getShortAccountName(log.address) + " " + JSON.stringify(log.topics));
}
Expand Down
19 changes: 11 additions & 8 deletions testIt.out
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
],
"price": "690100000",
"targetPrice": "690100000",
"expiry": 1728551453,
"expiry": 1728552736,
"tokens": "1000000000000000000",
"skipCheck": false
},
Expand All @@ -85,7 +85,7 @@
],
"price": "690200000",
"targetPrice": "690200000",
"expiry": 1728551453,
"expiry": 1728552736,
"tokens": "2000000000000000000",
"skipCheck": false
},
Expand All @@ -98,18 +98,21 @@
],
"price": "690300000",
"targetPrice": "690300000",
"expiry": 1728551453,
"expiry": 1728552736,
"tokens": "3000000000000000000",
"skipCheck": false
}
]
> user0->chadex.execute(actionsA) - gasUsed: 620494 ~ ETH 0.00620494 ~ USD 15
+ CHADEX Chadex:0xCf7E ["0xf22d70a8ebd78c56629182f34470e7b55c3b5b82766457d1b398c9bca2a9b17c","0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2","0x0000000000000000000000005fbdb2315678afecb367f032d93f642f64180aa3","0x0000000000000000000000009fe46736679d2d9a65f0992f2272de9f3c7fa6e0"]
+ CHADEX Chadex:0xCf7E ["0x6b1f92adce775bf96605560854f4155222863d3da4ca154334b48838fbeff55e","0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2","0xba50bff8ca4fde497871699eeb406f4cbadb4501c87b7dffb82bd406d51af64f","0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"]
+ CHADEX Chadex:0xCf7E ["0x6b1f92adce775bf96605560854f4155222863d3da4ca154334b48838fbeff55e","0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2","0x16ee2eb820c1dc86c5312b30df62429a70bf02e7ad9502c64f1bf72332f2d52c","0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"]
+ CHADEX Chadex:0xCf7E ["0x6b1f92adce775bf96605560854f4155222863d3da4ca154334b48838fbeff55e","0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2","0x216071ecd309e02f0a7c41a681f63c840beb698b2aedb288198fa4cb3667138e","0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"]
+ Chadex:0xCf7E PairAdded(pairKey: 0x2c831da670a13afa44, maker: user0:0x7099, base: Token0:0x5FbD, quote: WETH:0x9fE4, decimalss: [18,18], timestamp: 1728549165)
+ Chadex:0xCf7E OrderAdded(pairKey: 0x2c831da670a13afa44, orderKey: 0xba50bff8ca4fde4978, maker: user0:0x7099, buySell: 0, price: 690100000, expiry: 1728552736, baseTokens: 1000000000000000000, quoteTokens: 690100000000000000, timestamp: 1728549165)
+ CHADEX.OrderAdded Chadex:0xCf7E ["0x6b1f92adce775bf96605560854f4155222863d3da4ca154334b48838fbeff55e","0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2","0xba50bff8ca4fde497871699eeb406f4cbadb4501c87b7dffb82bd406d51af64f","0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"]
+ Chadex:0xCf7E OrderAdded(pairKey: 0x2c831da670a13afa44, orderKey: 0x16ee2eb820c1dc86c5, maker: user0:0x7099, buySell: 0, price: 690200000, expiry: 1728552736, baseTokens: 2000000000000000000, quoteTokens: 1380400000000000000, timestamp: 1728549165)
+ CHADEX.OrderAdded Chadex:0xCf7E ["0x6b1f92adce775bf96605560854f4155222863d3da4ca154334b48838fbeff55e","0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2","0x16ee2eb820c1dc86c5312b30df62429a70bf02e7ad9502c64f1bf72332f2d52c","0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"]
+ Chadex:0xCf7E OrderAdded(pairKey: 0x2c831da670a13afa44, orderKey: 0x216071ecd309e02f0a, maker: user0:0x7099, buySell: 0, price: 690300000, expiry: 1728552736, baseTokens: 3000000000000000000, quoteTokens: 2070900000000000000, timestamp: 1728549165)
+ CHADEX.OrderAdded Chadex:0xCf7E ["0x6b1f92adce775bf96605560854f4155222863d3da4ca154334b48838fbeff55e","0x2c831da670a13afa44000f723f930fbd31948192e5612f758ae2cfaeee460dc2","0x216071ecd309e02f0a7c41a681f63c840beb698b2aedb288198fa4cb3667138e","0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"]
✔ 00. Test 00


1 passing (492ms)
1 passing (487ms)

0 comments on commit 4cfbf4d

Please sign in to comment.