Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composable cow #140

Merged
merged 21 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ jest.results.json
*.iml
.yalc
yalc.lock
src/composable/generated
docs/typedoc/
1 change: 1 addition & 0 deletions abi/ComposableCoW.json
mfw78 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"_settlement","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InterfaceNotSupported","type":"error"},{"inputs":[],"name":"InvalidHandler","type":"error"},{"inputs":[],"name":"ProofNotAuthed","type":"error"},{"inputs":[],"name":"SingleOrderNotAuthed","type":"error"},{"inputs":[],"name":"SwapGuardRestricted","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"components":[{"internalType":"contract IConditionalOrder","name":"handler","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"}],"indexed":false,"internalType":"struct IConditionalOrder.ConditionalOrderParams","name":"params","type":"tuple"}],"name":"ConditionalOrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"bytes32","name":"root","type":"bytes32"},{"components":[{"internalType":"uint256","name":"location","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct ComposableCoW.Proof","name":"proof","type":"tuple"}],"name":"MerkleRootSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"contract ISwapGuard","name":"swapGuard","type":"address"}],"name":"SwapGuardSet","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"cabinet","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IConditionalOrder","name":"handler","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"}],"internalType":"struct IConditionalOrder.ConditionalOrderParams","name":"params","type":"tuple"},{"internalType":"bool","name":"dispatch","type":"bool"}],"name":"create","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IConditionalOrder","name":"handler","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"}],"internalType":"struct IConditionalOrder.ConditionalOrderParams","name":"params","type":"tuple"},{"internalType":"contract IValueFactory","name":"factory","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bool","name":"dispatch","type":"bool"}],"name":"createWithContext","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"components":[{"internalType":"contract IConditionalOrder","name":"handler","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"}],"internalType":"struct IConditionalOrder.ConditionalOrderParams","name":"params","type":"tuple"},{"internalType":"bytes","name":"offchainInput","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"getTradeableOrderWithSignature","outputs":[{"components":[{"internalType":"contract IERC20","name":"sellToken","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes32","name":"kind","type":"bytes32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"bytes32","name":"sellTokenBalance","type":"bytes32"},{"internalType":"bytes32","name":"buyTokenBalance","type":"bytes32"}],"internalType":"struct GPv2Order.Data","name":"order","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IConditionalOrder","name":"handler","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"}],"internalType":"struct IConditionalOrder.ConditionalOrderParams","name":"params","type":"tuple"}],"name":"hash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract Safe","name":"safe","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes32","name":"_domainSeparator","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes","name":"encodeData","type":"bytes"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"isValidSafeSignature","outputs":[{"internalType":"bytes4","name":"magic","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"singleOrderHash","type":"bytes32"}],"name":"remove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"roots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"root","type":"bytes32"},{"components":[{"internalType":"uint256","name":"location","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct ComposableCoW.Proof","name":"proof","type":"tuple"}],"name":"setRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"root","type":"bytes32"},{"components":[{"internalType":"uint256","name":"location","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct ComposableCoW.Proof","name":"proof","type":"tuple"},{"internalType":"contract IValueFactory","name":"factory","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setRootWithContext","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISwapGuard","name":"swapGuard","type":"address"}],"name":"setSwapGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"singleOrders","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"swapGuards","outputs":[{"internalType":"contract ISwapGuard","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions abi/ExtensibleFallbackHandler.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"indexed":false,"internalType":"contract ISafeSignatureVerifier","name":"verifier","type":"address"}],"name":"AddedDomainVerifier","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"AddedInterface","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes4","name":"selector","type":"bytes4"},{"indexed":false,"internalType":"bytes32","name":"method","type":"bytes32"}],"name":"AddedSafeMethod","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"indexed":false,"internalType":"contract ISafeSignatureVerifier","name":"oldVerifier","type":"address"},{"indexed":false,"internalType":"contract ISafeSignatureVerifier","name":"newVerifier","type":"address"}],"name":"ChangedDomainVerifier","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes4","name":"selector","type":"bytes4"},{"indexed":false,"internalType":"bytes32","name":"oldMethod","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"newMethod","type":"bytes32"}],"name":"ChangedSafeMethod","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes32","name":"domainSeparator","type":"bytes32"}],"name":"RemovedDomainVerifier","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"RemovedInterface","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Safe","name":"safe","type":"address"},{"indexed":false,"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"RemovedSafeMethod","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[{"internalType":"contract Safe","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"domainVerifiers","outputs":[{"internalType":"contract ISafeSignatureVerifier","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"magic","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract Safe","name":"","type":"address"},{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"safeInterfaces","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract Safe","name":"","type":"address"},{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"safeMethods","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"internalType":"contract ISafeSignatureVerifier","name":"newVerifier","type":"address"}],"name":"setDomainVerifier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"bytes32","name":"newMethod","type":"bytes32"}],"name":"setSafeMethod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"},{"internalType":"bool","name":"supported","type":"bool"}],"name":"setSupportedInterface","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"},{"internalType":"bytes32[]","name":"handlerWithSelectors","type":"bytes32[]"}],"name":"setSupportedInterfaceBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
1 change: 1 addition & 0 deletions abi/TWAP.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"contract ComposableCoW","name":"_composableCow","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidFrequency","type":"error"},{"inputs":[],"name":"InvalidMinPartLimit","type":"error"},{"inputs":[],"name":"InvalidNumParts","type":"error"},{"inputs":[],"name":"InvalidPartSellAmount","type":"error"},{"inputs":[],"name":"InvalidSameToken","type":"error"},{"inputs":[],"name":"InvalidSpan","type":"error"},{"inputs":[],"name":"InvalidStartTime","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"OrderNotValid","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"components":[{"internalType":"contract IConditionalOrder","name":"handler","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"}],"indexed":false,"internalType":"struct IConditionalOrder.ConditionalOrderParams","name":"params","type":"tuple"}],"name":"ConditionalOrderCreated","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"ctx","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"getTradeableOrder","outputs":[{"components":[{"internalType":"contract IERC20","name":"sellToken","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes32","name":"kind","type":"bytes32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"bytes32","name":"sellTokenBalance","type":"bytes32"},{"internalType":"bytes32","name":"buyTokenBalance","type":"bytes32"}],"internalType":"struct GPv2Order.Data","name":"order","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"internalType":"bytes32","name":"ctx","type":"bytes32"},{"internalType":"bytes","name":"staticInput","type":"bytes"},{"internalType":"bytes","name":"offchainInput","type":"bytes"},{"components":[{"internalType":"contract IERC20","name":"sellToken","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes32","name":"kind","type":"bytes32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"bytes32","name":"sellTokenBalance","type":"bytes32"},{"internalType":"bytes32","name":"buyTokenBalance","type":"bytes32"}],"internalType":"struct GPv2Order.Data","name":"","type":"tuple"}],"name":"verify","outputs":[],"stateMutability":"view","type":"function"}]
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@
"test": "jest",
"test:coverage": "jest --coverage --json --outputFile=jest.results.json && cat ./coverage/lcov.info | coveralls",
"test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
"codegen": "npm run graphql:codegen && npm run swagger:codegen",
"codegen": "npm run graphql:codegen && npm run swagger:codegen && npm run typechain:codegen",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"graphql:codegen": "graphql-codegen --config graphql-codegen.yml",
"swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/v2.117.1/crates/orderbook/openapi.yml --output src/order-book/generated --exportServices false --exportCore false"
"swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/v2.117.1/crates/orderbook/openapi.yml --output src/order-book/generated --exportServices false --exportCore false",
"typechain:codegen": "typechain --target ethers-v5 --out-dir ./src/composable/generated './abi/*.json'"
},
"dependencies": {
"@cowprotocol/contracts": "^1.4.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@openzeppelin/merkle-tree": "^1.0.5",
"exponential-backoff": "^3.1.1",
"limiter": "^2.1.0",
"cross-fetch": "^3.1.5",
Expand All @@ -48,6 +50,7 @@
"@graphql-codegen/cli": "3.0.0",
"@graphql-codegen/typescript": "3.0.0",
"@graphql-codegen/typescript-operations": "^3.0.0",
"@typechain/ethers-v5": "^11.0.0",
"@types/jest": "^29.4.0",
"@types/node": "^18.13.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
Expand All @@ -66,6 +69,7 @@
"prettier": "^2.5.1",
"ts-mockito": "^2.6.1",
"tsc-watch": "^6.0.0",
"typechain": "^8.2.0",
"typescript": "^4.9.5"
},
"jest": {
Expand All @@ -76,6 +80,9 @@
],
"collectCoverageFrom": [
"src/**/*.{ts,tsx}"
],
"coveragePathIgnorePatterns": [
"src/composable/generated"
]
},
"keywords": [
Expand Down
Loading