@@ -202,45 +202,64 @@ describe("SwapAndPlaceERC1155BuyOrder Integration Test", function () {
202202 recipient : deployer . address ,
203203 } ;
204204
205- console . log ( "\n=== BUY ORDER (ERC1155) INPUTS ===" ) ;
206- console . log ( "TokenIn:" , params . tokenIn ) ;
207- console . log ( "erc1155TokenAddress:" , params . erc1155TokenAddress ) ;
208- console . log ( "erc1155TokenId:" , params . erc1155TokenId . toString ( ) ) ;
209- console . log ( "category:" , params . category . toString ( ) ) ;
210- console . log ( "priceInWei (GHST) :" , ethers . utils . formatEther ( priceInWei ) ) ;
211- console . log ( "quantity :" , quantity . toString ( ) ) ;
212- console . log ( "duration :" , duration . toString ( ) ) ;
213- console . log ( "recipient :" , params . recipient ) ;
205+ console . log ( "\n" + "=" . repeat ( 60 ) ) ;
206+ console . log ( "🔄 SWAP AND PLACE ERC1155 BUY ORDER TEST" ) ;
207+ console . log ( "=" . repeat ( 60 ) ) ;
208+
209+ console . log ( "\n📋 ORDER PARAMETERS:" ) ;
210+ console . log ( "┌─ TokenIn :" , params . tokenIn ) ;
211+ console . log ( "├─ ERC1155 Token Address :" , params . erc1155TokenAddress ) ;
212+ console . log ( "├─ ERC1155 Token ID :" , params . erc1155TokenId . toString ( ) ) ;
213+ console . log ( "├─ Category :" , params . category . toString ( ) ) ;
214214 console . log (
215- "swapAmount (USDC):" ,
215+ "├─ Price per Unit (GHST):" ,
216+ ethers . utils . formatEther ( priceInWei )
217+ ) ;
218+ console . log ( "├─ Quantity:" , quantity . toString ( ) ) ;
219+ console . log ( "├─ Total Cost (GHST):" , ethers . utils . formatEther ( totalCost ) ) ;
220+ console . log ( "├─ Duration:" , duration . toString ( ) ) ;
221+ console . log ( "├─ Recipient:" , params . recipient ) ;
222+ console . log (
223+ "├─ Swap Amount (USDC):" ,
216224 ethers . utils . formatUnits ( params . swapAmount , 6 )
217225 ) ;
218226 console . log (
219- "minGhstOut ( GHST) :" ,
227+ "├─ Min GHST Out :" ,
220228 ethers . utils . formatEther ( params . minGhstOut )
221229 ) ;
222- console . log ( "deadline:" , params . swapDeadline ) ;
230+ console . log ( "└─ Deadline:" , params . swapDeadline ) ;
231+
232+ console . log ( "\n💰 BALANCES (BEFORE):" ) ;
223233 console . log (
224- "USDC balance (before) :" ,
234+ "┌─ User USDC Balance :" ,
225235 ethers . utils . formatUnits ( initialUsdcBalance , 6 )
226236 ) ;
237+ console . log (
238+ "└─ Diamond GHST Balance:" ,
239+ ethers . utils . formatEther ( initialDiamondGhst )
240+ ) ;
227241
228242 const tx = await buyOrderSwapFacet
229243 . connect ( deployer )
230244 . swapAndPlaceERC1155BuyOrder ( params ) ;
231245 const receipt = await tx . wait ( ) ;
232246
233247 const diamondGhstAfter = await ghstToken . balanceOf ( ADDRESSES . DIAMOND ) ;
248+
249+ console . log ( "\n🔄 TRANSACTION EXECUTED" ) ;
250+ console . log ( "└─ Transaction Hash:" , tx . hash ) ;
251+
252+ console . log ( "\n💰 BALANCES (AFTER):" ) ;
234253 console . log (
235- "Diamond GHST before :" ,
254+ "┌─ Diamond GHST Before :" ,
236255 ethers . utils . formatEther ( initialDiamondGhst )
237256 ) ;
238257 console . log (
239- "Diamond GHST after :" ,
258+ "├─ Diamond GHST After :" ,
240259 ethers . utils . formatEther ( diamondGhstAfter )
241260 ) ;
242261 console . log (
243- "Diamond GHST delta (order funded ):" ,
262+ "└─ Diamond GHST Delta (Order Funded ):" ,
244263 ethers . utils . formatEther ( diamondGhstAfter . sub ( initialDiamondGhst ) )
245264 ) ;
246265
@@ -255,14 +274,12 @@ describe("SwapAndPlaceERC1155BuyOrder Integration Test", function () {
255274 swapEvt . data ,
256275 swapEvt . topics
257276 ) ;
277+ console . log ( "\n🔄 SWAP RESULTS:" ) ;
258278 console . log (
259- "GHST received from swap :" ,
279+ "┌─ GHST Received from Swap :" ,
260280 ethers . utils . formatEther ( decodedSwap . ghstReceived )
261281 ) ;
262- console . log (
263- "BuyOrderId (from swap evt):" ,
264- decodedSwap . buyOrderId . toString ( )
265- ) ;
282+ console . log ( "└─ Buy Order ID:" , decodedSwap . buyOrderId . toString ( ) ) ;
266283
267284 // Parse last GHST Transfer (refund) from receipt logs
268285 const erc20Iface = new ethers . utils . Interface ( [
@@ -282,8 +299,9 @@ describe("SwapAndPlaceERC1155BuyOrder Integration Test", function () {
282299 lastGhstLog . topics
283300 ) ;
284301 const refundAmount = parsed . value as BigNumber ;
302+ console . log ( "\n💸 REFUND DETAILS:" ) ;
285303 console . log (
286- "Refunded GHST (from diamond to recipient ):" ,
304+ "└─ Refunded GHST (Diamond → Recipient ):" ,
287305 ethers . utils . formatEther ( refundAmount )
288306 ) ;
289307 // refund should equal ghstReceived - totalCost
@@ -312,13 +330,29 @@ describe("SwapAndPlaceERC1155BuyOrder Integration Test", function () {
312330 expect ( decoded . priceInWei ) . to . equal ( priceInWei ) ;
313331 expect ( decoded . quantity ) . to . equal ( quantity ) ;
314332
315- //diamond retains GHST for the order
316-
317333 const finalDiamondGhst = await ghstToken . balanceOf ( ADDRESSES . DIAMOND ) ;
334+ const finalUsdcBalance = await usdcToken . balanceOf ( deployer . address ) ;
335+
336+ console . log ( "\n✅ FINAL VERIFICATION:" ) ;
337+ console . log (
338+ "┌─ Final Diamond GHST:" ,
339+ ethers . utils . formatEther ( finalDiamondGhst )
340+ ) ;
341+ console . log (
342+ "├─ Final User USDC:" ,
343+ ethers . utils . formatUnits ( finalUsdcBalance , 6 )
344+ ) ;
345+ console . log (
346+ "├─ Diamond GHST Retained:" ,
347+ ethers . utils . formatEther ( finalDiamondGhst . sub ( initialDiamondGhst ) )
348+ ) ;
349+ console . log (
350+ "└─ USDC Spent:" ,
351+ ethers . utils . formatUnits ( initialUsdcBalance . sub ( finalUsdcBalance ) , 6 )
352+ ) ;
353+
318354 // diamond retains GHST equal to order total cost
319355 expect ( finalDiamondGhst . sub ( initialDiamondGhst ) ) . to . equal ( totalCost ) ;
320-
321- const finalUsdcBalance = await usdcToken . balanceOf ( deployer . address ) ;
322356 expect ( finalUsdcBalance ) . to . be . lt ( initialUsdcBalance ) ;
323357
324358 // Validate the swap event emitted by BuyOrderSwapFacet
0 commit comments