diff --git a/app/src/src/app/slice/orderList.js b/app/src/src/app/slice/orderList.js index 8a37243..3705da0 100644 --- a/app/src/src/app/slice/orderList.js +++ b/app/src/src/app/slice/orderList.js @@ -15,11 +15,14 @@ export const orderListSlice = createSlice({ addOrder: (state, action) => { state.push(action.payload); return state; + }, + removeOrder: (state, action) => { + return state.filter(item => item._id !== action.payload) } }, }); // Action creators are generated for each case reducer function -export const { setOrderList, addOrder } = orderListSlice.actions; +export const { setOrderList, addOrder, removeOrder } = orderListSlice.actions; export default orderListSlice.reducer; diff --git a/app/src/src/components/OrderList/index.jsx b/app/src/src/components/OrderList/index.jsx index b4ee8b1..54b5f88 100644 --- a/app/src/src/components/OrderList/index.jsx +++ b/app/src/src/components/OrderList/index.jsx @@ -1,10 +1,14 @@ import { useEffect, useState } from 'react'; import styles from './styles.module.scss'; import { formatUnits } from '../../utils/token'; -import { getMakerOrders } from '../../api/order.api'; +import { getMakerOrders, getTakerOrders } from '../../api/order.api'; import { TOKEN_SYMBOL } from '../../constants/index'; import { useSelector, useDispatch } from 'react-redux'; -import { setOrderList } from '../../app/slice/orderList'; +import { setOrderList, removeOrder } from '../../app/slice/orderList'; +import { approveERC20, checkAllowance } from '../../utils/erc20'; +import { fillOrder } from '../../utils/fillOrder'; +import { AUGUSTUS_ADDRESS } from '../../constants/order'; +import toast from '../../utils/toast'; export default function OrderList() { const account = useSelector((state) => state.account); @@ -26,7 +30,8 @@ export default function OrderList() { break; } case 1: { - dispatch(setOrderList([])); + const { data } = await getTakerOrders(account); + dispatch(setOrderList(data)); break; } case 2: { @@ -36,6 +41,33 @@ export default function OrderList() { } }; + const handleFillOrder = async (order) => { + try { + const args = { + nonceAndMeta: order.nonceAndMeta, + expiry: order.expiry, + makerAsset: order.makerAsset, + takerAsset: order.takerAsset, + maker: order.maker, + taker: order.taker, + makerAmount: order.makerAmount, + takerAmount: order.takerAmount, + }; + + const isAllowance = await checkAllowance(args.takerAsset, AUGUSTUS_ADDRESS, args.taker, args.takerAmount); + if (!isAllowance) { + await approveERC20(args.takerAsset, AUGUSTUS_ADDRESS); + } + + await fillOrder(args, order.signature); + dispatch(removeOrder(order._id)); + toast.success('Fill order successfully'); + } catch (error) { + console.log('error', error); + toast.error('An error has been occur'); + } + }; + useEffect(() => { if (account) { getOrderList(tab); @@ -69,6 +101,11 @@ export default function OrderList() { Expiry + {tab === 1 && ( + + Action + + )} @@ -81,6 +118,13 @@ export default function OrderList() { {formatUnits(item.makerAmount)} {formatUnits(item.takerAmount)} {item.expiry !== 0 ? getExpiry(item.expiry) : 'Never'} + {tab === 1 && ( + + + + )} ))} diff --git a/app/src/src/components/OrderList/styles.module.scss b/app/src/src/components/OrderList/styles.module.scss index 4a93b01..532caf7 100644 --- a/app/src/src/components/OrderList/styles.module.scss +++ b/app/src/src/components/OrderList/styles.module.scss @@ -41,7 +41,16 @@ } .textCenter { - text-align: center; + text-align: center; + } + + .fillBtn { + background-color: #2669f5; + width: 100%; + height: 40px; + color: #fff; + outline: none; + font-weight: bold; } } } diff --git a/app/src/src/components/Swap/index.jsx b/app/src/src/components/Swap/index.jsx index 7d0055a..466cb3f 100644 --- a/app/src/src/components/Swap/index.jsx +++ b/app/src/src/components/Swap/index.jsx @@ -11,6 +11,8 @@ import { createOrder } from '../../api/order.api'; import ReactLoading from 'react-loading'; import toast from '../../utils/toast'; import { addOrder } from '../../app/slice/orderList'; +import { approveERC20, checkAllowance } from '../../utils/erc20'; +import { AUGUSTUS_ADDRESS } from '../../constants/order'; export default function Swap() { const account = useSelector((state) => state.account); @@ -23,7 +25,7 @@ export default function Swap() { const [fromToken, setFromToken] = useState({ img: 'https://icons.iconarchive.com/icons/cjdowner/cryptocurrency-flat/512/Ethereum-ETH-icon.png', - symbol: 'ETH', + symbol: 'WETH', address: '0x0d1F718A3079d3B695C733BA2a726873A019299a', }); @@ -81,6 +83,11 @@ export default function Swap() { toast.error('Invalid input data'); return; } + + const isAllowance = await checkAllowance(args.makerAsset, AUGUSTUS_ADDRESS, args.maker, args.makerAmount) + if(!isAllowance) { + await approveERC20(args.makerAsset, AUGUSTUS_ADDRESS); + } const orderData = await createOrderStructure(args); const { data } = await createOrder(orderData); dispatch(addOrder(data)); diff --git a/app/src/src/constants/ABI.js b/app/src/src/constants/ABI.js new file mode 100644 index 0000000..2789a8e --- /dev/null +++ b/app/src/src/constants/ABI.js @@ -0,0 +1,508 @@ +export const ERC20ABI = [ + { + constant: true, + inputs: [], + name: 'name', + outputs: [ + { + name: '', + type: 'string', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: '_spender', + type: 'address', + }, + { + name: '_value', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'totalSupply', + outputs: [ + { + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: '_from', + type: 'address', + }, + { + name: '_to', + type: 'address', + }, + { + name: '_value', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'decimals', + outputs: [ + { + name: '', + type: 'uint8', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: '_owner', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + name: 'balance', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'symbol', + outputs: [ + { + name: '', + type: 'string', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { + name: '_to', + type: 'address', + }, + { + name: '_value', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + name: '', + type: 'bool', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [ + { + name: '_owner', + type: 'address', + }, + { + name: '_spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + name: '', + type: 'uint256', + }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + payable: true, + stateMutability: 'payable', + type: 'fallback', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + name: 'owner', + type: 'address', + }, + { + indexed: true, + name: 'spender', + type: 'address', + }, + { + indexed: false, + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + name: 'from', + type: 'address', + }, + { + indexed: true, + name: 'to', + type: 'address', + }, + { + indexed: false, + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, +]; + +export const FillOrderABI = [ + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'bytes32', name: 'orderHash', type: 'bytes32' }, + { indexed: true, internalType: 'address', name: 'maker', type: 'address' }, + ], + name: 'OrderCancelled', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'bytes32', name: 'orderHash', type: 'bytes32' }, + { indexed: true, internalType: 'address', name: 'maker', type: 'address' }, + { indexed: false, internalType: 'address', name: 'makerAsset', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { indexed: true, internalType: 'address', name: 'taker', type: 'address' }, + { indexed: false, internalType: 'address', name: 'takerAsset', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + name: 'OrderFilled', + type: 'event', + }, + { inputs: [], name: 'FILLED_ORDER', outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], stateMutability: 'view', type: 'function' }, + { inputs: [], name: 'RFQ_LIMIT_ORDER_TYPEHASH', outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], stateMutability: 'view', type: 'function' }, + { inputs: [], name: 'UNFILLED_ORDER', outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], stateMutability: 'view', type: 'function' }, + { + inputs: [ + { + components: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'uint256', name: 'takerTokenFillAmount', type: 'uint256' }, + { internalType: 'bytes', name: 'permitTakerAsset', type: 'bytes' }, + { internalType: 'bytes', name: 'permitMakerAsset', type: 'bytes' }, + ], + internalType: 'struct AugustusRFQ.OrderInfo[]', + name: 'orderInfos', + type: 'tuple[]', + }, + { internalType: 'address', name: 'target', type: 'address' }, + ], + name: 'batchFillOrderWithTarget', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { inputs: [{ internalType: 'bytes32', name: 'orderHash', type: 'bytes32' }], name: 'cancelOrder', outputs: [], stateMutability: 'nonpayable', type: 'function' }, + { inputs: [{ internalType: 'bytes32[]', name: 'orderHashes', type: 'bytes32[]' }], name: 'cancelOrders', outputs: [], stateMutability: 'nonpayable', type: 'function' }, + { + inputs: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + ], + name: 'fillOrder', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'address', name: 'target', type: 'address' }, + ], + name: 'fillOrderWithTarget', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'bytes32[]', name: 'orderHashes', type: 'bytes32[]' }, + ], + name: 'getRemainingOrderBalance', + outputs: [{ internalType: 'uint256[]', name: 'remainingBalances', type: 'uint256[]' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'uint256', name: 'takerTokenFillAmount', type: 'uint256' }, + ], + name: 'partialFillOrder', + outputs: [{ internalType: 'uint256', name: 'makerTokenFilledAmount', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'uint256', name: 'takerTokenFillAmount', type: 'uint256' }, + { internalType: 'address', name: 'target', type: 'address' }, + ], + name: 'partialFillOrderWithTarget', + outputs: [{ internalType: 'uint256', name: 'makerTokenFilledAmount', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'uint256', name: 'takerTokenFillAmount', type: 'uint256' }, + { internalType: 'address', name: 'target', type: 'address' }, + { internalType: 'bytes', name: 'permitTakerAsset', type: 'bytes' }, + { internalType: 'bytes', name: 'permitMakerAsset', type: 'bytes' }, + ], + name: 'partialFillOrderWithTargetPermit', + outputs: [{ internalType: 'uint256', name: 'makerTokenFilledAmount', type: 'uint256' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: '', type: 'address' }, + { internalType: 'bytes32', name: '', type: 'bytes32' }, + ], + name: 'remaining', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'uint256', name: 'takerTokenFillAmount', type: 'uint256' }, + { internalType: 'bytes', name: 'permitTakerAsset', type: 'bytes' }, + { internalType: 'bytes', name: 'permitMakerAsset', type: 'bytes' }, + ], + internalType: 'struct AugustusRFQ.OrderInfo[]', + name: 'orderInfos', + type: 'tuple[]', + }, + { internalType: 'uint256', name: 'makerFillAmount', type: 'uint256' }, + { internalType: 'address', name: 'target', type: 'address' }, + ], + name: 'tryBatchFillOrderMakerAmount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + components: [ + { internalType: 'uint256', name: 'nonceAndMeta', type: 'uint256' }, + { internalType: 'uint128', name: 'expiry', type: 'uint128' }, + { internalType: 'address', name: 'makerAsset', type: 'address' }, + { internalType: 'address', name: 'takerAsset', type: 'address' }, + { internalType: 'address', name: 'maker', type: 'address' }, + { internalType: 'address', name: 'taker', type: 'address' }, + { internalType: 'uint256', name: 'makerAmount', type: 'uint256' }, + { internalType: 'uint256', name: 'takerAmount', type: 'uint256' }, + ], + internalType: 'struct AugustusRFQ.Order', + name: 'order', + type: 'tuple', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'uint256', name: 'takerTokenFillAmount', type: 'uint256' }, + { internalType: 'bytes', name: 'permitTakerAsset', type: 'bytes' }, + { internalType: 'bytes', name: 'permitMakerAsset', type: 'bytes' }, + ], + internalType: 'struct AugustusRFQ.OrderInfo[]', + name: 'orderInfos', + type: 'tuple[]', + }, + { internalType: 'uint256', name: 'takerFillAmount', type: 'uint256' }, + { internalType: 'address', name: 'target', type: 'address' }, + ], + name: 'tryBatchFillOrderTakerAmount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +]; diff --git a/app/src/src/constants/example-data.js b/app/src/src/constants/example-data.js deleted file mode 100644 index e07090c..0000000 --- a/app/src/src/constants/example-data.js +++ /dev/null @@ -1,73 +0,0 @@ -export const orders = [ - { - expiry: 1682589153 + 4 * 60 * 60, - createdAt: 1682589153, - updatedAt: 1682589153, - transactionHash: null, - chainId: 137, - nonceAndMeta: '7433034152904838547212883274543254857465784035140417181410394112', - maker: '0x05182e579fdfcf69e4390c3411d8fea1fb6467cf', - taker: '0xdef171fe48cf0115b1d80b88dc8eab59176fee57', - takerFromMeta: '0x0000000000000000000000000000000000000000', - makerAsset: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', - takerAsset: '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063', - makerAmount: '10000000000000000', - fillableBalance: '10000000000000000', - swappableBalance: '10000000000000000', - makerBalance: '10000000000000000', - takerAmount: '7775870000000000', - signature: '0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b', - orderHash: '0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d', - permitMakerAsset: null, - type: 'LIMIT', - state: 'PENDING', - }, - { - expiry: 0, - createdAt: 1682589153, - updatedAt: 1682589153, - transactionHash: null, - chainId: 137, - nonceAndMeta: '7433034152904838547212883274543254857465784035140417181410394112', - maker: '0x05182e579fdfcf69e4390c3411d8fea1fb6467cf', - taker: '0xdef171fe48cf0115b1d80b88dc8eab59176fee57', - takerFromMeta: '0x0000000000000000000000000000000000000000', - makerAsset: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', - takerAsset: '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063', - makerAmount: '10000000000000000', - fillableBalance: '10000000000000000', - swappableBalance: '10000000000000000', - makerBalance: '10000000000000000', - takerAmount: '7775870000000000', - signature: '0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b', - orderHash: '0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d', - permitMakerAsset: null, - type: 'LIMIT', - state: 'PENDING', - }, -]; - -const orderStructure = [ - '2144949589934985531952967838871756830784271153205', - 0, - '0x0d1F718A3079d3B695C733BA2a726873A019299a', - '0xF5B217Af5d3c828BDaEE078837b8b22cD2cBe615', - '0xc8429c05315ae47ffc0789a201e5f53e93d591d4', - '0xcB34fD4C4eb84D05Ef1cC95177e47E6344B6e74A', - '100000000000000000', - '191743000000000020000', - { - nonceAndMeta: '2144949589934985531952967838871756830784271153205', - expiry: 0, - makerAsset: '0x0d1F718A3079d3B695C733BA2a726873A019299a', - takerAsset: '0xF5B217Af5d3c828BDaEE078837b8b22cD2cBe615', - maker: '0xc8429c05315ae47ffc0789a201e5f53e93d591d4', - taker: '0xcB34fD4C4eb84D05Ef1cC95177e47E6344B6e74A', - makerAmount: '100000000000000000', - takerAmount: '191743000000000020000', - signature: '0x91fa7ff5daf160d64b01b05206cbc8b5187d4a6ae5d41d8db0ce251bb1678c1c70c66bc9111ef168f08ef6178d8660b9cd68955c90f1aff3007d253d477d25d21b', - orderHash: '0xf08f61bcb10d2c7ede29673854709acc7cd9c206fcbdc88b11d4c74d1896a685', - chainId: 97, - takerFromMeta: '0x77b6ddba6afb1a74979011a07d078be28f8bf835', - }, -]; diff --git a/app/src/src/constants/order.js b/app/src/src/constants/order.js index dbb1025..4a38a00 100644 --- a/app/src/src/constants/order.js +++ b/app/src/src/constants/order.js @@ -1,4 +1,4 @@ -export const AUGUSTUS_ADDRESS = '0xbAce6b869d656407C4BB56E7c00Ae92e7490daE8'; +export const AUGUSTUS_ADDRESS = '0xC2264d930bE02EcCd4E5B128CdD48C4A75bbA490'; export const AUGUSTUS_WRAPPER_TAKER = '0xcB34fD4C4eb84D05Ef1cC95177e47E6344B6e74A'; diff --git a/app/src/src/utils/erc20.js b/app/src/src/utils/erc20.js new file mode 100644 index 0000000..d131823 --- /dev/null +++ b/app/src/src/utils/erc20.js @@ -0,0 +1,26 @@ +import { ERC20ABI } from '../constants/ABI'; +import { ethers } from 'ethers'; + +const provider = new ethers.providers.Web3Provider(window.ethereum); + +export const balanceOf = async (contractAddress, account) => { + const contract = new ethers.Contract(contractAddress, ERC20ABI, provider); + return contract.balanceOf(account); +} + +export const getContractSymbol = async (contractAddress) => { + const contract = new ethers.Contract(contractAddress, ERC20ABI, provider); + return contract.symbol(); +} + +export const checkAllowance = async (contractAddress, spender, account, amount) => { + const contract = new ethers.Contract(contractAddress, ERC20ABI, provider); + const allowance = await contract.allowance(account, spender); + return allowance >= amount; +} + +export const approveERC20 = async (contractAddress, spender) => { + const signer = provider.getSigner(); + const contract = new ethers.Contract(contractAddress, ERC20ABI, signer); + await contract.approve(spender, ethers.constants.MaxInt256); +} \ No newline at end of file diff --git a/app/src/src/utils/fillOrder.js b/app/src/src/utils/fillOrder.js new file mode 100644 index 0000000..c8d8268 --- /dev/null +++ b/app/src/src/utils/fillOrder.js @@ -0,0 +1,12 @@ +import { FillOrderABI } from '../constants/ABI'; +import { ethers } from 'ethers'; +import { AUGUSTUS_ADDRESS } from '../constants/order'; + +const provider = new ethers.providers.Web3Provider(window.ethereum); + + +export const fillOrder = async (order, signature) => { + const signer = provider.getSigner(); + const contract = new ethers.Contract(AUGUSTUS_ADDRESS, FillOrderABI, signer); + await contract.fillOrder(order, signature) +} \ No newline at end of file diff --git a/app/src/src/utils/helpers/limitOrder.js b/app/src/src/utils/helpers/limitOrder.js index 48e8be5..e028a34 100644 --- a/app/src/src/utils/helpers/limitOrder.js +++ b/app/src/src/utils/helpers/limitOrder.js @@ -1,5 +1,5 @@ import { getRandomInt, sanitizeOrderData } from '../misc'; -import { AUGUSTUS_ADDRESS, CHAIN_ID, ORDER_TYPE, AUGUSTUS_NAME, AUGUSTUS_WRAPPER_TAKER } from '../../constants/order'; +import { AUGUSTUS_ADDRESS, CHAIN_ID, ORDER_TYPE, AUGUSTUS_NAME } from '../../constants/order'; import { ethers } from 'ethers'; import { hexValue, hexZeroPad } from '@ethersproject/bytes'; @@ -25,7 +25,7 @@ export const buildLimitOrder = ({ taker: takerInNonce = ZERO_ADDRESS, }) => { const nonceAndMeta = (BigInt(takerInNonce) + (BigInt(nonce) << BigInt(160))).toString(10); - const taker = takerInNonce === ZERO_ADDRESS ? ZERO_ADDRESS : AUGUSTUS_WRAPPER_TAKER; + const taker = takerInNonce === ZERO_ADDRESS ? ZERO_ADDRESS : takerInNonce; const order = { nonceAndMeta, diff --git a/be/AugustusRFQ_ABI.json b/be/AugustusRFQ_ABI.json new file mode 100644 index 0000000..4d68571 --- /dev/null +++ b/be/AugustusRFQ_ABI.json @@ -0,0 +1,1081 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "maker", + "type": "address" + } + ], + "name": "OrderCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "taker", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "name": "OrderFilled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "makerAsset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "makerAssetId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "taker", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "takerAsset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "takerAssetId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "name": "OrderFilledNFT", + "type": "event" + }, + { + "inputs": [], + "name": "FILLED_ORDER", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RFQ_LIMIT_NFT_ORDER_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RFQ_LIMIT_ORDER_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "UNFILLED_ORDER", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "expiry", + "type": "uint128" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permitTakerAsset", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "permitMakerAsset", + "type": "bytes" + } + ], + "internalType": "struct AugustusRFQ.OrderInfo[]", + "name": "orderInfos", + "type": "tuple[]" + }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "batchFillOrderWithTarget", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "expiry", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "makerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "makerAssetId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAssetId", + "type": "uint256" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.OrderNFT", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permitTakerAsset", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "permitMakerAsset", + "type": "bytes" + } + ], + "internalType": "struct AugustusRFQ.OrderNFTInfo[]", + "name": "orderInfos", + "type": "tuple[]" + }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "batchFillOrderWithTargetNFT", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "orderHash", "type": "bytes32" } + ], + "name": "cancelOrder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "orderHashes", + "type": "bytes32[]" + } + ], + "name": "cancelOrders", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" } + ], + "name": "fillOrder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "uint256", + "name": "makerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "makerAssetId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAssetId", + "type": "uint256" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.OrderNFT", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" } + ], + "name": "fillOrderNFT", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "fillOrderWithTarget", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "uint256", + "name": "makerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "makerAssetId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAssetId", + "type": "uint256" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.OrderNFT", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "fillOrderWithTargetNFT", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "maker", "type": "address" }, + { + "internalType": "bytes32[]", + "name": "orderHashes", + "type": "bytes32[]" + } + ], + "name": "getRemainingOrderBalance", + "outputs": [ + { + "internalType": "uint256[]", + "name": "remainingBalances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + } + ], + "name": "partialFillOrder", + "outputs": [ + { + "internalType": "uint256", + "name": "makerTokenFilledAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "uint256", + "name": "makerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "makerAssetId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAssetId", + "type": "uint256" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.OrderNFT", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + } + ], + "name": "partialFillOrderNFT", + "outputs": [ + { + "internalType": "uint256", + "name": "makerTokenFilledAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "partialFillOrderWithTarget", + "outputs": [ + { + "internalType": "uint256", + "name": "makerTokenFilledAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "uint256", + "name": "makerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "makerAssetId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAssetId", + "type": "uint256" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.OrderNFT", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "partialFillOrderWithTargetNFT", + "outputs": [ + { + "internalType": "uint256", + "name": "makerTokenFilledAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { "internalType": "address", "name": "target", "type": "address" }, + { "internalType": "bytes", "name": "permitTakerAsset", "type": "bytes" }, + { "internalType": "bytes", "name": "permitMakerAsset", "type": "bytes" } + ], + "name": "partialFillOrderWithTargetPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "makerTokenFilledAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { "internalType": "uint128", "name": "expiry", "type": "uint128" }, + { + "internalType": "uint256", + "name": "makerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "makerAssetId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAsset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAssetId", + "type": "uint256" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.OrderNFT", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { "internalType": "address", "name": "target", "type": "address" }, + { "internalType": "bytes", "name": "permitTakerAsset", "type": "bytes" }, + { "internalType": "bytes", "name": "permitMakerAsset", "type": "bytes" } + ], + "name": "partialFillOrderWithTargetPermitNFT", + "outputs": [ + { + "internalType": "uint256", + "name": "makerTokenFilledAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "bytes32", "name": "", "type": "bytes32" } + ], + "name": "remaining", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "expiry", + "type": "uint128" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permitTakerAsset", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "permitMakerAsset", + "type": "bytes" + } + ], + "internalType": "struct AugustusRFQ.OrderInfo[]", + "name": "orderInfos", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "makerFillAmount", + "type": "uint256" + }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "tryBatchFillOrderMakerAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "nonceAndMeta", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "expiry", + "type": "uint128" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { "internalType": "address", "name": "maker", "type": "address" }, + { "internalType": "address", "name": "taker", "type": "address" }, + { + "internalType": "uint256", + "name": "makerAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takerAmount", + "type": "uint256" + } + ], + "internalType": "struct AugustusRFQ.Order", + "name": "order", + "type": "tuple" + }, + { "internalType": "bytes", "name": "signature", "type": "bytes" }, + { + "internalType": "uint256", + "name": "takerTokenFillAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permitTakerAsset", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "permitMakerAsset", + "type": "bytes" + } + ], + "internalType": "struct AugustusRFQ.OrderInfo[]", + "name": "orderInfos", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "takerFillAmount", + "type": "uint256" + }, + { "internalType": "address", "name": "target", "type": "address" } + ], + "name": "tryBatchFillOrderTakerAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/be/package-lock.json b/be/package-lock.json index 16bea93..9c07961 100644 --- a/be/package-lock.json +++ b/be/package-lock.json @@ -9,6 +9,8 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@ethersproject/contracts": "^5.7.0", + "@ethersproject/providers": "^5.7.2", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.2", @@ -17,6 +19,505 @@ }, "devDependencies": { "nodemon": "^2.0.22" + }, + "engines": { + "node": "18.12.1" + } + }, + "node_modules/@ethersproject/abi": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", + "integrity": "sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/abstract-provider": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz", + "integrity": "sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0" + } + }, + "node_modules/@ethersproject/abstract-signer": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz", + "integrity": "sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, + "node_modules/@ethersproject/address": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.7.0.tgz", + "integrity": "sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/rlp": "^5.7.0" + } + }, + "node_modules/@ethersproject/base64": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.7.0.tgz", + "integrity": "sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0" + } + }, + "node_modules/@ethersproject/basex": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.7.0.tgz", + "integrity": "sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, + "node_modules/@ethersproject/bignumber": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz", + "integrity": "sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "bn.js": "^5.2.1" + } + }, + "node_modules/@ethersproject/bytes": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.7.0.tgz", + "integrity": "sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/constants": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.7.0.tgz", + "integrity": "sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bignumber": "^5.7.0" + } + }, + "node_modules/@ethersproject/contracts": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.7.0.tgz", + "integrity": "sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0" + } + }, + "node_modules/@ethersproject/hash": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz", + "integrity": "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/keccak256": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz", + "integrity": "sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "js-sha3": "0.8.0" + } + }, + "node_modules/@ethersproject/logger": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.7.0.tgz", + "integrity": "sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ] + }, + "node_modules/@ethersproject/networks": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.7.1.tgz", + "integrity": "sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/properties": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz", + "integrity": "sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/providers": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.7.2.tgz", + "integrity": "sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0", + "bech32": "1.1.4", + "ws": "7.4.6" + } + }, + "node_modules/@ethersproject/random": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.7.0.tgz", + "integrity": "sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/rlp": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz", + "integrity": "sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/sha2": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.7.0.tgz", + "integrity": "sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "hash.js": "1.1.7" + } + }, + "node_modules/@ethersproject/signing-key": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz", + "integrity": "sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "bn.js": "^5.2.1", + "elliptic": "6.5.4", + "hash.js": "1.1.7" + } + }, + "node_modules/@ethersproject/strings": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", + "integrity": "sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/transactions": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.7.0.tgz", + "integrity": "sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0" + } + }, + "node_modules/@ethersproject/web": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz", + "integrity": "sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" } }, "node_modules/@types/node": { @@ -106,6 +607,11 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "license": "MIT" }, + "node_modules/bech32": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", + "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -116,6 +622,11 @@ "node": ">=8" } }, + "node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, "node_modules/body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -164,6 +675,11 @@ "node": ">=8" } }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" + }, "node_modules/bson": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/bson/-/bson-5.2.0.tgz", @@ -341,6 +857,25 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "license": "MIT" }, + "node_modules/elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -523,6 +1058,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -625,6 +1179,11 @@ "node": ">=0.12.0" } }, + "node_modules/js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + }, "node_modules/kareem": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", @@ -698,6 +1257,16 @@ "node": ">= 0.6" } }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -1380,9 +1949,295 @@ "engines": { "node": ">=12" } + }, + "node_modules/ws": { + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } } }, "dependencies": { + "@ethersproject/abi": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", + "integrity": "sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==", + "requires": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "@ethersproject/abstract-provider": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz", + "integrity": "sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==", + "requires": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0" + } + }, + "@ethersproject/abstract-signer": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz", + "integrity": "sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==", + "requires": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, + "@ethersproject/address": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.7.0.tgz", + "integrity": "sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==", + "requires": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/rlp": "^5.7.0" + } + }, + "@ethersproject/base64": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.7.0.tgz", + "integrity": "sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==", + "requires": { + "@ethersproject/bytes": "^5.7.0" + } + }, + "@ethersproject/basex": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.7.0.tgz", + "integrity": "sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, + "@ethersproject/bignumber": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz", + "integrity": "sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "bn.js": "^5.2.1" + } + }, + "@ethersproject/bytes": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.7.0.tgz", + "integrity": "sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==", + "requires": { + "@ethersproject/logger": "^5.7.0" + } + }, + "@ethersproject/constants": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.7.0.tgz", + "integrity": "sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==", + "requires": { + "@ethersproject/bignumber": "^5.7.0" + } + }, + "@ethersproject/contracts": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.7.0.tgz", + "integrity": "sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==", + "requires": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0" + } + }, + "@ethersproject/hash": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz", + "integrity": "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==", + "requires": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "@ethersproject/keccak256": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz", + "integrity": "sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "js-sha3": "0.8.0" + } + }, + "@ethersproject/logger": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.7.0.tgz", + "integrity": "sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==" + }, + "@ethersproject/networks": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.7.1.tgz", + "integrity": "sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==", + "requires": { + "@ethersproject/logger": "^5.7.0" + } + }, + "@ethersproject/properties": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz", + "integrity": "sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==", + "requires": { + "@ethersproject/logger": "^5.7.0" + } + }, + "@ethersproject/providers": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.7.2.tgz", + "integrity": "sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==", + "requires": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0", + "bech32": "1.1.4", + "ws": "7.4.6" + } + }, + "@ethersproject/random": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.7.0.tgz", + "integrity": "sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "@ethersproject/rlp": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz", + "integrity": "sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "@ethersproject/sha2": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.7.0.tgz", + "integrity": "sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "hash.js": "1.1.7" + } + }, + "@ethersproject/signing-key": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz", + "integrity": "sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "bn.js": "^5.2.1", + "elliptic": "6.5.4", + "hash.js": "1.1.7" + } + }, + "@ethersproject/strings": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", + "integrity": "sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==", + "requires": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "@ethersproject/transactions": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.7.0.tgz", + "integrity": "sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==", + "requires": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0" + } + }, + "@ethersproject/web": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz", + "integrity": "sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==", + "requires": { + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, "@types/node": { "version": "18.16.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.1.tgz", @@ -1453,12 +2308,22 @@ } } }, + "bech32": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", + "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" + }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, + "bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, "body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -1497,6 +2362,11 @@ "fill-range": "^7.0.1" } }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" + }, "bson": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/bson/-/bson-5.2.0.tgz", @@ -1614,6 +2484,27 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, + "elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "requires": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + } + } + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -1743,6 +2634,25 @@ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" }, + "hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -1814,6 +2724,11 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + }, "kareem": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", @@ -1858,6 +2773,16 @@ "mime-db": "1.52.0" } }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" + }, "minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -2301,6 +3226,12 @@ "tr46": "^3.0.0", "webidl-conversions": "^7.0.0" } + }, + "ws": { + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", + "requires": {} } } } diff --git a/be/package.json b/be/package.json index dc90bf5..e7ba7e0 100644 --- a/be/package.json +++ b/be/package.json @@ -14,6 +14,8 @@ "author": "", "license": "ISC", "dependencies": { + "@ethersproject/contracts": "^5.7.0", + "@ethersproject/providers": "^5.7.2", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.2", diff --git a/be/src/controllers/order.controller.js b/be/src/controllers/order.controller.js index c6918ca..40f210b 100644 --- a/be/src/controllers/order.controller.js +++ b/be/src/controllers/order.controller.js @@ -1,4 +1,5 @@ const Order = require('../models/Order.schema'); +const { ORDER_STATUS } = require('../constants'); class OrderController { async index(req, res) { @@ -8,7 +9,7 @@ class OrderController { async maker(req, res) { try { - const orders = await Order.find({ "maker": { '$regex': req.params.makerAddress, $options: 'i' }}); + const orders = await Order.find({ "maker": { '$regex': req.params.makerAddress, $options: 'i' }, state: ORDER_STATUS.PENDING}); res.json(orders); } catch (error) { res.sendStatus(500); @@ -16,10 +17,11 @@ class OrderController { } async taker(req, res) { - try {e - const orders = await Order.find({ "taker" : { '$regex': req.params.takerAddress, $options: 'i' }}) + try { + const orders = await Order.find({ "taker" : { '$regex': req.params.takerAddress, $options: 'i' }, state: ORDER_STATUS.PENDING }) res.json(orders); } catch (error) { + console.log(error); res.sendStatus(500); } } diff --git a/be/test.js b/be/test.js new file mode 100644 index 0000000..f67fa16 --- /dev/null +++ b/be/test.js @@ -0,0 +1,29 @@ +const AugustusRFQ_ABI = require('./AugustusRFQ_ABI.json') +const { Contract } = require("@ethersproject/contracts"); +const { JsonRpcProvider } = require("@ethersproject/providers"); + +const AugustusRFQ_ADDRESS = '0xe92b586627ccA7a83dC919cc7127196d70f55a06'; + +const JSON_RPC = 'https://1rpc.io/eth'; + +const crawlEvents = async () => { + const rpcProvider = new JsonRpcProvider(JSON_RPC); + const factoryContract = new Contract( + AugustusRFQ_ADDRESS, + AugustusRFQ_ABI, + rpcProvider + ); + + const fromBlock = 17170000; + const toBlock = 17180000; + // Fetch events data + const events = await factoryContract.queryFilter( + 'OrderFilled', + fromBlock, + toBlock + ); + + console.log(events); + } + + crawlEvents(); \ No newline at end of file diff --git a/be/yarn.lock b/be/yarn.lock index 4be0683..a367c71 100644 --- a/be/yarn.lock +++ b/be/yarn.lock @@ -2,6 +2,250 @@ # yarn lockfile v1 +"@ethersproject/abi@^5.7.0": + "integrity" "sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==" + "resolved" "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@ethersproject/abstract-provider@^5.7.0": + "integrity" "sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==" + "resolved" "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/networks" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/web" "^5.7.0" + +"@ethersproject/abstract-signer@^5.7.0": + "integrity" "sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + +"@ethersproject/address@^5.7.0": + "integrity" "sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==" + "resolved" "https://registry.npmjs.org/@ethersproject/address/-/address-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + +"@ethersproject/base64@^5.7.0": + "integrity" "sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + +"@ethersproject/basex@^5.7.0": + "integrity" "sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==" + "resolved" "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + +"@ethersproject/bignumber@^5.7.0": + "integrity" "sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==" + "resolved" "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "bn.js" "^5.2.1" + +"@ethersproject/bytes@^5.7.0": + "integrity" "sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==" + "resolved" "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/constants@^5.7.0": + "integrity" "sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==" + "resolved" "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bignumber" "^5.7.0" + +"@ethersproject/contracts@^5.7.0": + "integrity" "sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==" + "resolved" "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/abi" "^5.7.0" + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + +"@ethersproject/hash@^5.7.0": + "integrity" "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==" + "resolved" "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/base64" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@ethersproject/keccak256@^5.7.0": + "integrity" "sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==" + "resolved" "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "js-sha3" "0.8.0" + +"@ethersproject/logger@^5.7.0": + "integrity" "sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==" + "resolved" "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.7.0.tgz" + "version" "5.7.0" + +"@ethersproject/networks@^5.7.0": + "integrity" "sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.7.1.tgz" + "version" "5.7.1" + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/properties@^5.7.0": + "integrity" "sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==" + "resolved" "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/providers@^5.7.2": + "integrity" "sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==" + "resolved" "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.7.2.tgz" + "version" "5.7.2" + dependencies: + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/base64" "^5.7.0" + "@ethersproject/basex" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/networks" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/random" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + "@ethersproject/sha2" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/web" "^5.7.0" + "bech32" "1.1.4" + "ws" "7.4.6" + +"@ethersproject/random@^5.7.0": + "integrity" "sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/random/-/random-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/rlp@^5.7.0": + "integrity" "sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==" + "resolved" "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/sha2@^5.7.0": + "integrity" "sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==" + "resolved" "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "hash.js" "1.1.7" + +"@ethersproject/signing-key@^5.7.0": + "integrity" "sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==" + "resolved" "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "bn.js" "^5.2.1" + "elliptic" "6.5.4" + "hash.js" "1.1.7" + +"@ethersproject/strings@^5.7.0": + "integrity" "sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==" + "resolved" "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/transactions@^5.7.0": + "integrity" "sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==" + "resolved" "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.7.0.tgz" + "version" "5.7.0" + dependencies: + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + "@ethersproject/signing-key" "^5.7.0" + +"@ethersproject/web@^5.7.0": + "integrity" "sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==" + "resolved" "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz" + "version" "5.7.1" + dependencies: + "@ethersproject/base64" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + "@types/node@*": "integrity" "sha512-DZxSZWXxFfOlx7k7Rv4LAyiMroaxa3Ly/7OOzZO8cBNho0YzAi4qlbrx8W27JGqG57IgR/6J7r+nOJWw6kcvZA==" "resolved" "https://registry.npmjs.org/@types/node/-/node-18.16.1.tgz" @@ -58,11 +302,26 @@ dependencies: "safe-buffer" "5.1.2" +"bech32@1.1.4": + "integrity" "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" + "resolved" "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz" + "version" "1.1.4" + "binary-extensions@^2.0.0": "integrity" "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" "resolved" "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" "version" "2.2.0" +"bn.js@^4.11.9": + "integrity" "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" + "version" "4.12.0" + +"bn.js@^5.2.1": + "integrity" "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz" + "version" "5.2.1" + "body-parser@1.20.1": "integrity" "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==" "resolved" "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz" @@ -96,6 +355,11 @@ dependencies: "fill-range" "^7.0.1" +"brorand@^1.1.0": + "integrity" "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" + "resolved" "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz" + "version" "1.1.0" + "bson@^5.0.1": "integrity" "sha512-HevkSpDbpUfsrHWmWiAsNavANKYIErV2ePXllp1bwq5CDreAaFVj6RVlZpJnxK4WWDCJ/5jMUpaY6G526q3Hjg==" "resolved" "https://registry.npmjs.org/bson/-/bson-5.2.0.tgz" @@ -205,6 +469,19 @@ "resolved" "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" "version" "1.1.1" +"elliptic@6.5.4": + "integrity" "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==" + "resolved" "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz" + "version" "6.5.4" + dependencies: + "bn.js" "^4.11.9" + "brorand" "^1.1.0" + "hash.js" "^1.0.0" + "hmac-drbg" "^1.0.1" + "inherits" "^2.0.4" + "minimalistic-assert" "^1.0.1" + "minimalistic-crypto-utils" "^1.0.1" + "encodeurl@~1.0.2": "integrity" "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" "resolved" "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz" @@ -325,6 +602,23 @@ dependencies: "function-bind" "^1.1.1" +"hash.js@^1.0.0", "hash.js@^1.0.3", "hash.js@1.1.7": + "integrity" "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==" + "resolved" "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz" + "version" "1.1.7" + dependencies: + "inherits" "^2.0.3" + "minimalistic-assert" "^1.0.1" + +"hmac-drbg@^1.0.1": + "integrity" "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==" + "resolved" "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz" + "version" "1.0.1" + dependencies: + "hash.js" "^1.0.3" + "minimalistic-assert" "^1.0.0" + "minimalistic-crypto-utils" "^1.0.1" + "http-errors@2.0.0": "integrity" "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==" "resolved" "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz" @@ -348,7 +642,7 @@ "resolved" "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz" "version" "1.0.1" -"inherits@2.0.4": +"inherits@^2.0.3", "inherits@^2.0.4", "inherits@2.0.4": "integrity" "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" "resolved" "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" "version" "2.0.4" @@ -387,6 +681,11 @@ "resolved" "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" "version" "7.0.0" +"js-sha3@0.8.0": + "integrity" "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + "resolved" "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz" + "version" "0.8.0" + "kareem@2.5.1": "integrity" "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==" "resolved" "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz" @@ -429,6 +728,16 @@ "resolved" "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz" "version" "1.6.0" +"minimalistic-assert@^1.0.0", "minimalistic-assert@^1.0.1": + "integrity" "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + "resolved" "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz" + "version" "1.0.1" + +"minimalistic-crypto-utils@^1.0.1": + "integrity" "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" + "resolved" "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz" + "version" "1.0.1" + "minimatch@^3.1.2": "integrity" "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==" "resolved" "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" @@ -815,3 +1124,8 @@ dependencies: "tr46" "^3.0.0" "webidl-conversions" "^7.0.0" + +"ws@7.4.6": + "integrity" "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==" + "resolved" "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz" + "version" "7.4.6" diff --git a/blockchain/contracts/AugustusRFQ.sol b/blockchain/contracts/AugustusRFQ.sol index b862c17..126d9ae 100644 --- a/blockchain/contracts/AugustusRFQ.sol +++ b/blockchain/contracts/AugustusRFQ.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.10; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; diff --git a/blockchain/deployed/contract.json b/blockchain/deployed/contract.json index 7c1e885..5352aef 100644 --- a/blockchain/deployed/contract.json +++ b/blockchain/deployed/contract.json @@ -1,6 +1,6 @@ { "WETH": "0x0d1F718A3079d3B695C733BA2a726873A019299a", "DAI": "0xF5B217Af5d3c828BDaEE078837b8b22cD2cBe615", - "AugustusRFQ": "0xbAce6b869d656407C4BB56E7c00Ae92e7490daE8", + "AugustusRFQ": "0xC2264d930bE02EcCd4E5B128CdD48C4A75bbA490", "AugustusWrapper": "0xcb34fd4c4eb84d05ef1cc95177e47e6344b6e74a" } \ No newline at end of file diff --git a/blockchain/scripts/deploy.ts b/blockchain/scripts/deploy.ts index a82ec58..7302e63 100644 --- a/blockchain/scripts/deploy.ts +++ b/blockchain/scripts/deploy.ts @@ -9,42 +9,42 @@ async function main() { await augustusRFQ.deployed(); console.log('augustusRFQ', augustusRFQ.address); - const AugustusSwapper = await ethers.getContractFactory("AugustusSwapper"); - const augustusSwapper = await AugustusSwapper.deploy(accounts[0].address); - await augustusSwapper.deployed(); - console.log('augustusSwapper', augustusSwapper.address); + // const AugustusSwapper = await ethers.getContractFactory("AugustusSwapper"); + // const augustusSwapper = await AugustusSwapper.deploy(accounts[0].address); + // await augustusSwapper.deployed(); + // console.log('augustusSwapper', augustusSwapper.address); - const WETH = await ethers.getContractFactory("WETH"); - const weth = await WETH.deploy(ethers.utils.parseUnits('100', 18)); - await weth.deployed(); - console.log('weth', weth.address); + // const WETH = await ethers.getContractFactory("WETH"); + // const weth = await WETH.deploy(ethers.utils.parseUnits('100', 18)); + // await weth.deployed(); + // console.log('weth', weth.address); - const DAI = await ethers.getContractFactory("DAI"); - const dai = await DAI.deploy(ethers.utils.parseUnits('1000000', 18)); - await dai.deployed(); - console.log('dai', dai.address); + // const DAI = await ethers.getContractFactory("DAI"); + // const dai = await DAI.deploy(ethers.utils.parseUnits('1000000', 18)); + // await dai.deployed(); + // console.log('dai', dai.address); await run('verify:verify', { address: augustusRFQ.address, constructorArguments: [] }) - await run('verify:verify', { - address: augustusSwapper.address, - constructorArguments: [accounts[0].address] - }); - - await run('verify:verify', { - address: '0x0d1F718A3079d3B695C733BA2a726873A019299a', - contract: 'contracts/WETH.sol:WETH', - constructorArguments: [ethers.utils.parseUnits('100', 18)] - }); - - await run('verify:verify', { - address: '0xF5B217Af5d3c828BDaEE078837b8b22cD2cBe615', - contract: 'contracts/DAI.sol:DAI', - constructorArguments: [ethers.utils.parseUnits('1000000', 18)] - }); + // await run('verify:verify', { + // address: augustusSwapper.address, + // constructorArguments: [accounts[0].address] + // }); + + // await run('verify:verify', { + // address: '0x0d1F718A3079d3B695C733BA2a726873A019299a', + // contract: 'contracts/WETH.sol:WETH', + // constructorArguments: [ethers.utils.parseUnits('100', 18)] + // }); + + // await run('verify:verify', { + // address: '0xF5B217Af5d3c828BDaEE078837b8b22cD2cBe615', + // contract: 'contracts/DAI.sol:DAI', + // constructorArguments: [ethers.utils.parseUnits('1000000', 18)] + // }); } // We recommend this pattern to be able to use async/await everywhere diff --git a/blockchain/test.json b/blockchain/test.json new file mode 100644 index 0000000..1e9b289 --- /dev/null +++ b/blockchain/test.json @@ -0,0 +1,22 @@ +{ + "fromToken": "0x4d224452801aced8b2f0aebe155379bb5d594381", + "toToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "fromAmount": "19720172063384116056941", + "toAmount": "40000000000000000000", + "expectedAmount": "19622061754611060753176", + "callees": [ + "0xdef1c0ded9bec7f1a1670819833240f027b25eff", + "0xe592427a0aece92de3edee1f18e0157c05861564", + "0xe92b586627cca7a83dc919cc7127196d70f55a06", + "0xdef171fe48cf0115b1d80b88dc8eab59176fee57" + ], + "exchangeData": "0xaa77476c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000004d224452801aced8b2f0aebe155379bb5d594381000000000000000000000000000000000000000000000000ff6077fb9d9300000000000000000000000000000000000000000000000001e9aa011d6fe5ee7152000000000000000000000000807cf9a772d5a3f9cefbc1192e939d62f0d9bd38000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000007eb413211a9de1cd2fe8b8bb6055636c43f7d206000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000645188bc00000000000000000000000000000000000000000000000000000000645188620000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000001b299c64a16d5957ab02ecd29d0d9afd8541c97058d401c1f6f3c684d3ce56aa157ddede093bc9c8bf0006fe50a192fd9f72994c9790a737c89dc192c5b071b8d50000000000000000000000000000000000000000000001e99d785f93f42a8c16f28c0498000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee5700000000000000000000000000000000000000000000000000000000645ac2e2000000000000000000000000000000000000000000000000853a0d2313c0000000000000000000000000000000000000000000000000010085761d2593536fe8000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb84d224452801aced8b2f0aebe155379bb5d59438100000000000000000000000000000000000000000001fb36ba0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000a688906bd8b00000000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002005550ae37abb83ce33fe3c687eb413211a9de1cd2fe8b8bb6055636c43f7d20600000000000000000000000000000000000000000000000000000000645188bc000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000004d224452801aced8b2f0aebe155379bb5d594381000000000000000000000000807cf9a772d5a3f9cefbc1192e939d62f0d9bd38000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57000000000000000000000000000000000000000000000000a68cd3d09e6b000000000000000000000000000000000000000000000000013f4d67b02f0d0801c9000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000013f4d67b02f0d0801c9000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000041d4d042d7b3ee3fbd7f27751d058049aba4278c088a31bd3d30db6846f6ced59575fd0f324a6ad8a18449769148c2b0e2f18cfaa2fe1e90d6bfe0b16d7f09f5d21c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e1829cfe000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "startIndexes": ["0", "484", "776", "1516", "1552"], + "values": ["0", "0", "0", "0"], + "beneficiary": "0x0000000000000000000000000000000000000000", + "partner": "0xe4d12a78a24f63f856b7192beaacc9875d387fec", + "feePercent": "452312848583266388373324160190187140051835877600158453279131187530910711808", + "permit": "0x", + "deadline": "1683065020", + "uuid": "0xc564538be37343938cfa8e88db24ce06" +} diff --git a/blockchain/test/AugustusRFQ.test.ts b/blockchain/test/AugustusRFQ.test.ts index 86c4c7e..d7db2fe 100644 --- a/blockchain/test/AugustusRFQ.test.ts +++ b/blockchain/test/AugustusRFQ.test.ts @@ -1,6 +1,8 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import { ethers } from 'hardhat'; +import { ethers, network } from 'hardhat'; import { AugustusRFQ, AugustusSwapper, DAI, WETH } from '../typechain-types'; +import { createOrderStructure, sanitizeOrderData } from './utils'; +import { expect } from 'chai' let augustusRFQ: AugustusRFQ; let augustusSwapper: AugustusSwapper; @@ -11,6 +13,13 @@ let deployer: SignerWithAddress; let maker: SignerWithAddress; let taker: SignerWithAddress; +const TOKEN_1 = ethers.utils.parseUnits('1', 18); +const TOKEN_100 = ethers.utils.parseUnits('100', 18); +const ONE_DAY = 24 * 60 * 60; + +let CHAIN_ID: number; +let AUGUSTUS_ADDRESS: string; +let AUGUSTUS_WRAPPER_TAKER: string; describe('AugustusRFQ', () => { beforeEach(async () => { @@ -24,18 +33,53 @@ describe('AugustusRFQ', () => { await augustusSwapper.deployed(); const DAI = await ethers.getContractFactory('DAI'); - dai = await DAI.deploy(ethers.utils.parseUnits('1000000', 18)); + dai = await DAI.deploy(TOKEN_100.mul(1000)); await dai.deployed(); const WETH = await ethers.getContractFactory('WETH'); - weth = await WETH.deploy(ethers.utils.parseUnits('100', 18)); + weth = await WETH.deploy(TOKEN_100); await weth.deployed(); + + await weth.connect(maker).mint(TOKEN_100); + await dai.connect(taker).mint(TOKEN_100.mul(1000)); + + CHAIN_ID = network.config.chainId as number; + AUGUSTUS_ADDRESS = augustusRFQ.address; + AUGUSTUS_WRAPPER_TAKER = augustusSwapper.address; }); it('Testing fill order', async () => { - console.log(augustusRFQ.address) - console.log(augustusSwapper.address) - console.log(dai.address) - console.log(weth.address) - }) + const args = { + maker: maker.address, + makerAsset: weth.address, + takerAsset: dai.address, + makerAmount: TOKEN_1, + takerAmount: TOKEN_100.mul(20), + expiry: ONE_DAY * 7, + taker: taker.address, + CHAIN_ID, + AUGUSTUS_ADDRESS, + AUGUSTUS_WRAPPER_TAKER, + }; + + const { signableOrderData, returnedData } = await createOrderStructure(args); + const typedDataOnly = { + ...signableOrderData, + data: sanitizeOrderData(signableOrderData.data), + }; + const { data, domain, types } = typedDataOnly; + const provider = ethers.provider; + const signer = provider.getSigner(maker.address); + + const signature = await signer._signTypedData(domain, types, data); + returnedData.signature = signature; + const { signature: makerSignature, orderHash, chainId, takerFromMeta, ...order } = returnedData; + await weth.connect(maker).approve(augustusRFQ.address, ethers.constants.MaxInt256); + await dai.connect(taker).approve(augustusRFQ.address, ethers.constants.MaxInt256); + console.log(order); + await expect(augustusRFQ.connect(taker).fillOrder(order, signature)) + .to.changeTokenBalances(weth, [maker.address, taker.address], [TOKEN_1.mul(-1), TOKEN_1]) + .to.changeTokenBalances(dai, [maker.address, taker.address], [TOKEN_100.mul(20), TOKEN_100.mul(20).mul(-1)]) + + }); }); diff --git a/blockchain/test/utils.ts b/blockchain/test/utils.ts new file mode 100644 index 0000000..6c25188 --- /dev/null +++ b/blockchain/test/utils.ts @@ -0,0 +1,160 @@ +import { ethers } from 'ethers'; +import { hexValue, hexZeroPad } from '@ethersproject/bytes'; + +const ZERO_ADDRESS = ethers.constants.AddressZero; + +export const AUGUSTUS_NAME = 'AUGUSTUS RFQ'; + +export const ORDER_TYPE = [ + { + name: 'nonceAndMeta', + type: 'uint256', + }, + { + name: 'expiry', + type: 'uint128', + }, + { + name: 'makerAsset', + type: 'address', + }, + { + name: 'takerAsset', + type: 'address', + }, + { + name: 'maker', + type: 'address', + }, + { + name: 'taker', + type: 'address', + }, + { + name: 'makerAmount', + type: 'uint256', + }, + { + name: 'takerAmount', + type: 'uint256', + }, +]; + +export const getRandomInt = () => { + return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER); +}; + +export const sanitizeOrderData = ({ nonceAndMeta, expiry, makerAsset, takerAsset, maker, taker, makerAmount, takerAmount }) => { + return { + nonceAndMeta, + expiry, + makerAsset, + takerAsset, + maker, + taker, + makerAmount, + takerAmount, + }; +}; + +export const deriveTakerFromNonceAndTaker = (nonceAndMeta) => { + return hexZeroPad(hexValue(BigInt(nonceAndMeta) & ((BigInt(1) << BigInt(160)) - BigInt(1))), 20); +}; + +export const buildLimitOrder = ({ + nonce = getRandomInt(), + expiry, + makerAsset, + takerAsset, + makerAmount, + takerAmount, + maker, + // if taker is specified -- p2p order for that taker only to fill through Augustus -- taker = Augustus, takerInNonce = _taker + // if taker is not specified -- limitOrder for anyone to fill through Augustus or not -- taker = Zero, takerInNonce = Zero + taker: takerInNonce = ZERO_ADDRESS, + AUGUSTUS_ADDRESS, + AUGUSTUS_WRAPPER_TAKER, + CHAIN_ID, +}) => { + const nonceAndMeta = (BigInt(takerInNonce) + (BigInt(nonce) << BigInt(160))).toString(10); + const taker = takerInNonce === ZERO_ADDRESS ? ZERO_ADDRESS : takerInNonce; + + const order = { + nonceAndMeta, + expiry, + makerAsset, + takerAsset, + maker, + taker, + makerAmount, + takerAmount, + }; + + return { + types: { Order: ORDER_TYPE }, + domain: { name: AUGUSTUS_NAME, version: '1', chainId: CHAIN_ID, verifyingContract: AUGUSTUS_ADDRESS }, + data: order, + }; +}; + +export const signLimitOrder = async (typedData) => { + const typedDataOnly = { + ...typedData, + data: sanitizeOrderData(typedData.data), + }; + const { data, domain, types } = typedDataOnly; + const provider = ethers.provider; + const signer = provider.getSigner(typedData.data.taker.address); + + const signature = await signer._signTypedData(domain, types, data); + return signature; +}; + +export const calculateOrderHash = async ({ domain, types, data }) => { + return ethers.utils._TypedDataEncoder.hash(domain, types, data); +}; + +export const createOrderStructure = async ({ + taker, + maker, + makerAsset, + takerAsset, + makerAmount, + takerAmount, + expiry, + AUGUSTUS_ADDRESS, + AUGUSTUS_WRAPPER_TAKER, + CHAIN_ID, +}) => { + const orderInput = { + nonce: 1, + expiry: expiry === 0 ? 0 : Math.floor(Date.now() / 1000) + expiry, + makerAsset, + takerAsset, + makerAmount, + takerAmount, + maker, + taker, + }; + + const signableOrderData = buildLimitOrder({ ...orderInput, AUGUSTUS_ADDRESS, AUGUSTUS_WRAPPER_TAKER, CHAIN_ID }); + // const signature = await signLimitOrder(signableOrderData); + + const orderHash = await calculateOrderHash(signableOrderData); + const takerFromMeta = deriveTakerFromNonceAndTaker(signableOrderData.data.nonceAndMeta); + + signableOrderData.data.makerAmount = signableOrderData.data.makerAmount.toString(); + signableOrderData.data.takerAmount = signableOrderData.data.takerAmount.toString(); + + const returnedData = { + ...signableOrderData.data, + signature: '', + orderHash, + chainId: CHAIN_ID, + takerFromMeta, + }; + return { + signableOrderData, + returnedData, + }; +};