diff --git a/README.md b/README.md index dddff76..5bc8128 100644 --- a/README.md +++ b/README.md @@ -70,99 +70,99 @@ $ ./10_testIt.sh TokenAgentFactory Deploy TokenAgentFactory And TokenAgent - * accounts[0]->TokenAgentFactory.deploy() => 0x5FC8d326 - gasUsed: 5,069,336 0.005069336Ξ 12.67 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[0]->tokenAgentFactory.newTokenAgent() => 0x23dB4a08 - gasUsed: 187,001 0.000187001Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[1]->tokenAgentFactory.newTokenAgent() => 0x8EFa1819 - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[2]->tokenAgentFactory.newTokenAgent() => 0x6743E5c6 - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[3]->tokenAgentFactory.newTokenAgent() => 0xA14d9C7a - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[0]->TokenAgentFactory.deploy() => 0x5FC8d326 - gasUsed: 5,392,957 0.005392957Ξ 13.48 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[0]->tokenAgentFactory.newTokenAgent() => 0x23dB4a08 - gasUsed: 187,023 0.000187023Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[1]->tokenAgentFactory.newTokenAgent() => 0x8EFa1819 - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[2]->tokenAgentFactory.newTokenAgent() => 0x6743E5c6 - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[3]->tokenAgentFactory.newTokenAgent() => 0xA14d9C7a - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD Index Index by Owner tokenAgent Owner ----- -------------- ---------- ---------- 0 0 0x23dB4a08 0xf39Fd6e5 1 0 0x8EFa1819 0x70997970 2 0 0x6743E5c6 0x3C44CdDd 3 0 0xA14d9C7a 0x90F79bf6 - * now: 1:50:17 PM, expiry: 1:52:17 PM - ✔ Test TokenAgent secondary functions (784ms) + * now: 4:01:56 PM, expiry: 4:03:56 PM + ✔ Test TokenAgent secondary functions (788ms) ✔ Test TokenAgent invalid offers # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998937325079648011 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998936767562203663 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 - * offers1: [["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",0,1725853937,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]],["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",1,1725853937,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]]] - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1] - gasUsed: 471,846 0.000471846Ξ 1.18 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: BUY, expiry: 1:52:17 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: SELL, expiry: 1:52:17 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 1:52:00 PM) + * offers1: [["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",0,1725861836,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]],["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",1,1725861836,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]]] + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1] - gasUsed: 471,768 0.000471768Ξ 1.18 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: BUY, expiry: 4:03:56 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: SELL, expiry: 4:03:56 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 4:03:39 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998465478548349415 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998464999028162287 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xe7f1725E 20 BUY 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 - 1 0xe7f1725E 20 SELL 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 + 0 0xe7f1725E 20 BUY 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 + 1 0xe7f1725E 20 SELL 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 - * trades1: [[1,"104761904761904761",1,["1050000000000000000"]]] - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 142,961 0.000142961Ξ 0.36 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 1:52:01 PM) + * trades1: [[1,"104761904761904761",1,[],["1050000000000000000"]]] + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 143,385 0.000143385Ξ 0.36 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 4:03:40 PM) + erc20Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokens: 1.05) - + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, makerBuySell: SELL, prices: [0.1,0.2,0], tokenIds: [], tokenss: [1,0.05,0], price: 0.104761904761904761, timestamp: 1:52:01 PM) + + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, makerBuySell: SELL, prices: [0.1,0.2,0], tokenIds: [], tokenss: [1,0.05,0], price: 0.104761904761904761, timestamp: 4:03:40 PM) + weth.Transfer(src: 0x3C44CdDd, guy: 0x70997970, wad: 0.11) - + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 1:52:01 PM) + + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 4:03:40 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998465478548349415 100.11 998.95 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998809692289333706 99.89 1001.05 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998464999028162287 100.11 998.95 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998808802214676729 99.89 1001.05 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xe7f1725E 20 BUY 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 - 1 0xe7f1725E 20 SELL 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 1.00, 0.05, 0.00 + 0 0xe7f1725E 20 BUY 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 + 1 0xe7f1725E 20 SELL 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 1.00, 0.05, 0.00 - ✔ Test TokenAgent ERC-20 offers and trades (59ms) + ✔ Test TokenAgent ERC-20 offers and trades (58ms) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998937325079648011 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998936767562203663 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 - * offers1: ["0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,0,1725853937,4,100000000000000000,,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725853937,4,100000000000000000,4,5,6,7,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725853937,4,100000000000000000,200000000000000000,300000000000000000,400000000000000000,4,5,6,7,"] - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 447,981 0.000447981Ξ 1.12 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: BUY, expiry: 1:52:17 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 1:52:17 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [4,5,6,7], tokenss: [], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 1:52:17 PM, count: 4, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [4,5,6,7], tokenss: [], timestamp: 1:52:00 PM) + * offers1: ["0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,0,1725861836,4,100000000000000000,,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725861836,4,100000000000000000,4,5,6,7,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725861836,4,100000000000000000,200000000000000000,300000000000000000,400000000000000000,4,5,6,7,"] + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 447,809 0.000447809Ξ 1.12 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: BUY, expiry: 4:03:56 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 4:03:56 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [4,5,6,7], tokenss: [], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 4:03:56 PM, count: 4, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [4,5,6,7], tokenss: [], timestamp: 4:03:39 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998489343575221405 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998488958055283875 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0x9fE46736 721 BUY 1:52:17 PM 4 0 0.10 - 1 0x9fE46736 721 SELL 1:52:17 PM 4 0 0.10 4, 5, 6, 7 - 2 0x9fE46736 721 SELL 1:52:17 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 + 0 0x9fE46736 721 BUY 4:03:56 PM 4 0 0.10 + 1 0x9fE46736 721 SELL 4:03:56 PM 4 0 0.10 4, 5, 6, 7 + 2 0x9fE46736 721 SELL 4:03:56 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 - * trades1: [[1,"400000000000000000",1,[4,5,6,7]]] - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 165,951 0.000165951Ξ 0.41 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 1:52:01 PM) + * trades1: [[1,"400000000000000000",1,[4,5,6,7],[]]] + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 165,512 0.000165512Ξ 0.41 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 4:03:40 PM) + erc721Token.Approval(from: 0x70997970, to: 0x00000000, tokenId: 4) + erc721Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokenId: 4) + erc721Token.Approval(from: 0x70997970, to: 0x00000000, tokenId: 5) @@ -171,94 +171,94 @@ $ ./10_testIt.sh + erc721Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokenId: 6) + erc721Token.Approval(from: 0x70997970, to: 0x00000000, tokenId: 7) + erc721Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokenId: 7) - + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [4,5,6,7], tokenss: [], price: 0.4, timestamp: 1:52:01 PM) + + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [4,5,6,7], tokenss: [], price: 0.4, timestamp: 4:03:40 PM) + weth.Transfer(src: 0x3C44CdDd, guy: 0x70997970, wad: 0.4) - + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 1:52:01 PM) + + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 4:03:40 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998489343575221405 100.4 1000.0 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998786702266573606 99.6 1000.0 4, 5, 6, 7, 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998488958055283875 100.4 1000.0 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998786675192660364 99.6 1000.0 4, 5, 6, 7, 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0x9fE46736 721 BUY 1:52:17 PM 4 0 0.10 - 1 0x9fE46736 721 SELL 1:52:17 PM 0 0 0.10 4, 5, 6, 7 - 2 0x9fE46736 721 SELL 1:52:17 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 + 0 0x9fE46736 721 BUY 4:03:56 PM 4 0 0.10 + 1 0x9fE46736 721 SELL 4:03:56 PM 0 0 0.10 4, 5, 6, 7 + 2 0x9fE46736 721 SELL 4:03:56 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 - ✔ Test TokenAgent ERC-721 offers and trades (54ms) + ✔ Test TokenAgent ERC-721 offers and trades (55ms) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998937325079648011 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998936767562203663 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 - * offers1: ["0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,0,1725853937,40,100000000000000000,,","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725853937,26,100000000000000000,0,1,2,3,5,6,7,8","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725853937,40,100000000000000000,200000000000000000,300000000000000000,400000000000000000,0,1,2,3,10,10,10,10"] - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 639,126 0.000639126Ξ 1.60 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: BUY, expiry: 1:52:17 PM, count: 40, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 1:52:17 PM, count: 26, nonce: 0, prices: [0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 1:52:17 PM, count: 40, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [0,1,2,3], tokenss: [10,10,10,10], timestamp: 1:52:00 PM) + * offers1: ["0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,0,1725861836,40,100000000000000000,,","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725861836,26,100000000000000000,0,1,2,3,5,6,7,8","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725861836,40,100000000000000000,200000000000000000,300000000000000000,400000000000000000,0,1,2,3,10,10,10,10"] + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 638,954 0.000638954Ξ 1.60 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: BUY, expiry: 4:03:56 PM, count: 40, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 4:03:56 PM, count: 26, nonce: 0, prices: [0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 4:03:56 PM, count: 40, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [0,1,2,3], tokenss: [10,10,10,10], timestamp: 4:03:39 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998298198359992135 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998297812838907735 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xCf7Ed3Ac 1155 BUY 1:52:17 PM 40 0 0.10 - 1 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 26 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 - 2 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 + 0 0xCf7Ed3Ac 1155 BUY 4:03:56 PM 40 0 0.10 + 1 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 26 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 + 2 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 - * trades1: [[1,"2600000000000000000",1,[0,5,1,6,2,7,3,8]]] - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 173,977 0.000173977Ξ 0.43 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 1:52:01 PM) + * trades1: [[1,"2600000000000000000",1,[0,1,2,3],[5,6,7,8]]] + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 172,851 0.000172851Ξ 0.43 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 4:03:40 PM) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 0, tokens: 5) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 1, tokens: 6) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 2, tokens: 7) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 3, tokens: 8) - + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], price: 2.6, timestamp: 1:52:01 PM) + + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], price: 2.6, timestamp: 4:03:40 PM) + weth.Transfer(src: 0x3C44CdDd, guy: 0x70997970, wad: 2.6) - + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 1:52:01 PM) + + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 4:03:40 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998298198359992135 102.6 1000.0 4, 5, 6, 7 0:15, 1:14, 2:13, 3:12 - 2 0x3C44CdDd 9899.998778676258279912 97.4 1000.0 8, 9, 10, 11 0:35, 1:36, 2:37, 3:38 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998297812838907735 102.6 1000.0 4, 5, 6, 7 0:15, 1:14, 2:13, 3:12 + 2 0x3C44CdDd 9899.998779336185012357 97.4 1000.0 8, 9, 10, 11 0:35, 1:36, 2:37, 3:38 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xCf7Ed3Ac 1155 BUY 1:52:17 PM 40 0 0.10 - 1 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 0 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 - 2 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 - - ✔ Test TokenAgent ERC-1155 offers and trades (55ms) - - - 5 passing (983ms) - - * accounts[0]->TokenAgentFactory.deploy() => 0x5FC8d326 - gasUsed: 5,069,336 0.005069336Ξ 12.67 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[0]->tokenAgentFactory.newTokenAgent() => 0x23dB4a08 - gasUsed: 187,001 0.000187001Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[1]->tokenAgentFactory.newTokenAgent() => 0x8EFa1819 - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[2]->tokenAgentFactory.newTokenAgent() => 0x6743E5c6 - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[3]->tokenAgentFactory.newTokenAgent() => 0xA14d9C7a - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1] - gasUsed: 471,846 0.000471846Ξ 1.18 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 142,961 0.000142961Ξ 0.36 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 447,981 0.000447981Ξ 1.12 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 165,951 0.000165951Ξ 0.41 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 639,126 0.000639126Ξ 1.60 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 173,977 0.000173977Ξ 0.43 USD @ 1.0 gwei 2500.00 ETH/USD + 0 0xCf7Ed3Ac 1155 BUY 4:03:56 PM 40 0 0.10 + 1 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 0 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 + 2 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 + + ✔ Test TokenAgent ERC-1155 offers and trades (56ms) + + + 5 passing (973ms) + + * accounts[0]->TokenAgentFactory.deploy() => 0x5FC8d326 - gasUsed: 5,392,957 0.005392957Ξ 13.48 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[0]->tokenAgentFactory.newTokenAgent() => 0x23dB4a08 - gasUsed: 187,023 0.000187023Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[1]->tokenAgentFactory.newTokenAgent() => 0x8EFa1819 - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[2]->tokenAgentFactory.newTokenAgent() => 0x6743E5c6 - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[3]->tokenAgentFactory.newTokenAgent() => 0xA14d9C7a - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1] - gasUsed: 471,768 0.000471768Ξ 1.18 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 143,385 0.000143385Ξ 0.36 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 447,809 0.000447809Ξ 1.12 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 165,512 0.000165512Ξ 0.41 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 638,954 0.000638954Ξ 1.60 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 172,851 0.000172851Ξ 0.43 USD @ 1.0 gwei 2500.00 ETH/USD ```
diff --git a/contracts/TokenAgentFactory.sol b/contracts/TokenAgentFactory.sol index 20e2302..2f89884 100644 --- a/contracts/TokenAgentFactory.sol +++ b/contracts/TokenAgentFactory.sol @@ -226,6 +226,20 @@ contract Owned { owner = pendingOwner; pendingOwner = Account.wrap(address(0)); } + function recoverTokens(IERC20 token, Tokens tokens) public onlyOwner { + if (address(token) == address(0)) { + payable(msg.sender).transfer((Tokens.unwrap(tokens) == 0 ? address(this).balance : Tokens.unwrap(tokens))); + } else { + token.transfer(msg.sender, Tokens.unwrap(tokens) == 0 ? token.balanceOf(address(this)) : Tokens.unwrap(tokens)); + } + } + function recoverERC721Token(IERC721Partial token, TokenId tokenId) public onlyOwner { + token.transferFrom(address(this), msg.sender, TokenId.unwrap(tokenId)); + } + function recoverERC1155Token(IERC1155Partial token, TokenId tokenId, Tokens tokens) public onlyOwner { + token.safeTransferFrom(address(this), msg.sender, TokenId.unwrap(tokenId), Tokens.unwrap(tokens), ""); + + } } /// @notice Reentrancy guard @@ -263,25 +277,28 @@ contract TokenInfo { } } } - function _getTokenType(Token token) internal returns (TokenType _tokenType) { - _tokenType = tokenTypes[token]; - if (_tokenType == TokenType.UNKNOWN) { - if (Token.unwrap(token).code.length > 0) { - if (_supportsInterface(token, ERC721_INTERFACE)) { - _tokenType = TokenType.ERC721; - } else if (_supportsInterface(token, ERC1155_INTERFACE)) { - _tokenType = TokenType.ERC1155; + function _getTokenType(Token token) internal view returns (TokenType _tokenType) { + if (Token.unwrap(token).code.length > 0) { + if (_supportsInterface(token, ERC721_INTERFACE)) { + _tokenType = TokenType.ERC721; + } else if (_supportsInterface(token, ERC1155_INTERFACE)) { + _tokenType = TokenType.ERC1155; + } else { + if (_decimals(token) != type(uint8).max) { + _tokenType = TokenType.ERC20; } else { - if (_decimals(token) != type(uint8).max) { - _tokenType = TokenType.ERC20; - } else { - _tokenType = TokenType.INVALID; - } + _tokenType = TokenType.INVALID; } - } else { - _tokenType = TokenType.INVALID; } - tokenTypes[token] = _tokenType; + } else { + _tokenType = TokenType.INVALID; + } + } + + function getTokenTypes(Token[] memory tokens) public view returns (TokenType[] memory _tokenTypes) { + _tokenTypes = new TokenType[](tokens.length); + for (uint i = 0; i < tokens.length; i++) { + _tokenTypes[i] = _getTokenType(tokens[i]); } } } @@ -300,8 +317,6 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { } struct UpdateOffer { Index index; // 160 bits - // Token token; // 160 bits - // BuySell buySell; // 8 bits Unixtime expiry; // 40 bits Count count; // 16 bits Price[] prices; // token/WETH 18dp @@ -338,7 +353,8 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { Index index; // 32 bits Price price; // 128 bits min - ERC-20 max average when buying, min average when selling; ERC-721/1155 max total price when buying, min total price when selling Execution execution; // 8 bits - Only for ERC-20 - FILL or FILLORKILL - uint[] data; + TokenId[] tokenIds; + Tokens[] tokenss; } WETH public weth; @@ -379,9 +395,7 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { emit OffersInvalidated(nonce, Unixtime.wrap(uint40(block.timestamp))); } - receive() external payable { - } - + // AddOffer: // ERC-20 // prices[price0], tokenIds[], tokenss[] // prices[price0], tokenIds[], tokenss[tokens0, tokens1, ...] @@ -397,13 +411,17 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { function addOffers(AddOffer[] calldata inputs) external onlyOwner { for (uint i = 0; i < inputs.length; i++) { AddOffer memory input = inputs[i]; - TokenType tokenType = _getTokenType(input.token); - if (tokenType == TokenType.INVALID) { - revert InvalidToken(input.token); - } + TokenType tokenType = tokenTypes[input.token]; if (Token.unwrap(input.token) == address(weth)) { revert CannotOfferWETH(); } + if (tokenType == TokenType.UNKNOWN) { + tokenType = _getTokenType(input.token); + if (tokenType == TokenType.INVALID) { + revert InvalidToken(input.token); + } + tokenTypes[input.token] = tokenType; + } Offer storage offer = offers.push(); offer.token = input.token; offer.buySell = input.buySell; @@ -459,7 +477,7 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { } } - // TODO: Update offer.tokenIds, offer.tokenss, price, expiry? + // Cannot update token and buySell function updateOffers(UpdateOffer[] calldata inputs) external onlyOwner { for (uint i = 0; i < inputs.length; i++) { UpdateOffer memory input = inputs[i]; @@ -515,13 +533,20 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { } } + // TradeInput: + // ERC-20 + // tokenIds[], tokenss[tokens0] + // ERC-721 + // tokenIds[tokenId0, tokenId1, ...], tokenss[] + // ERC-1155 + // tokenIds[tokenId0, tokenId1, ...], tokenss[tokens0, tokens1, ...] function trade(TradeInput[] calldata inputs, bool paymentsInEth) external payable nonReentrant notOwner { uint totalEth = msg.value; if (totalEth > 0) { emit InternalTransfer(msg.sender, address(this), totalEth, Unixtime.wrap(uint40(block.timestamp))); } - uint takerToMakerTotal; - uint makerToTakerTotal; + uint takerToOwnerTotal; + uint ownerToTakerTotal; for (uint i = 0; i < inputs.length; i++) { TradeInput memory input = inputs[i]; if (Index.unwrap(input.index) >= offers.length) { @@ -540,10 +565,10 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { uint[] memory tokenIds_; uint[] memory tokenss_; if (tokenType == TokenType.ERC20) { - if (input.data.length != 1) { + if (input.tokenss.length != 1) { revert InvalidInputData("Expecting single price input"); } - uint tokens = input.data[0]; + uint tokens = uint(Tokens.unwrap(input.tokenss[0])); uint totalTokens; uint totalWETHTokens; prices_ = new uint[](offer.prices.length); @@ -572,8 +597,8 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { k++; } } - if (input.execution == Execution.FILLORKILL && totalTokens < input.data[0]) { - revert InsufficentTokensRemaining(Tokens.wrap(uint128(input.data[0])), Tokens.wrap(uint128(totalTokens))); + if (input.execution == Execution.FILLORKILL && totalTokens < uint(Tokens.unwrap(input.tokenss[0]))) { + revert InsufficentTokensRemaining(input.tokenss[0], Tokens.wrap(uint128(totalTokens))); } if (totalTokens > 0) { price = totalWETHTokens * 10**18 / totalTokens; @@ -582,40 +607,40 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { revert ExecutedAveragePriceLessThanSpecified(Price.wrap(uint128(price)), input.price); } IERC20(Token.unwrap(offer.token)).transferFrom(msg.sender, Account.unwrap(owner), totalTokens); - makerToTakerTotal += totalWETHTokens; + ownerToTakerTotal += totalWETHTokens; } else { if (price > Price.unwrap(input.price)) { revert ExecutedAveragePriceGreaterThanSpecified(Price.wrap(uint128(price)), input.price); } - takerToMakerTotal += totalWETHTokens; + takerToOwnerTotal += totalWETHTokens; IERC20(Token.unwrap(offer.token)).transferFrom(Account.unwrap(owner), msg.sender, totalTokens); } } } else if (tokenType == TokenType.ERC721) { if (Count.unwrap(offer.count) != type(uint16).max) { - if (Count.unwrap(offer.count) < input.data.length) { - revert InsufficentCountRemaining(Count.wrap(uint16(input.data.length)), offer.count); + if (Count.unwrap(offer.count) < input.tokenIds.length) { + revert InsufficentCountRemaining(Count.wrap(uint16(input.tokenIds.length)), offer.count); } - offer.count = Count.wrap(Count.unwrap(offer.count) - uint16(input.data.length)); + offer.count = Count.wrap(Count.unwrap(offer.count) - uint16(input.tokenIds.length)); } - prices_ = new uint[](input.data.length); - tokenIds_ = new uint[](input.data.length); + prices_ = new uint[](input.tokenIds.length); + tokenIds_ = new uint[](input.tokenIds.length); tokenss_ = new uint[](0); - for (uint j = 0; j < input.data.length; j++) { + for (uint j = 0; j < input.tokenIds.length; j++) { uint p; if (offer.tokenIds.length > 0) { uint k; if (offer.tokenIdType == TokenIdType.TOKENID16) { - if (input.data[j] < 2 ** 16) { - k = ArrayUtils.indexOfTokenId16s(offer.tokenId16s, TokenId16.wrap(uint16(input.data[j]))); + if (TokenId.unwrap(input.tokenIds[j]) < 2 ** 16) { + k = ArrayUtils.indexOfTokenId16s(offer.tokenId16s, TokenId16.wrap(uint16(TokenId.unwrap(input.tokenIds[j])))); } else { k = type(uint).max; } } else { - k = ArrayUtils.indexOfTokenIds(offer.tokenIds, TokenId.wrap(input.data[j])); + k = ArrayUtils.indexOfTokenIds(offer.tokenIds, input.tokenIds[j]); } if (k == type(uint).max) { - revert InvalidTokenId(TokenId.wrap(input.data[j])); + revert InvalidTokenId(input.tokenIds[j]); } if (offer.prices.length == offer.tokenIds.length) { p = Price.unwrap(offer.prices[k]); @@ -626,29 +651,32 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { p = Price.unwrap(offer.prices[0]); } prices_[j] = p; - tokenIds_[j] = input.data[j]; + tokenIds_[j] = TokenId.unwrap(input.tokenIds[j]); price += p; if (offer.buySell == BuySell.BUY) { - IERC721Partial(Token.unwrap(offer.token)).transferFrom(msg.sender, Account.unwrap(owner), input.data[j]); + IERC721Partial(Token.unwrap(offer.token)).transferFrom(msg.sender, Account.unwrap(owner), TokenId.unwrap(input.tokenIds[j])); } else { - IERC721Partial(Token.unwrap(offer.token)).transferFrom(Account.unwrap(owner), msg.sender, input.data[j]); + IERC721Partial(Token.unwrap(offer.token)).transferFrom(Account.unwrap(owner), msg.sender, TokenId.unwrap(input.tokenIds[j])); } } if (offer.buySell == BuySell.BUY) { if (price < Price.unwrap(input.price)) { revert ExecutedTotalPriceLessThanSpecified(Price.wrap(uint128(price)), input.price); } - makerToTakerTotal += price; + ownerToTakerTotal += price; } else { if (price > Price.unwrap(input.price)) { revert ExecutedTotalPriceGreaterThanSpecified(Price.wrap(uint128(price)), input.price); } - takerToMakerTotal += price; + takerToOwnerTotal += price; } } else if (tokenType == TokenType.ERC1155) { + if (input.tokenIds.length != input.tokenss.length) { + revert InvalidInputData("tokenIds must have the same length as tokenss"); + } uint totalCount; - for (uint j = 0; j < input.data.length; j += 2) { - totalCount += input.data[j+1]; + for (uint j = 0; j < input.tokenss.length; j++) { + totalCount += Tokens.unwrap(input.tokenss[j]); } if (Count.unwrap(offer.count) < totalCount) { revert InsufficentCountRemaining(Count.wrap(uint16(totalCount)), offer.count); @@ -656,32 +684,29 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { if (Count.unwrap(offer.count) != type(uint16).max) { offer.count = Count.wrap(Count.unwrap(offer.count) - uint16(totalCount)); } - prices_ = new uint[](input.data.length / 2); - tokenIds_ = new uint[](input.data.length / 2); - tokenss_ = new uint[](input.data.length / 2); - for (uint j = 0; j < input.data.length; j += 2) { - // - prices[price0], tokenIds[], tokenss[] - // - prices[price0], tokenIds[tokenId0, tokenId1, ...], tokenss[tokens0, tokens1, ...] - // - prices[price0, price1, ...], tokenIds[tokenId0, tokenId1, ...], tokenss[tokens0, tokens1, ...] + prices_ = new uint[](input.tokenIds.length); + tokenIds_ = new uint[](input.tokenIds.length); + tokenss_ = new uint[](input.tokenIds.length); + for (uint j = 0; j < input.tokenIds.length; j++) { uint p; if (offer.tokenIds.length > 0) { uint k; if (offer.tokenIdType == TokenIdType.TOKENID16) { - if (input.data[j] < 2 ** 16) { - k = ArrayUtils.indexOfTokenId16s(offer.tokenId16s, TokenId16.wrap(uint16(input.data[j]))); + if (TokenId.unwrap(input.tokenIds[j]) < 2 ** 16) { + k = ArrayUtils.indexOfTokenId16s(offer.tokenId16s, TokenId16.wrap(uint16(TokenId.unwrap(input.tokenIds[j])))); } else { k = type(uint).max; } } else { - k = ArrayUtils.indexOfTokenIds(offer.tokenIds, TokenId.wrap(input.data[j])); + k = ArrayUtils.indexOfTokenIds(offer.tokenIds, input.tokenIds[j]); } if (k == type(uint).max) { - revert InvalidTokenId(TokenId.wrap(input.data[j])); + revert InvalidTokenId(input.tokenIds[j]); } - if (Tokens.unwrap(offer.useds[k]) + uint128(input.data[j+1]) > Tokens.unwrap(offer.tokenss[k])) { - revert InsufficentCountRemaining(Count.wrap(uint16(input.data[j+1])), Count.wrap(uint16(Tokens.unwrap(offer.tokenss[k])))); + if (Tokens.unwrap(offer.useds[k]) + Tokens.unwrap(input.tokenss[j]) > Tokens.unwrap(offer.tokenss[k])) { + revert InsufficentCountRemaining(Count.wrap(uint16(Tokens.unwrap(input.tokenss[j]))), Count.wrap(uint16(Tokens.unwrap(offer.tokenss[k])))); } - offer.useds[k] = Tokens.wrap(Tokens.unwrap(offer.useds[k]) + uint128(input.data[j+1])); + offer.useds[k] = Tokens.wrap(Tokens.unwrap(offer.useds[k]) + uint128(Tokens.unwrap(input.tokenss[j]))); if (offer.prices.length == offer.tokenIds.length) { p = Price.unwrap(offer.prices[k]); } else { @@ -690,32 +715,32 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { } else { p = Price.unwrap(offer.prices[0]); } - prices_[j/2] = p; - tokenIds_[j/2] = input.data[j]; - tokenss_[j/2] = input.data[j+1]; - price += p * input.data[j+1]; + prices_[j] = p; + tokenIds_[j] = uint(TokenId.unwrap(input.tokenIds[j])); + tokenss_[j] = uint(Tokens.unwrap(input.tokenss[j])); + price += p * uint(Tokens.unwrap(input.tokenss[j])); if (offer.buySell == BuySell.BUY) { - IERC1155Partial(Token.unwrap(offer.token)).safeTransferFrom(msg.sender, Account.unwrap(owner), input.data[j], input.data[j+1], ""); + IERC1155Partial(Token.unwrap(offer.token)).safeTransferFrom(msg.sender, Account.unwrap(owner), TokenId.unwrap(input.tokenIds[j]), Tokens.unwrap(input.tokenss[j]), ""); } else { - IERC1155Partial(Token.unwrap(offer.token)).safeTransferFrom(Account.unwrap(owner), msg.sender, input.data[j], input.data[j+1], ""); + IERC1155Partial(Token.unwrap(offer.token)).safeTransferFrom(Account.unwrap(owner), msg.sender, TokenId.unwrap(input.tokenIds[j]), Tokens.unwrap(input.tokenss[j]), ""); } } if (offer.buySell == BuySell.BUY) { if (price < Price.unwrap(input.price)) { revert ExecutedTotalPriceLessThanSpecified(Price.wrap(uint128(price)), input.price); } - makerToTakerTotal += price; + ownerToTakerTotal += price; } else { if (price > Price.unwrap(input.price)) { revert ExecutedTotalPriceGreaterThanSpecified(Price.wrap(uint128(price)), input.price); } - takerToMakerTotal += price; + takerToOwnerTotal += price; } } emit Traded(input.index, Account.wrap(msg.sender), owner, offer.token, tokenType, offer.buySell, prices_, tokenIds_, tokenss_, Price.wrap(uint128(price)), Unixtime.wrap(uint40(block.timestamp))); } - if (takerToMakerTotal < makerToTakerTotal) { - uint diff = makerToTakerTotal - takerToMakerTotal; + if (takerToOwnerTotal < ownerToTakerTotal) { + uint diff = ownerToTakerTotal - takerToOwnerTotal; if (paymentsInEth) { weth.transferFrom(Account.unwrap(owner), address(this), diff); weth.withdraw(diff); @@ -724,8 +749,8 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { } else { weth.transferFrom(Account.unwrap(owner), msg.sender, diff); } - } else if (takerToMakerTotal > makerToTakerTotal){ - uint diff = takerToMakerTotal - makerToTakerTotal; + } else if (takerToOwnerTotal > ownerToTakerTotal){ + uint diff = takerToOwnerTotal - ownerToTakerTotal; if (paymentsInEth) { if (diff > totalEth) { revert InsufficentEthersRemaining(diff, totalEth); @@ -744,6 +769,9 @@ contract TokenAgent is TokenInfo, Owned, NonReentrancy { } } + receive() external payable { + } + function getOffersInfo(uint from, uint to) public view returns (OfferInfo[] memory results) { uint start = from < offers.length ? from : offers.length; uint end = to < offers.length ? to : offers.length; @@ -814,14 +842,6 @@ contract TokenAgentFactory is CloneFactory { } } - function tokenAgentsLength() public view returns (uint) { - return tokenAgentRecords.length; - } - - function tokenAgentsByOwnerLength(Account owner) public view returns (uint) { - return tokenAgentIndicesByOwners[owner].length; - } - function newTokenAgent() public { if (address(weth) == address(0)) { revert NotInitialised(); @@ -833,6 +853,12 @@ contract TokenAgentFactory is CloneFactory { emit NewTokenAgent(tokenAgent, Account.wrap(msg.sender), Index.wrap(uint32(tokenAgentRecords.length - 1)), Index.wrap(uint32(tokenAgentIndicesByOwners[Account.wrap(msg.sender)].length - 1)), Unixtime.wrap(uint40(block.timestamp))); } + function tokenAgentsLength() public view returns (uint) { + return tokenAgentRecords.length; + } + function tokenAgentsByOwnerLength(Account owner) public view returns (uint) { + return tokenAgentIndicesByOwners[owner].length; + } function getTokenAgentsInfo(uint from, uint to) public view returns (TokenAgentInfo[] memory results) { uint start = from < tokenAgentRecords.length ? from : tokenAgentRecords.length; uint end = to < tokenAgentRecords.length ? to : tokenAgentRecords.length; @@ -842,7 +868,6 @@ contract TokenAgentFactory is CloneFactory { results[k++] = TokenAgentInfo(Index.wrap(uint32(i)), tokenAgentRecords[i].indexByOwner, tokenAgentRecords[i].tokenAgent, tokenAgentRecords[i].tokenAgent.owner()); } } - function getTokenAgentsByOwnerInfo(Account owner, uint from, uint to) public view returns (TokenAgentInfo[] memory results) { Index[] memory indices = tokenAgentIndicesByOwners[owner]; uint start = from < indices.length ? from : indices.length; @@ -855,15 +880,3 @@ contract TokenAgentFactory is CloneFactory { } } } - -// ints -// 2^128 = -170, 141,183,460,469,231,731, 687,303,715,884,105,728 to 170, 141,183,460,469,231,731, 687,303,715,884,105,727 -// uints -// 2^16 = 65,536 -// 2^32 = 4,294,967,296 -// 2^40 = 1,099,511,627,776. For Unixtime, 1,099,511,627,776 seconds = 34865.285000507356672 years -// 2^48 = 281,474,976,710,656 -// 2^60 = 1, 152,921,504, 606,846,976 -// 2^64 = 18, 446,744,073,709,551,616 -// 2^128 = 340, 282,366,920,938,463,463, 374,607,431,768,211,456 -// 2^256 = 115,792, 089,237,316,195,423,570, 985,008,687,907,853,269, 984,665,640,564,039,457, 584,007,913,129,639,936 diff --git a/test/TokenAgentFactory.js b/test/TokenAgentFactory.js index d520329..8ed7552 100644 --- a/test/TokenAgentFactory.js +++ b/test/TokenAgentFactory.js @@ -344,7 +344,6 @@ describe("TokenAgentFactory", function () { it("Test TokenAgent secondary functions", async function () { const d = await loadFixture(deployContracts); - return; await expect(d.tokenAgentFactory.newTokenAgent()) .to.emit(d.tokenAgentFactory, "NewTokenAgent") .withArgs(anyValue, d.accounts[0].address, 4, 1, anyValue); @@ -365,7 +364,7 @@ describe("TokenAgentFactory", function () { await expect(tokenAgent.connect(d.accounts[1]).acceptOwnership()) .to.emit(tokenAgent, "OwnershipTransferred") .withArgs(d.accounts[0].address, d.accounts[1].address, anyValue); - // await printState(d); + expect((await tokenAgent.getTokenTypes([d.weth, d.erc20Token, d.erc721Token, d.erc1155Token, d.accounts[0]])).toString()).to.equal("1,1,2,3,4"); }); it("Test TokenAgent invalid offers", async function () { @@ -423,7 +422,7 @@ describe("TokenAgentFactory", function () { if (true) { const trades1 = [ // [indices[0], ethers.parseUnits("0.104761904761904761", 18).toString(), FILLORKILL, [ethers.parseUnits("1.05", 18).toString()]], - [indices[1], ethers.parseUnits("0.104761904761904761", 18).toString(), FILLORKILL, [ethers.parseUnits("1.05", 18).toString()]], + [indices[1], ethers.parseUnits("0.104761904761904761", 18).toString(), FILLORKILL, [], [ethers.parseUnits("1.05", 18).toString()]], ]; console.log(" * trades1: " + JSON.stringify(trades1)); const trades1Tx = await d.tokenAgents[1].connect(d.accounts[2]).trade(trades1, false, {value: ethers.parseEther("10.0")}); @@ -433,7 +432,7 @@ describe("TokenAgentFactory", function () { } if (false) { const trades2 = [ - [indices[0], ethers.parseUnits("0.209523809523809523", 18).toString(), FILLORKILL, [ethers.parseUnits("1.05", 18).toString()]], + [indices[0], ethers.parseUnits("0.209523809523809523", 18).toString(), FILLORKILL, [], [ethers.parseUnits("1.05", 18).toString()]], ]; console.log(" * trades2: " + JSON.stringify(trades2)); const trades2Tx = await d.tokenAgents[1].connect(d.accounts[2]).trade(trades2, false); @@ -481,7 +480,7 @@ describe("TokenAgentFactory", function () { if (true) { const trades1 = [ // [indices[0], ethers.parseUnits("0.4", 18).toString(), FILLORKILL, [8, 9, 10, 11]], - [indices[1], ethers.parseUnits("0.4", 18).toString(), FILLORKILL, [4, 5, 6, 7]], + [indices[1], ethers.parseUnits("0.4", 18).toString(), FILLORKILL, [4, 5, 6, 7], []], // [indices[2], ethers.parseUnits("1", 18).toString(), FILLORKILL, [4, 5, 6, 7]], ]; console.log(" * trades1: " + JSON.stringify(trades1)); @@ -530,7 +529,7 @@ describe("TokenAgentFactory", function () { // TODO: Confirm check price const trades1 = [ // [indices[0], ethers.parseUnits("0.157142857142857142", 18).toString(), FILLORKILL, [0, 9, 1, 10]], - [indices[1], ethers.parseUnits("2.6", 18).toString(), FILLORKILL, [0, 5, 1, 6, 2, 7, 3, 8]], + [indices[1], ethers.parseUnits("2.6", 18).toString(), FILLORKILL, [0, 1, 2, 3], [5, 6, 7, 8]], // [indices[2], ethers.parseUnits("7", 18).toString(), FILLORKILL, [0, 5, 1, 6, 2, 7, 3, 8]], // [indices[2], ethers.parseUnits("1", 18).toString(), FILLORKILL, [4, 5, 6, 7]], ]; diff --git a/testIt.out b/testIt.out index 536a296..4eeba63 100644 --- a/testIt.out +++ b/testIt.out @@ -2,99 +2,99 @@ TokenAgentFactory Deploy TokenAgentFactory And TokenAgent - * accounts[0]->TokenAgentFactory.deploy() => 0x5FC8d326 - gasUsed: 5,069,336 0.005069336Ξ 12.67 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[0]->tokenAgentFactory.newTokenAgent() => 0x23dB4a08 - gasUsed: 187,001 0.000187001Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[1]->tokenAgentFactory.newTokenAgent() => 0x8EFa1819 - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[2]->tokenAgentFactory.newTokenAgent() => 0x6743E5c6 - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD - * accounts[3]->tokenAgentFactory.newTokenAgent() => 0xA14d9C7a - gasUsed: 189,801 0.000189801Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[0]->TokenAgentFactory.deploy() => 0x5FC8d326 - gasUsed: 5,392,957 0.005392957Ξ 13.48 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[0]->tokenAgentFactory.newTokenAgent() => 0x23dB4a08 - gasUsed: 187,023 0.000187023Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[1]->tokenAgentFactory.newTokenAgent() => 0x8EFa1819 - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[2]->tokenAgentFactory.newTokenAgent() => 0x6743E5c6 - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD + * accounts[3]->tokenAgentFactory.newTokenAgent() => 0xA14d9C7a - gasUsed: 189,823 0.000189823Ξ 0.47 USD @ 1.0 gwei 2500.00 ETH/USD Index Index by Owner tokenAgent Owner ----- -------------- ---------- ---------- 0 0 0x23dB4a08 0xf39Fd6e5 1 0 0x8EFa1819 0x70997970 2 0 0x6743E5c6 0x3C44CdDd 3 0 0xA14d9C7a 0x90F79bf6 - * now: 1:50:17 PM, expiry: 1:52:17 PM - ✔ Test TokenAgent secondary functions (784ms) + * now: 4:01:56 PM, expiry: 4:03:56 PM + ✔ Test TokenAgent secondary functions (788ms) ✔ Test TokenAgent invalid offers # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998937325079648011 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998936767562203663 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 - * offers1: [["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",0,1725853937,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]],["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",1,1725853937,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]]] - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1] - gasUsed: 471,846 0.000471846Ξ 1.18 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: BUY, expiry: 1:52:17 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: SELL, expiry: 1:52:17 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 1:52:00 PM) + * offers1: [["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",0,1725861836,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]],["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",1,1725861836,0,["0.1","0.2","0.3"],[],["1.0","1.0","0.1"]]] + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1] - gasUsed: 471,768 0.000471768Ξ 1.18 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: BUY, expiry: 4:03:56 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, buySell: SELL, expiry: 4:03:56 PM, count: 0, nonce: 0, prices: [0.1,0.2,0.3], tokenIds: [], tokenss: [1,1,0.1], timestamp: 4:03:39 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998465478548349415 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998464999028162287 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xe7f1725E 20 BUY 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 - 1 0xe7f1725E 20 SELL 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 + 0 0xe7f1725E 20 BUY 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 + 1 0xe7f1725E 20 SELL 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 - * trades1: [[1,"104761904761904761",1,["1050000000000000000"]]] - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 142,961 0.000142961Ξ 0.36 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 1:52:01 PM) + * trades1: [[1,"104761904761904761",1,[],["1050000000000000000"]]] + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 143,385 0.000143385Ξ 0.36 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 4:03:40 PM) + erc20Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokens: 1.05) - + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, makerBuySell: SELL, prices: [0.1,0.2,0], tokenIds: [], tokenss: [1,0.05,0], price: 0.104761904761904761, timestamp: 1:52:01 PM) + + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xe7f1725E, tokenType: 20, makerBuySell: SELL, prices: [0.1,0.2,0], tokenIds: [], tokenss: [1,0.05,0], price: 0.104761904761904761, timestamp: 4:03:40 PM) + weth.Transfer(src: 0x3C44CdDd, guy: 0x70997970, wad: 0.11) - + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 1:52:01 PM) + + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 4:03:40 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998465478548349415 100.11 998.95 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998809692289333706 99.89 1001.05 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998464999028162287 100.11 998.95 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998808802214676729 99.89 1001.05 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xe7f1725E 20 BUY 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 - 1 0xe7f1725E 20 SELL 1:52:17 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 1.00, 0.05, 0.00 + 0 0xe7f1725E 20 BUY 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 0.00, 0.00, 0.00 + 1 0xe7f1725E 20 SELL 4:03:56 PM 0 0 0.10, 0.20, 0.30 1.00, 1.00, 0.10 1.00, 0.05, 0.00 - ✔ Test TokenAgent ERC-20 offers and trades (59ms) + ✔ Test TokenAgent ERC-20 offers and trades (58ms) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998937325079648011 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998936767562203663 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 - * offers1: ["0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,0,1725853937,4,100000000000000000,,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725853937,4,100000000000000000,4,5,6,7,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725853937,4,100000000000000000,200000000000000000,300000000000000000,400000000000000000,4,5,6,7,"] - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 447,981 0.000447981Ξ 1.12 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: BUY, expiry: 1:52:17 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 1:52:17 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [4,5,6,7], tokenss: [], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 1:52:17 PM, count: 4, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [4,5,6,7], tokenss: [], timestamp: 1:52:00 PM) + * offers1: ["0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,0,1725861836,4,100000000000000000,,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725861836,4,100000000000000000,4,5,6,7,","0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0,1,1725861836,4,100000000000000000,200000000000000000,300000000000000000,400000000000000000,4,5,6,7,"] + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 447,809 0.000447809Ξ 1.12 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: BUY, expiry: 4:03:56 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 4:03:56 PM, count: 4, nonce: 0, prices: [0.1], tokenIds: [4,5,6,7], tokenss: [], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, buySell: SELL, expiry: 4:03:56 PM, count: 4, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [4,5,6,7], tokenss: [], timestamp: 4:03:39 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998489343575221405 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998488958055283875 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0x9fE46736 721 BUY 1:52:17 PM 4 0 0.10 - 1 0x9fE46736 721 SELL 1:52:17 PM 4 0 0.10 4, 5, 6, 7 - 2 0x9fE46736 721 SELL 1:52:17 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 + 0 0x9fE46736 721 BUY 4:03:56 PM 4 0 0.10 + 1 0x9fE46736 721 SELL 4:03:56 PM 4 0 0.10 4, 5, 6, 7 + 2 0x9fE46736 721 SELL 4:03:56 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 - * trades1: [[1,"400000000000000000",1,[4,5,6,7]]] - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 165,951 0.000165951Ξ 0.41 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 1:52:01 PM) + * trades1: [[1,"400000000000000000",1,[4,5,6,7],[]]] + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 165,512 0.000165512Ξ 0.41 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 4:03:40 PM) + erc721Token.Approval(from: 0x70997970, to: 0x00000000, tokenId: 4) + erc721Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokenId: 4) + erc721Token.Approval(from: 0x70997970, to: 0x00000000, tokenId: 5) @@ -103,80 +103,80 @@ + erc721Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokenId: 6) + erc721Token.Approval(from: 0x70997970, to: 0x00000000, tokenId: 7) + erc721Token.Transfer(from: 0x70997970, to: 0x3C44CdDd, tokenId: 7) - + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [4,5,6,7], tokenss: [], price: 0.4, timestamp: 1:52:01 PM) + + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0x9fE46736, tokenType: 721, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [4,5,6,7], tokenss: [], price: 0.4, timestamp: 4:03:40 PM) + weth.Transfer(src: 0x3C44CdDd, guy: 0x70997970, wad: 0.4) - + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 1:52:01 PM) + + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 4:03:40 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998489343575221405 100.4 1000.0 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998786702266573606 99.6 1000.0 4, 5, 6, 7, 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998488958055283875 100.4 1000.0 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998786675192660364 99.6 1000.0 4, 5, 6, 7, 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0x9fE46736 721 BUY 1:52:17 PM 4 0 0.10 - 1 0x9fE46736 721 SELL 1:52:17 PM 0 0 0.10 4, 5, 6, 7 - 2 0x9fE46736 721 SELL 1:52:17 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 + 0 0x9fE46736 721 BUY 4:03:56 PM 4 0 0.10 + 1 0x9fE46736 721 SELL 4:03:56 PM 0 0 0.10 4, 5, 6, 7 + 2 0x9fE46736 721 SELL 4:03:56 PM 4 0 0.10, 0.20, 0.30, 0.40 4, 5, 6, 7 - ✔ Test TokenAgent ERC-721 offers and trades (54ms) + ✔ Test TokenAgent ERC-721 offers and trades (55ms) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998937325079648011 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998936767562203663 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 - * offers1: ["0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,0,1725853937,40,100000000000000000,,","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725853937,26,100000000000000000,0,1,2,3,5,6,7,8","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725853937,40,100000000000000000,200000000000000000,300000000000000000,400000000000000000,0,1,2,3,10,10,10,10"] - * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 639,126 0.000639126Ξ 1.60 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: BUY, expiry: 1:52:17 PM, count: 40, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 1:52:17 PM, count: 26, nonce: 0, prices: [0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], timestamp: 1:52:00 PM) - + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 1:52:17 PM, count: 40, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [0,1,2,3], tokenss: [10,10,10,10], timestamp: 1:52:00 PM) + * offers1: ["0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,0,1725861836,40,100000000000000000,,","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725861836,26,100000000000000000,0,1,2,3,5,6,7,8","0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,1,1725861836,40,100000000000000000,200000000000000000,300000000000000000,400000000000000000,0,1,2,3,10,10,10,10"] + * accounts[1]->tokenAgents[1].addOffers(offers1) => [0, 1, 2] - gasUsed: 638,954 0.000638954Ξ 1.60 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].Offered(index:0, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: BUY, expiry: 4:03:56 PM, count: 40, nonce: 0, prices: [0.1], tokenIds: [], tokenss: [], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:1, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 4:03:56 PM, count: 26, nonce: 0, prices: [0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], timestamp: 4:03:39 PM) + + tokenAgents[1].Offered(index:2, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, buySell: SELL, expiry: 4:03:56 PM, count: 40, nonce: 0, prices: [0.1,0.2,0.3,0.4], tokenIds: [0,1,2,3], tokenss: [10,10,10,10], timestamp: 4:03:39 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998298198359992135 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 - 2 0x3C44CdDd 9899.998952653430865096 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998297812838907735 100.0 1000.0 4, 5, 6, 7 0:20, 1:20, 2:20, 3:20 + 2 0x3C44CdDd 9899.998952187357344804 100.0 1000.0 8, 9, 10, 11 0:30, 1:30, 2:30, 3:30 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xCf7Ed3Ac 1155 BUY 1:52:17 PM 40 0 0.10 - 1 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 26 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 - 2 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 + 0 0xCf7Ed3Ac 1155 BUY 4:03:56 PM 40 0 0.10 + 1 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 26 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 + 2 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 - * trades1: [[1,"2600000000000000000",1,[0,5,1,6,2,7,3,8]]] - * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 173,977 0.000173977Ξ 0.43 USD @ 1.0 gwei 2500.00 ETH/USD - + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 1:52:01 PM) + * trades1: [[1,"2600000000000000000",1,[0,1,2,3],[5,6,7,8]]] + * accounts[2]->tokenAgents[1].trade(trades1, false) - gasUsed: 172,851 0.000172851Ξ 0.43 USD @ 1.0 gwei 2500.00 ETH/USD + + tokenAgents[1].InternalTransfer(from: 0x3C44CdDd, to: 0x8EFa1819, ethers: 10.0, timestamp: 4:03:40 PM) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 0, tokens: 5) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 1, tokens: 6) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 2, tokens: 7) + erc1155Token.TransferSingle(operator: 0x8EFa1819, from: 0x70997970, to: 0x3C44CdDd, tokenId: 3, tokens: 8) - + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], price: 2.6, timestamp: 1:52:01 PM) + + tokenAgents[1].Traded(index:1, taker: 0x3C44CdDd, maker: 0x70997970, token: 0xCf7Ed3Ac, tokenType: 1155, makerBuySell: SELL, prices: [0.1,0.1,0.1,0.1], tokenIds: [0,1,2,3], tokenss: [5,6,7,8], price: 2.6, timestamp: 4:03:40 PM) + weth.Transfer(src: 0x3C44CdDd, guy: 0x70997970, wad: 2.6) - + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 1:52:01 PM) + + tokenAgents[1].InternalTransfer(from: 0x8EFa1819, to: 0x3C44CdDd, ethers: 10.0, timestamp: 4:03:40 PM) # Account ETH WETH 0x5FbDB231 ERC-20 0xe7f1725E ERC-721 0x9fE46736 ERC-1155 0xCf7Ed3Ac --- ---------- ------------------------ ------------------------ ------------------------ ---------------------------------- ---------------------------------- - 0 0xf39Fd6e5 9899.974702365963310023 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 - 1 0x70997970 9899.998298198359992135 102.6 1000.0 4, 5, 6, 7 0:15, 1:14, 2:13, 3:12 - 2 0x3C44CdDd 9899.998778676258279912 97.4 1000.0 8, 9, 10, 11 0:35, 1:36, 2:37, 3:38 - 3 0x90F79bf6 9899.998964320233742441 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 + 0 0xf39Fd6e5 9899.973714516359711689 100.0 1000.0 0, 1, 2, 3 0:10, 1:10, 2:10, 3:10 + 1 0x70997970 9899.998297812838907735 102.6 1000.0 4, 5, 6, 7 0:15, 1:14, 2:13, 3:12 + 2 0x3C44CdDd 9899.998779336185012357 97.4 1000.0 8, 9, 10, 11 0:35, 1:36, 2:37, 3:38 + 3 0x90F79bf6 9899.99896392386904347 100.0 1000.0 12, 13, 14, 15 0:40, 1:40, 2:40, 3:40 tokenAgents[1] Offers # Token Type B/S Expiry Count Nonce Prices TokenIds Tokenss Useds --- ---------- ---- ---- ------------ ----- ----- ------------------------------ ------------------------------ ------------------------------ ------------------------------ - 0 0xCf7Ed3Ac 1155 BUY 1:52:17 PM 40 0 0.10 - 1 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 0 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 - 2 0xCf7Ed3Ac 1155 SELL 1:52:17 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 + 0 0xCf7Ed3Ac 1155 BUY 4:03:56 PM 40 0 0.10 + 1 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 0 0 0.10 0, 1, 2, 3 5, 6, 7, 8 0, 0, 0, 0 + 2 0xCf7Ed3Ac 1155 SELL 4:03:56 PM 40 0 0.10, 0.20, 0.30, 0.40 0, 1, 2, 3 10, 10, 10, 10 0, 0, 0, 0 - ✔ Test TokenAgent ERC-1155 offers and trades (55ms) + ✔ Test TokenAgent ERC-1155 offers and trades (56ms) - 5 passing (983ms) + 5 passing (973ms)