generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add universal router #2
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e166794
chore: upgrade dependencies
fubuloubu e128f6b
feat: add start of Universal Router encoder/decoder algorithm
fubuloubu a85b4e6
feat: add Permit2 types
fubuloubu ade4078
chore: deprecate py3.7, add py3.11 and 3.12
fubuloubu 85c7182
chore: update CI for py3.11+ and downgrade macos for fix
fubuloubu aa67ee1
style: fix black styling
fubuloubu d660914
fix: remove number of args from inner callable for typing
fubuloubu 0f1afea
fix: update lower pin on ethpm-types for mypy fix; widen ape pin
fubuloubu 8e2707d
fix: universal router class (still WIP, but no type issues)
fubuloubu 3a2c487
refactor: typing and clarity improvements
fubuloubu 6f104e0
feat: implement all universal router command encodings (#3)
banteg 2305829
feat: config Uniswap projects for compiling manifests for project
fubuloubu bd6b26e
feat: add all known deployments of Singleton contracts for v2/v3/ur/p2
fubuloubu 5c44162
chore: add manifests as package resources to package
fubuloubu ae3780b
feat: add UniversalRouter class
fubuloubu dbd7483
refactor: update UniversalRouter class to work
fubuloubu ac8263c
refactor: decode v3 path to show
fubuloubu 7749dbf
fix: lint issues
fubuloubu e48dfbc
docs: add docs for Plan and UniversalRouter
fubuloubu 25a9442
refactor: remove .inject function
fubuloubu 672edbf
feat: add Plan class
fubuloubu bf6086e
refactor: fix docstring and add constants for easier use
fubuloubu 74d361d
docs: add link to where I got the deploy addresses from
fubuloubu dd23dc9
refactor: add `__dir__` to Plan and also some TODOs
fubuloubu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# NOTE: We don't need this other than for copying over the manifests to build with the | ||
# python package, and for testing | ||
|
||
plugins: | ||
# For compiling contracts | ||
- name: solidity | ||
# For fork testing | ||
- name: foundry | ||
|
||
dependencies: | ||
- name: uniswap-v3 | ||
github: Uniswap/v3-core | ||
ref: v1.0.0 | ||
|
||
- name: uniswap-v2 | ||
github: Uniswap/v2-core | ||
ref: v1.0.1 | ||
|
||
- name: permit2 | ||
github: Uniswap/permit2 | ||
ref: main | ||
config_override: | ||
solidity: | ||
via_ir: True # NOTE: Trouble compiling without this | ||
|
||
- name: universal-router | ||
github: Uniswap/universal-router | ||
ref: v1.6.0 | ||
config_override: | ||
dependencies: | ||
- name: openzeppelin | ||
github: OpenZeppelin/openzeppelin-contracts | ||
ref: v4.7.0 | ||
solidity: | ||
import_remapping: | ||
- "permit2=permit2" | ||
- "@uniswap/v3-core=uniswap-v3" | ||
- "@uniswap/v2-core=uniswap-v2" | ||
via_ir: True # NOTE: Trouble compiling without this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from pathlib import Path | ||
|
||
from ape import project | ||
from ethpm_types import ContractType | ||
|
||
PACKAGE_FOLDER = Path(__file__).parent.parent / "uniswap_sdk" | ||
|
||
|
||
def clean_contract_type(contract_type): | ||
clean_model_dict = contract_type.model_dump( | ||
exclude={ | ||
"ast", | ||
"deployment_bytecode", | ||
"runtime_bytecode", | ||
"source_id", | ||
"pcmap", | ||
"dev_messages", | ||
"sourcemap", | ||
"userdoc", | ||
"devdoc", | ||
"method_identifiers", | ||
} | ||
) | ||
return ContractType.model_validate(clean_model_dict) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
|
||
def clean_manifest(manifest, *contract_types_to_keep): | ||
manifest.contract_types = { | ||
k: clean_contract_type(v) | ||
for k, v in manifest.contract_types.items() | ||
if k in contract_types_to_keep | ||
} | ||
return manifest.model_dump_json( | ||
exclude={ | ||
"meta", | ||
"dependencies", | ||
"sources", | ||
"compilers", | ||
} | ||
) | ||
|
||
|
||
def main(): | ||
manifest_json = clean_manifest( | ||
project.dependencies["uniswap-v2"]["v1.0.1"].extract_manifest(), | ||
"UniswapV2Factory", | ||
"UniswapV2Pair", | ||
) | ||
(PACKAGE_FOLDER / "v2-manifest.json").write_text(manifest_json) | ||
|
||
manifest_json = clean_manifest( | ||
project.dependencies["uniswap-v3"]["v1.0.0"].extract_manifest(), | ||
"UniswapV3Factory", | ||
"UniswapV3Pool", | ||
) | ||
(PACKAGE_FOLDER / "v3-manifest.json").write_text(manifest_json) | ||
|
||
manifest_json = clean_manifest( | ||
project.dependencies["permit2"]["main"].extract_manifest(), | ||
"Permit2", | ||
) | ||
(PACKAGE_FOLDER / "permit2-manifest.json").write_text(manifest_json) | ||
|
||
manifest_json = clean_manifest( | ||
project.dependencies["universal-router"]["v1.6.0"].extract_manifest(), | ||
"UniversalRouter", | ||
) | ||
(PACKAGE_FOLDER / "unirouter-manifest.json").write_text(manifest_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: add types!