Compare commits

...

156 Commits

Author SHA1 Message Date
Github Actions
e0d705703d Publish
- @0x/contracts-erc20@3.3.35
 - @0x/contracts-test-utils@5.4.26
 - @0x/contracts-treasury@1.4.18
 - @0x/contracts-utils@4.8.16
 - @0x/contracts-zero-ex@0.36.2
 - @0x/asset-swapper@16.66.2
 - @0x/contract-addresses@6.19.1
 - @0x/contract-wrappers@13.20.7
 - @0x/protocol-utils@11.16.2
2022-08-09 19:27:28 +00:00
Github Actions
01a6d933ca Updated CHANGELOGS & MD docs 2022-08-09 19:27:24 +00:00
Kyu
9b9f0b91d7 Move woofi tokens to constant.ts and run prettier (#544) 2022-08-09 13:31:37 +09:00
Ido Kleinman
0d0fef841d PR # 2022-08-08 19:04:04 -05:00
Ido Kleinman
17adfbea32 changelogs 2022-08-08 19:04:04 -05:00
Noah Khamliche
80594622b2 empty commit to run workflow 2022-08-08 18:55:39 -05:00
Ido Kleinman
0dba5a5a3a lowercase addresses (#542) 2022-08-08 16:40:31 -07:00
phil-ociraptor
4dae8de1b6 feat: add Foundry support to contracts/zero-ex (#534)
Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
2022-08-08 11:46:50 -05:00
eobbad
0046bb26d8 Update WooFi sampler logicand addresses.json w/ new FQT's 2022-08-08 12:27:45 -04:00
Kyu
fe935f787c Use @0x/fast-abi instead of deprecated fast-abi (#540) 2022-08-08 14:34:48 +09:00
Kyu
1b527ffcd8 Clean up Mirror and UST related stuff (#539) 2022-08-08 12:29:33 +09:00
Github Actions
9f5324d9c3 Publish
- @0x/asset-swapper@16.66.1
2022-08-08 02:47:26 +00:00
Github Actions
3647392a04 Updated CHANGELOGS & MD docs 2022-08-08 02:47:21 +00:00
Kyu
1d49662c58 Upgrade fast-abi (#538) 2022-08-08 11:27:44 +09:00
Github Actions
6324b08b4d Publish
- @0x/contracts-erc20@3.3.34
 - @0x/contracts-test-utils@5.4.25
 - @0x/contracts-treasury@1.4.17
 - @0x/contracts-utils@4.8.15
 - @0x/contracts-zero-ex@0.36.1
 - @0x/asset-swapper@16.66.0
 - @0x/contract-addresses@6.19.0
 - @0x/contract-wrappers@13.20.6
 - @0x/protocol-utils@11.16.1
2022-08-06 01:52:58 +00:00
Github Actions
fe73b63aaa Updated CHANGELOGS & MD docs 2022-08-06 01:52:55 +00:00
Kyu
192d0b17d9 Empty commit to trigger CI (something is wrong with Ido's account lol) 2022-08-06 10:34:15 +09:00
Ido Kleinman
aa74d04083 new contract address for goerli verified deploy (#537)
* new contract address for goerli verified deploy

* v6.18.0

* updated addresses for goerli + mumbai to verified contracts

* contract addresses changelog update

* unbump package version
2022-08-05 18:22:06 -07:00
Kyu
d586f5727d Rename Balancer pool cache files (#536) 2022-08-05 17:53:55 +09:00
Kyu
98fc79a085 Upgrade dependencies in asset-swapper to match the versions used in 0x-api [TKR-484] (#535)
* Upgrade dependencies to match the versions used in 0x-api

* Fix/disable tslint issues from the new version
2022-08-05 14:26:18 +09:00
eobbad
c12a10b96e Add WooFI support (#513)
* Add WooFI interface for sampling

* WooFi Sampler

* Add mixin

* Update bridge adapters

* fix some bugs

* update transformer_utils

* Add BSC support

* yarn prettier

* Capitalize WOOFI in bridge adapters

* Put rebateAddress in a constant, fixed some other stylistic errors

* bug fixes

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/contracts-erc20@3.3.33
 - @0x/contracts-test-utils@5.4.24
 - @0x/contracts-treasury@1.4.16
 - @0x/contracts-utils@4.8.14
 - @0x/contracts-zero-ex@0.36.0
 - @0x/asset-swapper@16.64.0
 - @0x/contract-addresses@6.17.0
 - @0x/contract-wrappers@13.20.5
 - @0x/protocol-utils@11.16.0

* Update reference.mdx (#531)

Align with `DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE` value from c74e31c219/src/constants.ts (L26)

* code cleanup

* remove deusdc curve pool from this pr

* Refactor PoolsCache (part 1) [TKR-500] (#525)

* Make _refreshPoolCacheIfRequiredAsync type-safe and remove Promise.all

* Factor out PoolsCache key logic into a function

* Use Map instead of object in PoolsCache and increase the default timeout

* Clean up PoolsCache and simplify its public interface

* Refactor PoolsCache (part 2) [TKR-500]  (#526)

* Introduce NoOpPoolsCache and use it in unsupported chains for BeethovenX

* Use `NoOpPoolsCache` for `CreamPoolsCache` and `BalancerPoolsCache` on unsupported chains

* Remove `getBidAskLiquidityForMakerTakerAssetPairAsync` (#528)

* Add transfer approval for quote token for multi-hops and fix buy sampler typo

* Use 0x gas api instead of eth gas station api [TKR-502] (#532)

* Use 0x gas api instead of eth gas station api

* Add integration test for `ProtocolFeeUtils`

* Update CHANGELOG.json

* Add polygon, fantom, avalanche support

* yarn prettier

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/asset-swapper@16.65.0

* Remove references to `custom-no-magic-numbers` ts lint rule [TKR-484] (#533)

* Remove references to `custom-no-magic-numbers ts` lint rule

* Run prettier

* resolve Kyu's comments

* remove fqt change

* Add WooFI interface for sampling

* WooFi Sampler

* Add mixin

* Update bridge adapters

* fix some bugs

* update transformer_utils

* Add BSC support

* yarn prettier

* Capitalize WOOFI in bridge adapters

* Put rebateAddress in a constant, fixed some other stylistic errors

* bug fixes

* code cleanup

* remove deusdc curve pool from this pr

* Add transfer approval for quote token for multi-hops and fix buy sampler typo

* Add polygon, fantom, avalanche support

* yarn prettier

* resolve Kyu's comments

* remove fqt change

* merge types.ts

* WOOFi -> WOOFI

* fix lerna run lint

* Changelog

* nit changes

Co-authored-by: Github Actions <github-actions@github.com>
Co-authored-by: Pavel <51318041+pavel-bc@users.noreply.github.com>
Co-authored-by: Kyu <kyuhyun217@gmail.com>
2022-08-03 15:54:09 -04:00
Kyu
d3d4a08f91 Remove references to custom-no-magic-numbers ts lint rule [TKR-484] (#533)
* Remove references to `custom-no-magic-numbers ts` lint rule

* Run prettier
2022-08-01 17:50:40 -07:00
Github Actions
9ce090c8cd Publish
- @0x/asset-swapper@16.65.0
2022-08-01 22:10:47 +00:00
Github Actions
980d60deb8 Updated CHANGELOGS & MD docs 2022-08-01 22:10:42 +00:00
Kyu
d6d79e51e7 Use 0x gas api instead of eth gas station api [TKR-502] (#532)
* Use 0x gas api instead of eth gas station api

* Add integration test for `ProtocolFeeUtils`

* Update CHANGELOG.json
2022-08-01 14:42:45 -07:00
Kyu
3ef5de93bb Remove getBidAskLiquidityForMakerTakerAssetPairAsync (#528) 2022-07-28 09:26:07 -07:00
Kyu
ab7dc33ca4 Refactor PoolsCache (part 2) [TKR-500] (#526)
* Introduce NoOpPoolsCache and use it in unsupported chains for BeethovenX

* Use `NoOpPoolsCache` for `CreamPoolsCache` and `BalancerPoolsCache` on unsupported chains
2022-07-28 09:12:02 -07:00
Kyu
14dcee5bb6 Refactor PoolsCache (part 1) [TKR-500] (#525)
* Make _refreshPoolCacheIfRequiredAsync type-safe and remove Promise.all

* Factor out PoolsCache key logic into a function

* Use Map instead of object in PoolsCache and increase the default timeout

* Clean up PoolsCache and simplify its public interface
2022-07-28 09:04:42 -07:00
Pavel
9856e78609 Update reference.mdx (#531)
Align with `DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE` value from c74e31c219/src/constants.ts (L26)
2022-07-27 12:35:16 -07:00
Github Actions
2801b066b3 Publish
- @0x/contracts-erc20@3.3.33
 - @0x/contracts-test-utils@5.4.24
 - @0x/contracts-treasury@1.4.16
 - @0x/contracts-utils@4.8.14
 - @0x/contracts-zero-ex@0.36.0
 - @0x/asset-swapper@16.64.0
 - @0x/contract-addresses@6.17.0
 - @0x/contract-wrappers@13.20.5
 - @0x/protocol-utils@11.16.0
2022-07-27 19:32:19 +00:00
Github Actions
5bc8b13fc3 Updated CHANGELOGS & MD docs 2022-07-27 19:32:17 +00:00
Kyu
36dba8f5be Update FQT addresses on mainnet and Optimism (#530) 2022-07-27 09:56:50 -07:00
Kyu
ee2c069889 Remove Mooniswap on Ethereum Mainnet (#529)
* Remove Mooniswap from EthereumBridgeAdapter

* Remove Mooniswap sampling on mainnet

* Update CHANGELOG.json
2022-07-27 08:09:27 -07:00
Kyu
6ca14ed7b2 Fix Beethoven X Cache Issue [TKR-486] (#519)
* Replace Beethoven X subgraph url and add a test

* Simplify PoolsCacheMap type

* Make `BalancerV2PoolsCache` optional for Beethoven X

* Update CHANGELOG.json
2022-07-26 09:54:05 -07:00
Kyu
a5babb9a34 Add Synthetix Atomic Swap support [TKR-324] (#518)
* Implement SyntehtixSampler

* Implement MixinSynthetix

* Update transformer_utils.ts

* Add Synthetix mainnet support

* Add Synthetix optimism support

* Fine-tune gas schedule

* Pass read proxy dynamically to SynthetixSampler

* Pass read proxy dynamically to SynthetixMixin

* Fetch Synthetix address from sampler

* Pass Synthetix address directly to MixinSynthetix

* Update CHANGELOG.json
2022-07-25 21:17:27 -07:00
Kyu
661cc4669d Fix formatting 2022-07-22 16:25:31 -07:00
Ido Kleinman
553ba5c868 Add Goerli and Mumbai liquidity and support [TKR-493] (#523)
* deployment contract addresses on goerli

* add Goerli chainID and liquidity support for Sushi, Uni1,2,3

* UniV1 fix for Goerli

* add UniV3 to Mumbai

* remove comments

* lowercase addresses

* update contract-addresses package version

* reset package.json's states
2022-07-22 16:12:58 -07:00
Kyu
d03d2f254d Remove unused dependencies in asset-swapper [TKR-484] (#521)
* Remove unused dependencies

* Remove unused devDependencies
2022-07-19 16:44:40 -07:00
Kyu
feb91a04b0 Fix typos in GMX sampling logic (#520) 2022-07-19 16:18:37 -07:00
Kyu
4d63f33aba Update CODEOWNERS (#522) 2022-07-19 16:09:42 -07:00
Kyu
b72b8b5ffd Refactor TokenAdjacency and TokenAdjacencyBuilder [TKR-324] (#517)
* Add a new TokenAdjacencyGraph implementation

* Replace old TokenAdjacencyGraph with new implementation

* Simplify token adjacency graph in constants.ts

* Fix lint error

* Update CHANGELOG.json
2022-07-18 13:02:56 -07:00
Github Actions
f7cb7a0f51 Publish
- @0x/asset-swapper@16.63.1
2022-07-12 21:26:51 +00:00
Github Actions
9fcb28f5d8 Updated CHANGELOGS & MD docs 2022-07-12 21:26:48 +00:00
Kyu
982173471c Wrap balancer fetch top pools with try and catch [TKR-481] (#515)
* Wrap balancer fetch top pool with try and catch

* Update CHANGELOG.json
2022-07-12 13:50:07 -07:00
Github Actions
e77958425f Publish
- @0x/asset-swapper@16.63.0
2022-06-29 08:36:38 +00:00
Github Actions
6af4d71573 Updated CHANGELOGS & MD docs 2022-06-29 08:36:34 +00:00
Jacob Evans
ee985240fb chore: FillAdjustor and clean up JS router and unused functions [TKR-403] (#480)
* Remove old JS router and add a FillAdjustor

Clean up JS router and unused functions

Remove more unused functions, add adjustment of fills

Comment on why we use fill over sample

update CODEOWNERS

lint

Clean up Fill removing unused properties

Remove CollapsedFills, omit flags bigint

Create GasSchedule vs FeeSchedule, return Fill and gas on OptimizedOrder

Use Fill Adjustment in Phase2 of routing

Fix Limit orders being treated as VIP

* Fix case where dex liquidity is empty

* Use best gas adjusted pricing for fee sources

* CHANGELOG
2022-06-29 18:10:56 +10:00
eobbad
2aadbda527 Offboard Smoothy and ComethSwap (#509)
* Offboard ComethSwap

* offboard smoothy

* Changelog + yarn prettier
2022-06-22 18:36:52 +02:00
Github Actions
297c73abcc Publish
- @0x/asset-swapper@16.62.1
2022-06-15 00:40:27 +00:00
Github Actions
4c9e1b21ec Updated CHANGELOGS & MD docs 2022-06-15 00:40:24 +00:00
Kyu
41685d1545 Empty commit to trigger CI 2022-06-14 17:16:23 -07:00
Ido Kleinman
b9c25112ed Remove nUSD from intermediate liquidity to save on sampler gas (#505)
* remote nUSD from intermediate liquidity

* changelog
2022-06-14 16:07:47 -07:00
Github Actions
f0738fc122 Publish
- @0x/contracts-erc20@3.3.32
 - @0x/contracts-test-utils@5.4.23
 - @0x/contracts-treasury@1.4.15
 - @0x/contracts-utils@4.8.13
 - @0x/contracts-zero-ex@0.35.0
 - @0x/asset-swapper@16.62.0
 - @0x/contract-addresses@6.16.0
 - @0x/contract-wrappers@13.20.4
 - @0x/protocol-utils@11.15.0
2022-06-14 22:16:09 +00:00
Github Actions
42baf504b7 Updated CHANGELOGS & MD docs 2022-06-14 22:16:07 +00:00
Kyu
56038d122f Update Ethereum and Optimism FQT addresses (#504) 2022-06-14 14:45:26 -07:00
eobbad
c4446b6c0e Offboard Jetswap, CafeSwap, JulSwap, and PolyDex (#503)
* Offboard Jetswap

* Offboarded CafeSwap

* Offboarded JulSwap

* Offboarded PolyDex

* Changelog

* Update changelog

* Changelog update
2022-06-14 23:05:53 +02:00
eobbad
eaed2958c3 KnightSwap and Mdex cosmetic changes (#502)
* Lowercased KnightSwap and MDEX router address

* Changelog.JSON
2022-06-14 14:45:47 +02:00
Jorge Pérez
a045a3afb8 Chore: Do not send empty entries on Quote Report (#501)
* Chore: Do not send empty entries on Quote Report

* Changelog
2022-06-13 15:52:59 -05:00
Kyu
1cc59ab1ab feat: Add Velodrome support [TKR-432] (#494)
* Implement MixinVelodrome

* Add preliminary implementation of VelodromeSampler

* Add Velodrome in BridgeProtocol of transformer_utils.ts

* Fix MixinVelodrome

* Wire Velodrome sampler in market_operation_utils

* Fix lint error

* Remove gas schedule TODO

* Format VelodromeSampler.sol

* Fix MixinVelodrome

* Update CHANGELOG.json
2022-06-13 11:55:40 -07:00
Kyu
2c6a714b71 Fix a lint error in CHANGELOG.json 2022-06-13 10:41:58 -07:00
Kyu
d8c97d6720 Fix a lint error introduced in earlier PRs 2022-06-13 09:09:13 -07:00
eobbad
d6bc702550 Add KnightSwap on BSC (#498)
* Curve pool script to generate pools and their info. Still need to integrate into API

* Added MDEX to BSC

* Removed curve automation scripts from this PR

* Fixed typo

* Changelog

* fix formatting

* Fixed yarn lint

* Add KnightSwap

* Changelog

* update changelog

* changelog again...
2022-06-10 16:57:42 +02:00
eobbad
2838cb9420 Add MDEX support (BSC) [TKR-426] (#496)
* Curve pool script to generate pools and their info. Still need to integrate into API

* Added MDEX to BSC

* Removed curve automation scripts from this PR

* Fixed typo

* Changelog

* fix formatting

* Fixed yarn lint
2022-06-10 14:14:08 +02:00
Github Actions
b10cfc50d3 Publish
- @0x/contracts-erc20@3.3.31
 - @0x/contracts-test-utils@5.4.22
 - @0x/contracts-treasury@1.4.14
 - @0x/contracts-utils@4.8.12
 - @0x/contracts-zero-ex@0.34.0
 - @0x/asset-swapper@16.61.0
 - @0x/contract-addresses@6.15.0
 - @0x/contract-wrappers@13.20.3
 - @0x/protocol-utils@11.14.0
2022-06-03 19:20:52 +00:00
Github Actions
2e6317b01e Updated CHANGELOGS & MD docs 2022-06-03 19:20:49 +00:00
Noah Khamliche
50e99e6eac address comments 2022-06-03 15:03:00 -04:00
Noah Khamliche
8f2f4554eb fix linting 2022-06-03 15:03:00 -04:00
Noah Khamliche
67d9678a3a fix linting 2022-06-03 15:03:00 -04:00
Noah Khamliche
f70341fb48 rebase development 2022-06-03 15:03:00 -04:00
Megan
14cd24ea47 feat/add MeshSwap on Polygon [TKR-374] (#491)
* Added MeshSwap on Polygon

* Updated changelog
2022-06-03 15:03:00 -04:00
Noah Khamliche
78328056d7 Added BancorV3 to fqt, and added support in asset-swapper 2022-06-03 15:03:00 -04:00
Noah Khamliche
0045a60b0f updated contract-addresses with new ethereum fqt 2022-06-03 15:03:00 -04:00
Noah Khamliche
e4e71c76e1 add weth/eth wrap/unwrap support for bancorv3 2022-06-03 15:03:00 -04:00
Megan
ca8127545f feat/add MeshSwap on Polygon [TKR-374] (#491)
* Added MeshSwap on Polygon

* Updated changelog
2022-06-03 15:03:00 -04:00
Noah Khamliche
7b709089ce fix versioning issue on protocol-utils 2022-06-03 15:03:00 -04:00
Noah Khamliche
190f7e45f2 final changes 2022-06-03 15:03:00 -04:00
Noah Khamliche
0dcc3a6fc3 nitpicks 2022-06-03 15:03:00 -04:00
Noah Khamliche
c2e8cae293 added changelog entries 2022-06-03 15:03:00 -04:00
Noah Khamliche
83da7caab4 fixed bancor sell quotes 2022-06-03 15:03:00 -04:00
Noah Khamliche
fd69a0c273 added weth/eth support to sampler 2022-06-03 15:03:00 -04:00
Noah Khamliche
9b131199ad add weth/eth wrap/unwrap support for bancorv3 2022-06-03 15:03:00 -04:00
Noah Khamliche
f5c486050b added bancor mixin/sampler and started linking up with asset-swapper 2022-06-03 15:03:00 -04:00
Megan
1f41fe6a20 feat/add MeshSwap on Polygon [TKR-374] (#491)
* Added MeshSwap on Polygon

* Updated changelog
2022-06-02 19:11:25 +02:00
Kyu
7f4080e0a2 Delete packages/migrations (#488)
* Delete packages/migrations

* Remove 0x/migrations from asset-swapper dev dependency

* Remove 0x/migrations references
2022-06-02 10:00:50 -07:00
Kyu
db76da58d7 Add stETH wrap/unwrap support [TKR-377] (#476)
* Update MixinLido to support stETH wrapping/unwrapping

* Update LidoSampler and asset-swapper

* Re-use token address constants in LIDO_INFO_BY_CHAIN

* Update CHANGELOG.json

* Add stETH <-> wstETH to TokenAdjacencyGraph

* Change lido gas schedule code style

* Move allowance approval inside the wrap branch

* Refactor LidoSampler to reduce its bytecode size
2022-05-31 09:58:44 -07:00
mzhu25
cf8fc0ff8e Split up BridgeAdapter by chain [TKR-402] (#487)
* Split up BridgeAdapter by chain

* Fix BridgeProtocols enum

* Add isSupportedSource to bridge adapter contracts

* Add bridge adapter tests

* Fix FQT test
2022-05-25 14:18:24 -04:00
Kyu
2d16f83e37 Offboard/clean up Oasis, CoFix, and legacy Kyber [TKR-405] (#482)
* Remove Oasis

* Remove CoFix code

* Remove MixinKyber

* Remove Kyber from asset-swapper

* Delete unused imports, interface, and etc.

* Fix the test failure issue when it's run with neon-router

* Update CHANGELOG.json
2022-05-19 17:39:02 -07:00
Github Actions
4057bdab91 Publish
- @0x/asset-swapper@16.60.1
2022-05-19 03:40:00 +00:00
Github Actions
1cd10f0ac9 Updated CHANGELOGS & MD docs 2022-05-19 03:39:57 +00:00
Jacob Evans
68f87b2432 fix: BalancerV2 sor alias (#481)
* Install both Balancer sor and rename early version to v1

* yarn.lock

* CHANGELOG
2022-05-19 13:19:25 +10:00
Github Actions
69bafc3bcd Publish
- @0x/contracts-erc20@3.3.30
 - @0x/contracts-test-utils@5.4.21
 - @0x/contracts-treasury@1.4.13
 - @0x/contracts-utils@4.8.11
 - @0x/contracts-zero-ex@0.33.0
 - @0x/asset-swapper@16.60.0
 - @0x/contract-addresses@6.14.0
 - @0x/contract-wrappers@13.20.2
 - @0x/migrations@8.1.19
 - @0x/protocol-utils@11.13.0
2022-05-19 00:21:50 +00:00
Github Actions
2c44b06b7b Updated CHANGELOGS & MD docs 2022-05-19 00:21:47 +00:00
Kyu
0233f00b4e Increase KyberDMM base gas [TKR-317] (#479)
* Increase KyberDMM base gas

* Update CHANGELOG.json
2022-05-18 17:00:11 -07:00
Kyu
fedb53187d Add Yoshi Exchange support (Fantom) [TKR-270] (#473)
* Resolve conflicts

* Update CHANGELOG.json
2022-05-18 16:58:41 -07:00
Noah Khamliche
6774d2f588 prettier and lint everything 2022-05-18 19:53:50 -04:00
Noah Khamliche
cf740b74f5 removed extraneous comments in sampler 2022-05-18 19:53:50 -04:00
Noah Khamliche
177c00463a comments and nits 2022-05-18 19:53:50 -04:00
Noah Khamliche
49b0e32129 added address ref from AVALANCHE_TOKENS for mim instead of raw address 2022-05-18 19:53:50 -04:00
Noah Khamliche
938fc94756 final deployments and updates for bridge adapter and fqt on avax/bsc 2022-05-18 19:53:50 -04:00
Noah Khamliche
1561d91c2b added changelog entries 2022-05-18 19:53:50 -04:00
Noah Khamliche
9a28e51f51 rebased dev and merged 2022-05-18 19:53:50 -04:00
Ido Kleinman
f55eaa867b Add BiSwap (as UniV2 clone) on BSC (#471)
* Add BiSwap (as UniV2 clone) on BSC

* changelog PR number

* add BSW

* remove BiSwap from transformer_utils

* Do not initialize BalancerV2SwapInfoCache on unsupported chains [TKR-365] (#472)

* Do not initialize BalancerV2SwapInfoCache on unsupported chains
* Update CHANGELOG.json

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/asset-swapper@16.57.3

* chore: Decomission SnowSwap [TKR-356] (#468)

* Decomission SnowSwap

* SnowSwap doesn't have much liquidity anymore (the largest pool has ~$50k)

* Update CHANGELOG.json

* Update CHANGELOG.json

* chore: Offboard Swerve Finance and LinkSwap [TKR-356] (#469)

* Offboard swerve

* Update CHANGELOG.json

* Offboard LinkSwap

* Remove unused import

* Fix CHANGELOG.json

* chore: Offboard Eth2Dai [TKR-356] (#470)

* Offboard Eth2Dai

* Update CHANGELOG.json

* feat: add IRfqClient (#467)

* add message to changelog for #467 (#474)

* Update saddle mainnet pools (#450)

* Add saddle v2 pools

* remove outdated pools

* add two saddle meta pools

* forgot changelog

* remove saddle metapools

* changelog update

* Fix a lint issue (#475)

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/asset-swapper@16.59.0

* Add BiSwap (as UniV2 clone) on BSC

* rebase new changes for balv2, up changelog, quotes working

* remove Biswap from transformer_utils once again

Co-authored-by: Kyu <kyuhyun217@gmail.com>
Co-authored-by: Github Actions <github-actions@github.com>
Co-authored-by: phil-ociraptor <phil@0x.org>
Co-authored-by: Cece Z <me@cecez.xyz>
Co-authored-by: Noah Khamliche <noah@0xproject.com>
2022-05-16 17:11:23 -07:00
Github Actions
6b2856424a Publish
- @0x/asset-swapper@16.59.0
2022-05-13 00:07:18 +00:00
Github Actions
da757c4700 Updated CHANGELOGS & MD docs 2022-05-13 00:07:16 +00:00
Kyu
75e6654884 Fix a lint issue (#475) 2022-05-12 16:49:10 -07:00
Cece Z
87308e7693 Update saddle mainnet pools (#450)
* Add saddle v2 pools

* remove outdated pools

* add two saddle meta pools

* forgot changelog

* remove saddle metapools

* changelog update
2022-05-12 18:59:55 -04:00
phil-ociraptor
d5eef93a76 add message to changelog for #467 (#474) 2022-05-11 22:17:17 -05:00
phil-ociraptor
a7f23a982e feat: add IRfqClient (#467) 2022-05-11 12:35:05 -05:00
Kyu
9eadc5fc28 chore: Offboard Eth2Dai [TKR-356] (#470)
* Offboard Eth2Dai

* Update CHANGELOG.json
2022-05-10 13:54:28 -07:00
Kyu
92ad1a612e chore: Offboard Swerve Finance and LinkSwap [TKR-356] (#469)
* Offboard swerve

* Update CHANGELOG.json

* Offboard LinkSwap

* Remove unused import

* Fix CHANGELOG.json
2022-05-10 13:13:18 -07:00
Kyu
09413c0e12 chore: Decomission SnowSwap [TKR-356] (#468)
* Decomission SnowSwap

* SnowSwap doesn't have much liquidity anymore (the largest pool has ~$50k)

* Update CHANGELOG.json

* Update CHANGELOG.json
2022-05-10 09:55:43 -07:00
Github Actions
23788b41d5 Publish
- @0x/asset-swapper@16.57.3
2022-05-10 01:41:10 +00:00
Github Actions
ccf999a495 Updated CHANGELOGS & MD docs 2022-05-10 01:41:06 +00:00
Kyu
aa1016ee5f Do not initialize BalancerV2SwapInfoCache on unsupported chains [TKR-365] (#472)
* Do not initialize BalancerV2SwapInfoCache on unsupported chains
* Update CHANGELOG.json
2022-05-09 18:21:04 -07:00
Github Actions
423ef57344 Publish
- @0x/asset-swapper@16.57.2
2022-05-02 21:22:37 +00:00
Github Actions
c18149e82f Updated CHANGELOGS & MD docs 2022-05-02 21:22:33 +00:00
Jorge Pérez
d14aebf724 Fix the filter for considered sources on indicative sells for Quote Report (#466) 2022-05-02 15:45:15 -05:00
Kyu
ba719a9631 Add cvxfxs-fxs curve pool on Ethereum mainnet (#465)
* Add cvxfxs-fxs curve pool on Ethereum mainnet

* Update CHANGELOG.json

* Fix an existing formatting issue

* Adjust gasSchedule and merge the change under 16.57.1
2022-04-27 17:07:36 -07:00
eobbad
d36034d958 chore/ANY-QUICK on polygon MAG-MIM on avax (#464)
* Added ANY/QUICK pair on Polygon

* Updated changelog.json

* Update CHANGELOG.json
2022-04-26 10:55:03 -04:00
Github Actions
7750c57620 Publish
- @0x/contracts-erc20@3.3.29
 - @0x/contracts-test-utils@5.4.20
 - @0x/contracts-treasury@1.4.12
 - @0x/contracts-utils@4.8.10
 - @0x/contracts-zero-ex@0.32.0
 - @0x/asset-swapper@16.57.0
 - @0x/contract-addresses@6.13.0
 - @0x/contract-wrappers@13.20.1
 - @0x/migrations@8.1.18
 - @0x/protocol-utils@11.12.0
2022-04-22 07:05:10 +00:00
Github Actions
4d027e11d1 Updated CHANGELOGS & MD docs 2022-04-22 07:05:06 +00:00
Lawrence Forman
470e9a4697 AS: Balancer V2 batchSwap (#462)
* Draft. PoC pseudo code showing general idea for resuing SOR path creation logic and adding multihop support.

* Add actual Balancer SDK function calls.

* Update to handle buys.

* Correct taker>maker for buy.

* Draft. PoC pseudo code showing general idea for resuing SOR path creation logic and adding multihop support.

* make it build

* rebase

* add BalancerV2Batch protocol

* add BalancerV2Batch protocol

* get balancer v2 multihop working

* fix BalancerV2Batch for sells (buys still iffy)

* fix buys, appease linter and prettier

* remove unused RPC URL from balancer sdk construction

* update changelogs

* clean up comments
add event loop yield in `BalancerV2SwapInfoCache.loadTopPools()`

* add negative result check on balancerv2batch swap output

* compiler hack

* reintroduce CompilerHack

* delete unused multibridge sampler

* remove compilerhack

* reintroduce compilerhack

* try to fix CI compile errors

* plz work

* plz work

* pretty plz work

* yay it works, also address feedback

* appease linter

* deploy new FQTs

Co-authored-by: johngrantuk <johngrantuk@googlemail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-04-22 02:43:41 -04:00
Github Actions
7c51412e2f Publish
- @0x/asset-swapper@16.56.0
2022-04-21 21:16:27 +00:00
Github Actions
b3d1f3cd10 Updated CHANGELOGS & MD docs 2022-04-21 21:16:23 +00:00
mzhu25
389bb77439 Add estimatedGas to ExtendedQuoteReport (#463) 2022-04-21 13:52:13 -07:00
Github Actions
4327885a00 Publish
- @0x/asset-swapper@16.55.0
2022-04-07 16:07:52 +00:00
Github Actions
0aef0afbbb Updated CHANGELOGS & MD docs 2022-04-07 16:07:49 +00:00
Lawrence Forman
fa4c3a4f5f fix quote consumer RFQ VIP code path not checking if transfromERC20 is required (#461)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-04-07 11:58:07 -04:00
Github Actions
1d7c527c5c Publish
- @0x/asset-swapper@16.54.0
2022-04-06 03:26:22 +00:00
Github Actions
cbe3135e4b Updated CHANGELOGS & MD docs 2022-04-06 03:26:18 +00:00
Lawrence Forman
955ad49711 add real VIP support for eligible RFQT swaps (#458)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-04-05 23:00:12 -04:00
Github Actions
8d6f6e76e0 Publish
- @0x/contracts-erc20@3.3.28
 - @0x/contracts-test-utils@5.4.19
 - @0x/contracts-treasury@1.4.11
 - @0x/contracts-utils@4.8.9
 - @0x/contracts-zero-ex@0.31.2
 - @0x/asset-swapper@16.53.0
 - @0x/contract-addresses@6.12.1
 - @0x/contract-artifacts@3.18.0
 - @0x/contract-wrappers@13.20.0
 - @0x/migrations@8.1.17
 - @0x/protocol-utils@1.11.2
2022-03-31 15:09:24 +00:00
Github Actions
9337115650 Updated CHANGELOGS & MD docs 2022-03-31 15:09:21 +00:00
Kim Persson
fa45a44fe4 fix: use Node 16 for publish GH action (#457) 2022-03-31 16:47:02 +02:00
Kim Persson
c9c7ac8559 feat: add block number to quote report data [TKR-314] (#448)
* feat: add blockNumber to MarketSideLiquidity response

* fix: return block number back in swap quote response

* chore: add asset-swapper changelog entry
2022-03-31 15:42:34 +02:00
Kim Persson
c881723578 feat: use neon-router in CI tests (#453)
* fix: initially skip all tests that don't work with the Rust router

* fix: enable rust router for CircleCI tests

* fix: handle invalid output sampels & enable numSamples tests

* chore: add comments about disabled tests

* chore: add asset-swapper changelog entry
2022-03-31 14:32:59 +02:00
Kim Persson
c9c30d3a76 chore: bump ts version to solve type issue with ethereumjs (#455) 2022-03-31 13:55:17 +02:00
Noah Khamliche
73dfdb5b69 fixed gas estimation and removed hint from intermediate tokens 2022-03-21 14:51:23 -04:00
Noah Khamliche
e638268f94 updated routing 2022-03-21 14:51:23 -04:00
Noah Khamliche
0bfd765481 updating changelog 2022-03-21 14:51:23 -04:00
Noah Khamliche
1f12893735 fixing routing 2022-03-21 14:51:23 -04:00
Noah Khamliche
dd3d9337c4 Added Stargate curve pool 2022-03-21 14:51:23 -04:00
Lawrence Forman
904214f4a8 ugprade tools deps and regenerate wrappers (#449)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-03-16 12:14:31 -04:00
Noah Khamliche
64c090c4b4 removed local bignumber resolution 2022-03-10 21:22:28 -05:00
Noah Khamliche
e24474f152 lint and prettier 2022-03-10 21:22:28 -05:00
Noah Khamliche
29fa408256 final nitpicks 2022-03-10 21:22:28 -05:00
Noah Khamliche
1b94cc68af fixed gas schedule 2022-03-10 21:22:28 -05:00
Noah Khamliche
f5b4bb3035 removed low liquidity pools, and fixed some routing 2022-03-10 21:22:28 -05:00
Noah Khamliche
afd880f28c poolAddress -> NULL_ADDRESS for consitent types 2022-03-10 21:22:28 -05:00
Noah Khamliche
cd14cdd168 fixed lint 2022-03-10 21:22:28 -05:00
Noah Khamliche
c8ff53a75f fixed mobius common argument abstraction 2022-03-10 21:22:28 -05:00
Noah Khamliche
6d08add20b minimized reused code for mobius pairs 2022-03-10 21:22:28 -05:00
Noah Khamliche
29f9c725e3 bump changelog to version after feat/BTRFLYCurve 2022-03-10 21:22:28 -05:00
Noah Khamliche
a83453f07f prettier and lint 2022-03-10 21:22:28 -05:00
Noah Khamliche
ae365ce92c finished off mobius money pairs 2022-03-10 21:22:28 -05:00
Noah Khamliche
77a592e891 added mobius config for celo and some inital test pools 2022-03-10 21:22:28 -05:00
205 changed files with 10785 additions and 10480 deletions

View File

@@ -10,6 +10,7 @@ jobs:
working_directory: ~/repo
steps:
- checkout
- run: git submodule update --init --recursive
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
- run:
name: install-yarn
@@ -19,7 +20,6 @@ jobs:
command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install
- setup_remote_docker
- run: yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci
- run: yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts
- save_cache:
key: repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
@@ -78,6 +78,17 @@ jobs:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun -p @0x/contracts-multisig -p @0x/contracts-utils -p @0x/contracts-exchange-libs -p @0x/contracts-erc20 -p @0x/contracts-erc721 -p @0x/contracts-erc1155 -p @0x/contracts-asset-proxy -p @0x/contracts-broker -p @0x/contracts-zero-ex -m --serial -c test:circleci
test-foundry:
resource_class: medium+
docker:
- image: ghcr.io/foundry-rs/foundry:latest
working_directory: ~/repo/contracts/zero-ex
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
# - run: forge install
- run: forge test
test-publish:
resource_class: large
environment:
@@ -110,6 +121,8 @@ jobs:
docker:
- image: node:16
working_directory: ~/repo
environment:
RUST_ROUTER: 'true'
steps:
- restore_cache:
keys:
@@ -117,7 +130,6 @@ jobs:
- run: yarn wsrun -p @0x/contracts-test-utils -m --serial -c test:circleci
- run: yarn wsrun -p @0x/contract-artifacts -m --serial -c test:circleci
- run: yarn wsrun -p @0x/contract-wrappers-test -m --serial -c test:circleci
- run: yarn wsrun -p @0x/migrations -m --serial -c test:circleci
- run: yarn wsrun -p @0x/order-utils -m --serial -c test:circleci
- run: yarn wsrun -p @0x/asset-swapper -m --serial -c test:circleci
- save_cache:
@@ -181,6 +193,9 @@ workflows:
# - test-contracts-extra-ganache:
# requires:
# - build
- test-foundry:
requires:
- build
- test-contracts-rest-ganache:
requires:
- build

View File

@@ -1,7 +1,6 @@
python: ['python-packages']
contracts: ['contracts']
@0x/contract-addresses: ['packages/contract-addresses']
@0x/migrations: ['packages/migrations']
@0x/order-utils: ['packages/order-utils']
@0x/contract-artifacts: ['packages/contract-artifacts']
@0x/contract-wrappers: ['packages/contract-wrappers']

View File

@@ -28,7 +28,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 16
- uses: actions/setup-python@v2
- name: 'configure git'
run: |

9
.gitignore vendored
View File

@@ -173,6 +173,15 @@ contracts/zero-ex/test/generated-wrappers/
contracts/treasury/generated-wrappers/
contracts/treasury/test/generated-wrappers/
# foundry artifacts
contracts/zero-ex/foundry-artifacts/
# foundry cache
contracts/zero-ex/foundry-cache/
# typechain wrappers
contracts/zero-ex/typechain-wrappers/
# Doc README copy
packages/*/docs/README.md

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "contracts/zero-ex/contracts/deps/forge-std"]
path = contracts/zero-ex/contracts/deps/forge-std
url = https://github.com/foundry-rs/forge-std

View File

@@ -1,18 +1,20 @@
# See https://help.github.com/articles/about-codeowners/
# for more info about CODEOWNERS file
# It uses the same pattern rule for gitignore file
# https://git-scm.com/docs/gitignore#_pattern_format
# Website
packages/asset-swapper/ @BMillman19 @fragosti @dave4506
packages/instant/ @BMillman19 @fragosti @dave4506
packages/asset-swapper/ @dekz @dextracker @kyu-c
# Dev tools & setup
.circleci/ @dorothy-zbornak
packages/contract-addresses/ @abandeali1
packages/contract-artifacts/ @abandeali1
packages/order-utils/ @dorothy-zbornak
.circleci/ @dekz
packages/contract-addresses/ @dekz @dextracker @kyu-c
packages/contract-artifacts/ @dekz
packages/protocol-utils/ @dekz
# Protocol/smart contracts
contracts/ @abandeali1 @hysz @dorothy-zbornak @mzhu25
contracts/ @dekz @dextracker

View File

@@ -38,7 +38,6 @@ These packages are all under development. See [/contracts/README.md](/contracts/
| [`@0x/protocol-utils`](/packages/protocol-utils) | [![npm](https://img.shields.io/npm/v/@0x/protocol-utils.svg)](https://www.npmjs.com/package/@0x/protocol-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
| [`@0x/contract-addresses`](/packages/contract-addresses) | [![npm](https://img.shields.io/npm/v/@0x/contract-addresses.svg)](https://www.npmjs.com/package/@0x/contract-addresses) | A tiny utility library for getting known deployed contract addresses for a particular network. |
| [`@0x/contract-wrappers`](/packages/contract-wrappers) | [![npm](https://img.shields.io/npm/v/@0x/contract-wrappers.svg)](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
| [`@0x/migrations`](/packages/migrations) | [![npm](https://img.shields.io/npm/v/@0x/migrations.svg)](https://www.npmjs.com/package/@0x/migrations) | Migration tool for deploying 0x smart contracts on private testnets |
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [![npm](https://img.shields.io/npm/v/@0x/contract-artifacts.svg)](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts | |
## Usage

View File

@@ -1,4 +1,76 @@
[
{
"timestamp": 1660073235,
"version": "3.3.35",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1659750766,
"version": "3.3.34",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1658950329,
"version": "3.3.33",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1655244958,
"version": "3.3.32",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1654284040,
"version": "3.3.31",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1652919697,
"version": "3.3.30",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1650611093,
"version": "3.3.29",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1648739346,
"version": "3.3.28",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1646225739,
"version": "3.3.27",

View File

@@ -5,6 +5,38 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.3.35 - _August 9, 2022_
* Dependencies updated
## v3.3.34 - _August 6, 2022_
* Dependencies updated
## v3.3.33 - _July 27, 2022_
* Dependencies updated
## v3.3.32 - _June 14, 2022_
* Dependencies updated
## v3.3.31 - _June 3, 2022_
* Dependencies updated
## v3.3.30 - _May 19, 2022_
* Dependencies updated
## v3.3.29 - _April 22, 2022_
* Dependencies updated
## v3.3.28 - _March 31, 2022_
* Dependencies updated
## v3.3.27 - _March 2, 2022_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc20",
"version": "3.3.27",
"version": "3.3.35",
"engines": {
"node": ">=6.12"
},
@@ -51,18 +51,18 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"devDependencies": {
"@0x/abi-gen": "^5.7.2",
"@0x/contracts-gen": "^2.0.43",
"@0x/contracts-test-utils": "^5.4.18",
"@0x/contracts-utils": "^4.8.8",
"@0x/dev-utils": "^4.2.11",
"@0x/sol-compiler": "^4.7.8",
"@0x/abi-gen": "^5.8.0",
"@0x/contracts-gen": "^2.0.46",
"@0x/contracts-test-utils": "^5.4.26",
"@0x/contracts-utils": "^4.8.16",
"@0x/dev-utils": "^4.2.14",
"@0x/sol-compiler": "^4.8.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
"@0x/types": "^3.3.4",
"@0x/typescript-typings": "^5.2.1",
"@0x/utils": "^6.5.0",
"@0x/web3-wrapper": "^7.6.2",
"@0x/types": "^3.3.6",
"@0x/typescript-typings": "^5.3.1",
"@0x/utils": "^6.5.3",
"@0x/web3-wrapper": "^7.6.5",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -70,7 +70,7 @@
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.6.0",
"ethereum-types": "^3.7.0",
"lodash": "^4.17.11",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
@@ -79,10 +79,10 @@
"solhint": "^1.4.1",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typescript": "4.2.2"
"typescript": "4.6.3"
},
"dependencies": {
"@0x/base-contract": "^6.4.5",
"@0x/base-contract": "^6.5.0",
"ethers": "~4.0.4"
},
"publishConfig": {

View File

@@ -1,4 +1,76 @@
[
{
"timestamp": 1660073235,
"version": "5.4.26",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1659750766,
"version": "5.4.25",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1658950329,
"version": "5.4.24",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1655244958,
"version": "5.4.23",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1654284040,
"version": "5.4.22",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1652919697,
"version": "5.4.21",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1650611093,
"version": "5.4.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1648739346,
"version": "5.4.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1646225739,
"version": "5.4.18",

View File

@@ -5,6 +5,38 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v5.4.26 - _August 9, 2022_
* Dependencies updated
## v5.4.25 - _August 6, 2022_
* Dependencies updated
## v5.4.24 - _July 27, 2022_
* Dependencies updated
## v5.4.23 - _June 14, 2022_
* Dependencies updated
## v5.4.22 - _June 3, 2022_
* Dependencies updated
## v5.4.21 - _May 19, 2022_
* Dependencies updated
## v5.4.20 - _April 22, 2022_
* Dependencies updated
## v5.4.19 - _March 31, 2022_
* Dependencies updated
## v5.4.18 - _March 2, 2022_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-test-utils",
"version": "5.4.18",
"version": "5.4.26",
"engines": {
"node": ">=6.12"
},
@@ -34,28 +34,28 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/test-utils",
"devDependencies": {
"@0x/sol-compiler": "^4.7.8",
"@0x/sol-compiler": "^4.8.1",
"@0x/tslint-config": "^4.1.4",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typescript": "4.2.2"
"typescript": "4.6.3"
},
"dependencies": {
"@0x/assert": "^3.0.31",
"@0x/base-contract": "^6.4.5",
"@0x/contract-addresses": "^6.12.0",
"@0x/dev-utils": "^4.2.11",
"@0x/json-schemas": "^6.4.1",
"@0x/assert": "^3.0.34",
"@0x/base-contract": "^6.5.0",
"@0x/contract-addresses": "^6.19.1",
"@0x/dev-utils": "^4.2.14",
"@0x/json-schemas": "^6.4.4",
"@0x/order-utils": "^10.4.28",
"@0x/sol-coverage": "^4.0.42",
"@0x/sol-profiler": "^4.1.32",
"@0x/sol-trace": "^3.0.42",
"@0x/subproviders": "^6.6.2",
"@0x/types": "^3.3.4",
"@0x/typescript-typings": "^5.2.1",
"@0x/utils": "^6.5.0",
"@0x/web3-wrapper": "^7.6.2",
"@0x/sol-coverage": "^4.0.45",
"@0x/sol-profiler": "^4.1.35",
"@0x/sol-trace": "^3.0.45",
"@0x/subproviders": "^6.6.5",
"@0x/types": "^3.3.6",
"@0x/typescript-typings": "^5.3.1",
"@0x/utils": "^6.5.3",
"@0x/web3-wrapper": "^7.6.5",
"@types/bn.js": "^4.11.0",
"@types/js-combinatorics": "^0.5.29",
"@types/lodash": "4.14.104",
@@ -67,7 +67,7 @@
"chai-bignumber": "^3.0.0",
"decimal.js": "^10.2.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.6.0",
"ethereum-types": "^3.7.0",
"ethereumjs-util": "^7.0.10",
"ethers": "~4.0.4",
"js-combinatorics": "^0.5.3",

View File

@@ -1,4 +1,76 @@
[
{
"timestamp": 1660073235,
"version": "1.4.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1659750766,
"version": "1.4.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1658950329,
"version": "1.4.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1655244958,
"version": "1.4.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1654284040,
"version": "1.4.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1652919697,
"version": "1.4.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1650611093,
"version": "1.4.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1648739346,
"version": "1.4.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1646225739,
"version": "1.4.10",

View File

@@ -5,6 +5,38 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.4.18 - _August 9, 2022_
* Dependencies updated
## v1.4.17 - _August 6, 2022_
* Dependencies updated
## v1.4.16 - _July 27, 2022_
* Dependencies updated
## v1.4.15 - _June 14, 2022_
* Dependencies updated
## v1.4.14 - _June 3, 2022_
* Dependencies updated
## v1.4.13 - _May 19, 2022_
* Dependencies updated
## v1.4.12 - _April 22, 2022_
* Dependencies updated
## v1.4.11 - _March 31, 2022_
* Dependencies updated
## v1.4.10 - _March 2, 2022_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-treasury",
"version": "1.4.10",
"version": "1.4.18",
"engines": {
"node": ">=6.12"
},
@@ -46,14 +46,14 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/treasury",
"devDependencies": {
"@0x/abi-gen": "^5.7.2",
"@0x/contract-addresses": "^6.12.0",
"@0x/abi-gen": "^5.8.0",
"@0x/contract-addresses": "^6.19.1",
"@0x/contracts-asset-proxy": "^3.7.19",
"@0x/contracts-erc20": "^3.3.27",
"@0x/contracts-gen": "^2.0.43",
"@0x/contracts-erc20": "^3.3.35",
"@0x/contracts-gen": "^2.0.46",
"@0x/contracts-staking": "^2.0.45",
"@0x/contracts-test-utils": "^5.4.18",
"@0x/sol-compiler": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.26",
"@0x/sol-compiler": "^4.8.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
"@types/isomorphic-fetch": "^0.0.35",
@@ -69,17 +69,17 @@
"solhint": "^1.4.1",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typescript": "4.2.2"
"typescript": "4.6.3"
},
"dependencies": {
"@0x/base-contract": "^6.4.5",
"@0x/protocol-utils": "^1.11.1",
"@0x/subproviders": "^6.6.2",
"@0x/types": "^3.3.4",
"@0x/typescript-typings": "^5.2.1",
"@0x/utils": "^6.5.0",
"@0x/web3-wrapper": "^7.6.2",
"ethereum-types": "^3.6.0",
"@0x/base-contract": "^6.5.0",
"@0x/protocol-utils": "^11.16.2",
"@0x/subproviders": "^6.6.5",
"@0x/types": "^3.3.6",
"@0x/typescript-typings": "^5.3.1",
"@0x/utils": "^6.5.3",
"@0x/web3-wrapper": "^7.6.5",
"ethereum-types": "^3.7.0",
"ethereumjs-util": "^7.0.10"
},
"publishConfig": {

View File

@@ -1,4 +1,76 @@
[
{
"timestamp": 1660073235,
"version": "4.8.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1659750766,
"version": "4.8.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1658950329,
"version": "4.8.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1655244958,
"version": "4.8.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1654284040,
"version": "4.8.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1652919697,
"version": "4.8.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1650611093,
"version": "4.8.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1648739346,
"version": "4.8.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1646225739,
"version": "4.8.8",

View File

@@ -5,6 +5,38 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.8.16 - _August 9, 2022_
* Dependencies updated
## v4.8.15 - _August 6, 2022_
* Dependencies updated
## v4.8.14 - _July 27, 2022_
* Dependencies updated
## v4.8.13 - _June 14, 2022_
* Dependencies updated
## v4.8.12 - _June 3, 2022_
* Dependencies updated
## v4.8.11 - _May 19, 2022_
* Dependencies updated
## v4.8.10 - _April 22, 2022_
* Dependencies updated
## v4.8.9 - _March 31, 2022_
* Dependencies updated
## v4.8.8 - _March 2, 2022_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-utils",
"version": "4.8.8",
"version": "4.8.16",
"engines": {
"node": ">=6.12"
},
@@ -50,15 +50,15 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/utils",
"devDependencies": {
"@0x/abi-gen": "^5.7.2",
"@0x/contracts-gen": "^2.0.43",
"@0x/contracts-test-utils": "^5.4.18",
"@0x/dev-utils": "^4.2.11",
"@0x/abi-gen": "^5.8.0",
"@0x/contracts-gen": "^2.0.46",
"@0x/contracts-test-utils": "^5.4.26",
"@0x/dev-utils": "^4.2.14",
"@0x/order-utils": "^10.4.28",
"@0x/sol-compiler": "^4.7.8",
"@0x/sol-compiler": "^4.8.1",
"@0x/tslint-config": "^4.1.4",
"@0x/types": "^3.3.4",
"@0x/web3-wrapper": "^7.6.2",
"@0x/types": "^3.3.6",
"@0x/web3-wrapper": "^7.6.5",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
@@ -76,14 +76,14 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typescript": "4.2.2"
"typescript": "4.6.3"
},
"dependencies": {
"@0x/base-contract": "^6.4.5",
"@0x/typescript-typings": "^5.2.1",
"@0x/utils": "^6.5.0",
"@0x/base-contract": "^6.5.0",
"@0x/typescript-typings": "^5.3.1",
"@0x/utils": "^6.5.3",
"bn.js": "^4.11.8",
"ethereum-types": "^3.6.0"
"ethereum-types": "^3.7.0"
},
"publishConfig": {
"access": "public"

View File

@@ -1,4 +1,90 @@
[
{
"version": "0.36.2",
"changes": [
{
"note": "Add Foundry support",
"pr": 534
}
],
"timestamp": 1659976271
},
{
"timestamp": 1659750766,
"version": "0.36.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "0.36.0",
"changes": [
{
"note": "Add Synthetix support in Ethereum and Optimism bridge adapters",
"pr": 518
}
],
"timestamp": 1658950329
},
{
"version": "0.35.0",
"changes": [
{
"note": "Adds support for Velodrome OptimismBridgeAdapter",
"pr": 494
}
],
"timestamp": 1655244958
},
{
"version": "0.34.0",
"changes": [
{
"note": "Splits BridgeAdapter up by chain",
"pr": 487
},
{
"note": "Add stETH wrap/unwrap support",
"pr": 476
},
{
"note": "Adds support for BancorV3 to EthereumBridgeAdapter",
"pr": 492
}
],
"timestamp": 1654284040
},
{
"version": "0.33.0",
"changes": [
{
"note": "Add support for GMX and Platypus to bridge adapter",
"pr": 478
}
],
"timestamp": 1652919697
},
{
"version": "0.32.0",
"changes": [
{
"note": "Add support for `BalancerV2Batch` fills in FQT",
"pr": 462
}
],
"timestamp": 1650611093
},
{
"timestamp": 1648739346,
"version": "0.31.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1646225739,
"version": "0.31.1",

View File

@@ -5,6 +5,40 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.36.2 - _August 8, 2022_
* Add Foundry support (#534)
## v0.36.1 - _August 6, 2022_
* Dependencies updated
## v0.36.0 - _July 27, 2022_
* Add Synthetix support in Ethereum and Optimism bridge adapters (#518)
## v0.35.0 - _June 14, 2022_
* Adds support for Velodrome OptimismBridgeAdapter (#494)
## v0.34.0 - _June 3, 2022_
* Splits BridgeAdapter up by chain (#487)
* Add stETH wrap/unwrap support (#476)
* Adds support for BancorV3 to EthereumBridgeAdapter (#492)
## v0.33.0 - _May 19, 2022_
* Add support for GMX and Platypus to bridge adapter (#478)
## v0.32.0 - _April 22, 2022_
* Add support for `BalancerV2Batch` fills in FQT (#462)
## v0.31.2 - _March 31, 2022_
* Dependencies updated
## v0.31.1 - _March 2, 2022_
* Dependencies updated

View File

@@ -2,6 +2,10 @@
This package contains contracts for the ZeroEx extensible contract architecture.
> **_NOTE:_** This repo is undergoing a tooling change. If adding a contract, you will need to
> add it to `compiler.json`. You can generate the entire list by running the following:
> `find . -type f -name "*.sol" | grep -v foundry | grep -v "contracts/dep" | grep -v "node_modules"`
## Installation
**Install**

View File

@@ -1,6 +1,212 @@
{
"artifactsDir": "./test/generated-artifacts",
"contractsDir": "./contracts",
"contracts": [
"./contracts/src/IZeroEx.sol",
"./contracts/src/ZeroEx.sol",
"./contracts/src/ZeroExOptimized.sol",
"./contracts/src/errors/LibCommonRichErrors.sol",
"./contracts/src/errors/LibLiquidityProviderRichErrors.sol",
"./contracts/src/errors/LibMetaTransactionsRichErrors.sol",
"./contracts/src/errors/LibNFTOrdersRichErrors.sol",
"./contracts/src/errors/LibNativeOrdersRichErrors.sol",
"./contracts/src/errors/LibOwnableRichErrors.sol",
"./contracts/src/errors/LibProxyRichErrors.sol",
"./contracts/src/errors/LibSignatureRichErrors.sol",
"./contracts/src/errors/LibSimpleFunctionRegistryRichErrors.sol",
"./contracts/src/errors/LibTransformERC20RichErrors.sol",
"./contracts/src/errors/LibWalletRichErrors.sol",
"./contracts/src/external/FeeCollector.sol",
"./contracts/src/external/FeeCollectorController.sol",
"./contracts/src/external/FlashWallet.sol",
"./contracts/src/external/IFlashWallet.sol",
"./contracts/src/external/ILiquidityProviderSandbox.sol",
"./contracts/src/external/LibFeeCollector.sol",
"./contracts/src/external/LiquidityProviderSandbox.sol",
"./contracts/src/external/PermissionlessTransformerDeployer.sol",
"./contracts/src/external/TransformerDeployer.sol",
"./contracts/src/features/BatchFillNativeOrdersFeature.sol",
"./contracts/src/features/BootstrapFeature.sol",
"./contracts/src/features/ERC165Feature.sol",
"./contracts/src/features/FundRecoveryFeature.sol",
"./contracts/src/features/LiquidityProviderFeature.sol",
"./contracts/src/features/MetaTransactionsFeature.sol",
"./contracts/src/features/NativeOrdersFeature.sol",
"./contracts/src/features/OtcOrdersFeature.sol",
"./contracts/src/features/OwnableFeature.sol",
"./contracts/src/features/PancakeSwapFeature.sol",
"./contracts/src/features/SimpleFunctionRegistryFeature.sol",
"./contracts/src/features/TransformERC20Feature.sol",
"./contracts/src/features/UniswapFeature.sol",
"./contracts/src/features/UniswapV3Feature.sol",
"./contracts/src/features/interfaces/IBatchFillNativeOrdersFeature.sol",
"./contracts/src/features/interfaces/IBootstrapFeature.sol",
"./contracts/src/features/interfaces/IERC1155OrdersFeature.sol",
"./contracts/src/features/interfaces/IERC165Feature.sol",
"./contracts/src/features/interfaces/IERC721OrdersFeature.sol",
"./contracts/src/features/interfaces/IFeature.sol",
"./contracts/src/features/interfaces/IFundRecoveryFeature.sol",
"./contracts/src/features/interfaces/ILiquidityProviderFeature.sol",
"./contracts/src/features/interfaces/IMetaTransactionsFeature.sol",
"./contracts/src/features/interfaces/IMultiplexFeature.sol",
"./contracts/src/features/interfaces/INativeOrdersEvents.sol",
"./contracts/src/features/interfaces/INativeOrdersFeature.sol",
"./contracts/src/features/interfaces/IOtcOrdersFeature.sol",
"./contracts/src/features/interfaces/IOwnableFeature.sol",
"./contracts/src/features/interfaces/IPancakeSwapFeature.sol",
"./contracts/src/features/interfaces/ISimpleFunctionRegistryFeature.sol",
"./contracts/src/features/interfaces/ITokenSpenderFeature.sol",
"./contracts/src/features/interfaces/ITransformERC20Feature.sol",
"./contracts/src/features/interfaces/IUniswapFeature.sol",
"./contracts/src/features/interfaces/IUniswapV3Feature.sol",
"./contracts/src/features/libs/LibNFTOrder.sol",
"./contracts/src/features/libs/LibNativeOrder.sol",
"./contracts/src/features/libs/LibSignature.sol",
"./contracts/src/features/multiplex/MultiplexFeature.sol",
"./contracts/src/features/multiplex/MultiplexLiquidityProvider.sol",
"./contracts/src/features/multiplex/MultiplexOtc.sol",
"./contracts/src/features/multiplex/MultiplexRfq.sol",
"./contracts/src/features/multiplex/MultiplexTransformERC20.sol",
"./contracts/src/features/multiplex/MultiplexUniswapV2.sol",
"./contracts/src/features/multiplex/MultiplexUniswapV3.sol",
"./contracts/src/features/native_orders/NativeOrdersCancellation.sol",
"./contracts/src/features/native_orders/NativeOrdersInfo.sol",
"./contracts/src/features/native_orders/NativeOrdersProtocolFees.sol",
"./contracts/src/features/native_orders/NativeOrdersSettlement.sol",
"./contracts/src/features/nft_orders/ERC1155OrdersFeature.sol",
"./contracts/src/features/nft_orders/ERC721OrdersFeature.sol",
"./contracts/src/features/nft_orders/NFTOrders.sol",
"./contracts/src/fixins/FixinCommon.sol",
"./contracts/src/fixins/FixinEIP712.sol",
"./contracts/src/fixins/FixinERC1155Spender.sol",
"./contracts/src/fixins/FixinERC721Spender.sol",
"./contracts/src/fixins/FixinProtocolFees.sol",
"./contracts/src/fixins/FixinReentrancyGuard.sol",
"./contracts/src/fixins/FixinTokenSpender.sol",
"./contracts/src/liquidity-providers/CurveLiquidityProvider.sol",
"./contracts/src/liquidity-providers/MooniswapLiquidityProvider.sol",
"./contracts/src/migrations/FullMigration.sol",
"./contracts/src/migrations/InitialMigration.sol",
"./contracts/src/migrations/LibBootstrap.sol",
"./contracts/src/migrations/LibMigrate.sol",
"./contracts/src/storage/LibERC1155OrdersStorage.sol",
"./contracts/src/storage/LibERC721OrdersStorage.sol",
"./contracts/src/storage/LibMetaTransactionsStorage.sol",
"./contracts/src/storage/LibNativeOrdersStorage.sol",
"./contracts/src/storage/LibOtcOrdersStorage.sol",
"./contracts/src/storage/LibOwnableStorage.sol",
"./contracts/src/storage/LibProxyStorage.sol",
"./contracts/src/storage/LibReentrancyGuardStorage.sol",
"./contracts/src/storage/LibSimpleFunctionRegistryStorage.sol",
"./contracts/src/storage/LibStorage.sol",
"./contracts/src/storage/LibTransformERC20Storage.sol",
"./contracts/src/transformers/AffiliateFeeTransformer.sol",
"./contracts/src/transformers/FillQuoteTransformer.sol",
"./contracts/src/transformers/IERC20Transformer.sol",
"./contracts/src/transformers/LibERC20Transformer.sol",
"./contracts/src/transformers/LogMetadataTransformer.sol",
"./contracts/src/transformers/PayTakerTransformer.sol",
"./contracts/src/transformers/PositiveSlippageFeeTransformer.sol",
"./contracts/src/transformers/Transformer.sol",
"./contracts/src/transformers/WethTransformer.sol",
"./contracts/src/transformers/bridges/AbstractBridgeAdapter.sol",
"./contracts/src/transformers/bridges/AvalancheBridgeAdapter.sol",
"./contracts/src/transformers/bridges/BSCBridgeAdapter.sol",
"./contracts/src/transformers/bridges/BridgeProtocols.sol",
"./contracts/src/transformers/bridges/CeloBridgeAdapter.sol",
"./contracts/src/transformers/bridges/EthereumBridgeAdapter.sol",
"./contracts/src/transformers/bridges/FantomBridgeAdapter.sol",
"./contracts/src/transformers/bridges/IBridgeAdapter.sol",
"./contracts/src/transformers/bridges/OptimismBridgeAdapter.sol",
"./contracts/src/transformers/bridges/PolygonBridgeAdapter.sol",
"./contracts/src/transformers/bridges/mixins/MixinAaveV2.sol",
"./contracts/src/transformers/bridges/mixins/MixinBalancer.sol",
"./contracts/src/transformers/bridges/mixins/MixinBalancerV2.sol",
"./contracts/src/transformers/bridges/mixins/MixinBalancerV2Batch.sol",
"./contracts/src/transformers/bridges/mixins/MixinBancor.sol",
"./contracts/src/transformers/bridges/mixins/MixinBancorV3.sol",
"./contracts/src/transformers/bridges/mixins/MixinCompound.sol",
"./contracts/src/transformers/bridges/mixins/MixinCryptoCom.sol",
"./contracts/src/transformers/bridges/mixins/MixinCurve.sol",
"./contracts/src/transformers/bridges/mixins/MixinCurveV2.sol",
"./contracts/src/transformers/bridges/mixins/MixinDodo.sol",
"./contracts/src/transformers/bridges/mixins/MixinDodoV2.sol",
"./contracts/src/transformers/bridges/mixins/MixinGMX.sol",
"./contracts/src/transformers/bridges/mixins/MixinKyberDmm.sol",
"./contracts/src/transformers/bridges/mixins/MixinLido.sol",
"./contracts/src/transformers/bridges/mixins/MixinMStable.sol",
"./contracts/src/transformers/bridges/mixins/MixinMakerPSM.sol",
"./contracts/src/transformers/bridges/mixins/MixinMooniswap.sol",
"./contracts/src/transformers/bridges/mixins/MixinNerve.sol",
"./contracts/src/transformers/bridges/mixins/MixinPlatypus.sol",
"./contracts/src/transformers/bridges/mixins/MixinShell.sol",
"./contracts/src/transformers/bridges/mixins/MixinSynthetix.sol",
"./contracts/src/transformers/bridges/mixins/MixinUniswap.sol",
"./contracts/src/transformers/bridges/mixins/MixinUniswapV2.sol",
"./contracts/src/transformers/bridges/mixins/MixinUniswapV3.sol",
"./contracts/src/transformers/bridges/mixins/MixinVelodrome.sol",
"./contracts/src/transformers/bridges/mixins/MixinZeroExBridge.sol",
"./contracts/src/vendor/IERC1155Token.sol",
"./contracts/src/vendor/IERC721Token.sol",
"./contracts/src/vendor/IFeeRecipient.sol",
"./contracts/src/vendor/ILiquidityProvider.sol",
"./contracts/src/vendor/IMooniswapPool.sol",
"./contracts/src/vendor/IPropertyValidator.sol",
"./contracts/src/vendor/ITakerCallback.sol",
"./contracts/src/vendor/IUniswapV2Pair.sol",
"./contracts/src/vendor/IUniswapV3Pool.sol",
"./contracts/src/vendor/v3/IERC20Bridge.sol",
"./contracts/src/vendor/v3/IStaking.sol",
"./contracts/test/ITestSimpleFunctionRegistryFeature.sol",
"./contracts/test/TestBridge.sol",
"./contracts/test/TestCallTarget.sol",
"./contracts/test/TestDelegateCaller.sol",
"./contracts/test/TestFeeCollectorController.sol",
"./contracts/test/TestFeeRecipient.sol",
"./contracts/test/TestFillQuoteTransformerBridge.sol",
"./contracts/test/TestFillQuoteTransformerExchange.sol",
"./contracts/test/TestFillQuoteTransformerHost.sol",
"./contracts/test/TestFixinProtocolFees.sol",
"./contracts/test/TestFixinTokenSpender.sol",
"./contracts/test/TestFullMigration.sol",
"./contracts/test/TestInitialMigration.sol",
"./contracts/test/TestLibNativeOrder.sol",
"./contracts/test/TestLibSignature.sol",
"./contracts/test/TestMetaTransactionsNativeOrdersFeature.sol",
"./contracts/test/TestMetaTransactionsTransformERC20Feature.sol",
"./contracts/test/TestMigrator.sol",
"./contracts/test/TestMintTokenERC20Transformer.sol",
"./contracts/test/TestNFTOrderPresigner.sol",
"./contracts/test/TestNativeOrdersFeature.sol",
"./contracts/test/TestNoEthRecipient.sol",
"./contracts/test/TestOrderSignerRegistryWithContractWallet.sol",
"./contracts/test/TestPermissionlessTransformerDeployerSuicidal.sol",
"./contracts/test/TestPermissionlessTransformerDeployerTransformer.sol",
"./contracts/test/TestPropertyValidator.sol",
"./contracts/test/TestRfqOriginRegistration.sol",
"./contracts/test/TestSimpleFunctionRegistryFeatureImpl1.sol",
"./contracts/test/TestSimpleFunctionRegistryFeatureImpl2.sol",
"./contracts/test/TestStaking.sol",
"./contracts/test/TestTransformERC20.sol",
"./contracts/test/TestTransformerBase.sol",
"./contracts/test/TestTransformerDeployerTransformer.sol",
"./contracts/test/TestTransformerHost.sol",
"./contracts/test/TestUniswapV3Feature.sol",
"./contracts/test/TestWethTransformerHost.sol",
"./contracts/test/TestZeroExFeature.sol",
"./contracts/test/integration/TestCurve.sol",
"./contracts/test/integration/TestLiquidityProvider.sol",
"./contracts/test/integration/TestMooniswap.sol",
"./contracts/test/integration/TestUniswapV2Factory.sol",
"./contracts/test/integration/TestUniswapV2Pool.sol",
"./contracts/test/integration/TestUniswapV3Factory.sol",
"./contracts/test/integration/TestUniswapV3Pool.sol",
"./contracts/test/tokens/TestMintableERC1155Token.sol",
"./contracts/test/tokens/TestMintableERC20Token.sol",
"./contracts/test/tokens/TestMintableERC721Token.sol",
"./contracts/test/tokens/TestTokenSpenderERC20Token.sol",
"./contracts/test/tokens/TestWeth.sol"
],
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,

View File

@@ -313,7 +313,7 @@ contract FillQuoteTransformer is
if (success) {
results.makerTokenBoughtAmount = abi.decode(resultData, (uint256));
results.takerTokenSoldAmount = takerTokenFillAmount;
}
}
}
// Fill a single limit order.

View File

@@ -0,0 +1,88 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./IBridgeAdapter.sol";
abstract contract AbstractBridgeAdapter is IBridgeAdapter {
constructor(
uint256 expectedChainId,
string memory expectedChainName
)
public
{
uint256 chainId;
assembly { chainId := chainid() }
// Allow testing on Ganache
if (chainId != expectedChainId && chainId != 1337) {
revert(string(abi.encodePacked(expectedChainName, "BridgeAdapter.constructor: wrong chain ID")));
}
}
function isSupportedSource(bytes32 source)
external
override
returns (bool isSupported)
{
BridgeOrder memory placeholderOrder;
placeholderOrder.source = source;
IERC20TokenV06 placeholderToken = IERC20TokenV06(address(0));
(, isSupported) = _trade(
placeholderOrder,
placeholderToken,
placeholderToken,
0,
true
);
}
function trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount
)
public
override
returns (uint256 boughtAmount)
{
(boughtAmount, ) = _trade(
order,
sellToken,
buyToken,
sellAmount,
false
);
}
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bool dryRun
)
internal
virtual
returns (uint256 boughtAmount, bool supportedSource);
}

View File

@@ -0,0 +1,151 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinGMX.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinAaveV2.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinPlatypus.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinWOOFi.sol";
import "./mixins/MixinZeroExBridge.sol";
contract AvalancheBridgeAdapter is
AbstractBridgeAdapter(43114, "Avalanche"),
MixinCurve,
MixinCurveV2,
MixinGMX,
MixinKyberDmm,
MixinAaveV2,
MixinNerve,
MixinPlatypus,
MixinUniswapV2,
MixinWOOFi,
MixinZeroExBridge
{
constructor(IEtherTokenV06 weth)
public
MixinCurve(weth)
{}
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bool dryRun
)
internal
override
returns (uint256 boughtAmount, bool supportedSource)
{
uint128 protocolId = uint128(uint256(order.source) >> 128);
if (protocolId == BridgeProtocols.CURVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurve(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CURVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV2(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.KYBERDMM) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeKyberDmm(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.AAVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeAaveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.GMX) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeGMX(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.PLATYPUS) {
if (dryRun) { return (0, true); }
boughtAmount = _tradePlatypus(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.WOOFI) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeWOOFi(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeZeroExBridge(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
}
emit BridgeFill(
order.source,
sellToken,
buyToken,
sellAmount,
boughtAmount
);
}
}

View File

@@ -0,0 +1,142 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinDodo.sol";
import "./mixins/MixinDodoV2.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinMooniswap.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinWOOFi.sol";
import "./mixins/MixinZeroExBridge.sol";
contract BSCBridgeAdapter is
AbstractBridgeAdapter(56, "BSC"),
MixinCurve,
MixinDodo,
MixinDodoV2,
MixinKyberDmm,
MixinMooniswap,
MixinNerve,
MixinUniswapV2,
MixinWOOFi,
MixinZeroExBridge
{
constructor(IEtherTokenV06 weth)
public
MixinCurve(weth)
MixinMooniswap(weth)
{}
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bool dryRun
)
internal
override
returns (uint256 boughtAmount, bool supportedSource)
{
uint128 protocolId = uint128(uint256(order.source) >> 128);
if (protocolId == BridgeProtocols.CURVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurve(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV2(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.MOONISWAP) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeMooniswap(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.DODO) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeDodo(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.DODOV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeDodoV2(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.KYBERDMM) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeKyberDmm(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.WOOFI) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeWOOFi(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeZeroExBridge(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
}
emit BridgeFill(
order.source,
sellToken,
buyToken,
sellAmount,
boughtAmount
);
}
}

View File

@@ -27,29 +27,36 @@ library BridgeProtocols {
// A incrementally increasing, append-only list of protocol IDs.
// We don't use an enum so solidity doesn't throw when we pass in a
// new protocol ID that hasn't been rolled up yet.
uint128 internal constant UNKNOWN = 0;
uint128 internal constant CURVE = 1;
uint128 internal constant UNISWAPV2 = 2;
uint128 internal constant UNISWAP = 3;
uint128 internal constant BALANCER = 4;
uint128 internal constant KYBER = 5;
uint128 internal constant MOONISWAP = 6;
uint128 internal constant MSTABLE = 7;
uint128 internal constant OASIS = 8;
uint128 internal constant SHELL = 9;
uint128 internal constant DODO = 10;
uint128 internal constant DODOV2 = 11;
uint128 internal constant CRYPTOCOM = 12;
uint128 internal constant BANCOR = 13;
uint128 internal constant COFIX = 14;
uint128 internal constant NERVE = 15;
uint128 internal constant MAKERPSM = 16;
uint128 internal constant BALANCERV2 = 17;
uint128 internal constant UNISWAPV3 = 18;
uint128 internal constant KYBERDMM = 19;
uint128 internal constant CURVEV2 = 20;
uint128 internal constant LIDO = 21;
uint128 internal constant CLIPPER = 22; // Not used: Clipper is now using PLP interface
uint128 internal constant AAVEV2 = 23;
uint128 internal constant COMPOUND = 24;
uint128 internal constant UNKNOWN = 0;
uint128 internal constant CURVE = 1;
uint128 internal constant UNISWAPV2 = 2;
uint128 internal constant UNISWAP = 3;
uint128 internal constant BALANCER = 4;
uint128 internal constant KYBER = 5; // Not used: deprecated.
uint128 internal constant MOONISWAP = 6;
uint128 internal constant MSTABLE = 7;
uint128 internal constant OASIS = 8; // Not used: deprecated.
uint128 internal constant SHELL = 9;
uint128 internal constant DODO = 10;
uint128 internal constant DODOV2 = 11;
uint128 internal constant CRYPTOCOM = 12;
uint128 internal constant BANCOR = 13;
uint128 internal constant COFIX = 14; // Not used: deprecated.
uint128 internal constant NERVE = 15;
uint128 internal constant MAKERPSM = 16;
uint128 internal constant BALANCERV2 = 17;
uint128 internal constant UNISWAPV3 = 18;
uint128 internal constant KYBERDMM = 19;
uint128 internal constant CURVEV2 = 20;
uint128 internal constant LIDO = 21;
uint128 internal constant CLIPPER = 22; // Not used: Clipper is now using PLP interface
uint128 internal constant AAVEV2 = 23;
uint128 internal constant COMPOUND = 24;
uint128 internal constant BALANCERV2BATCH = 25;
uint128 internal constant GMX = 26;
uint128 internal constant PLATYPUS = 27;
uint128 internal constant BANCORV3 = 28;
uint128 internal constant VELODROME = 29;
uint128 internal constant SYNTHETIX = 30;
uint128 internal constant WOOFI = 31;
}

View File

@@ -0,0 +1,84 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinZeroExBridge.sol";
contract CeloBridgeAdapter is
AbstractBridgeAdapter(42220, "Celo"),
MixinNerve,
MixinUniswapV2,
MixinZeroExBridge
{
constructor(address _weth)
public
{}
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bool dryRun
)
internal
override
returns (uint256 boughtAmount, bool supportedSource)
{
uint128 protocolId = uint128(uint256(order.source) >> 128);
if (protocolId == BridgeProtocols.UNISWAPV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV2(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeZeroExBridge(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
}
emit BridgeFill(
order.source,
sellToken,
buyToken,
sellAmount,
boughtAmount
);
}
}

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2021 ZeroEx Intl.
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,55 +20,53 @@
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "./IBridgeAdapter.sol";
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinAaveV2.sol";
import "./mixins/MixinBalancer.sol";
import "./mixins/MixinBalancerV2.sol";
import "./mixins/MixinBalancerV2Batch.sol";
import "./mixins/MixinBancor.sol";
import "./mixins/MixinCoFiX.sol";
import "./mixins/MixinBancorV3.sol";
import "./mixins/MixinCompound.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinCryptoCom.sol";
import "./mixins/MixinDodo.sol";
import "./mixins/MixinDodoV2.sol";
import "./mixins/MixinKyber.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinLido.sol";
import "./mixins/MixinMakerPSM.sol";
import "./mixins/MixinMooniswap.sol";
import "./mixins/MixinMStable.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinOasis.sol";
import "./mixins/MixinShell.sol";
import "./mixins/MixinSynthetix.sol";
import "./mixins/MixinUniswap.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinUniswapV3.sol";
import "./mixins/MixinZeroExBridge.sol";
contract BridgeAdapter is
IBridgeAdapter,
contract EthereumBridgeAdapter is
AbstractBridgeAdapter(1, "Ethereum"),
MixinAaveV2,
MixinBalancer,
MixinBalancerV2,
MixinBalancerV2Batch,
MixinBancor,
MixinCoFiX,
MixinBancorV3,
MixinCompound,
MixinCurve,
MixinCurveV2,
MixinCryptoCom,
MixinDodo,
MixinDodoV2,
MixinKyber,
MixinKyberDmm,
MixinLido,
MixinMakerPSM,
MixinMooniswap,
MixinMStable,
MixinNerve,
MixinOasis,
MixinShell,
MixinSynthetix,
MixinUniswap,
MixinUniswapV2,
MixinUniswapV3,
@@ -76,43 +74,28 @@ contract BridgeAdapter is
{
constructor(IEtherTokenV06 weth)
public
MixinAaveV2()
MixinBalancer()
MixinBalancerV2()
MixinBancor(weth)
MixinCoFiX()
MixinBancorV3(weth)
MixinCompound(weth)
MixinCurve(weth)
MixinCurveV2()
MixinCryptoCom()
MixinDodo()
MixinDodoV2()
MixinKyber(weth)
MixinLido(weth)
MixinMakerPSM()
MixinMooniswap(weth)
MixinMStable()
MixinNerve()
MixinOasis()
MixinShell()
MixinUniswap(weth)
MixinUniswapV2()
MixinUniswapV3()
MixinZeroExBridge()
{}
function trade(
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount
uint256 sellAmount,
bool dryRun
)
public
internal
override
returns (uint256 boughtAmount)
returns (uint256 boughtAmount, bool supportedSource)
{
uint128 protocolId = uint128(uint256(order.source) >> 128);
if (protocolId == BridgeProtocols.CURVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurve(
sellToken,
buyToken,
@@ -120,6 +103,7 @@ contract BridgeAdapter is
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CURVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurveV2(
sellToken,
buyToken,
@@ -127,18 +111,21 @@ contract BridgeAdapter is
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV3(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV2(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAP) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswap(
sellToken,
buyToken,
@@ -146,6 +133,7 @@ contract BridgeAdapter is
order.bridgeData
);
} else if (protocolId == BridgeProtocols.BALANCER) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBalancer(
sellToken,
buyToken,
@@ -153,48 +141,37 @@ contract BridgeAdapter is
order.bridgeData
);
} else if (protocolId == BridgeProtocols.BALANCERV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBalancerV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.KYBER) {
boughtAmount = _tradeKyber(
sellToken,
buyToken,
} else if (protocolId == BridgeProtocols.BALANCERV2BATCH) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBalancerV2Batch(
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.MAKERPSM) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeMakerPsm(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.MOONISWAP) {
boughtAmount = _tradeMooniswap(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.MSTABLE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeMStable(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.OASIS) {
boughtAmount = _tradeOasis(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.SHELL) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeShell(
sellToken,
buyToken,
@@ -202,49 +179,49 @@ contract BridgeAdapter is
order.bridgeData
);
} else if (protocolId == BridgeProtocols.DODO) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeDodo(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.DODOV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeDodoV2(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CRYPTOCOM) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCryptoCom(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.BANCOR) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBancor(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.COFIX) {
boughtAmount = _tradeCoFiX(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.KYBERDMM) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeKyberDmm(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.LIDO) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeLido(
sellToken,
buyToken,
@@ -252,6 +229,7 @@ contract BridgeAdapter is
order.bridgeData
);
} else if (protocolId == BridgeProtocols.AAVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeAaveV2(
sellToken,
buyToken,
@@ -259,13 +237,28 @@ contract BridgeAdapter is
order.bridgeData
);
} else if (protocolId == BridgeProtocols.COMPOUND) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCompound(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else {
} else if (protocolId == BridgeProtocols.BANCORV3) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBancorV3(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.SYNTHETIX) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeSynthetix(
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeZeroExBridge(
sellToken,
buyToken,

View File

@@ -0,0 +1,134 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinAaveV2.sol";
import "./mixins/MixinBalancerV2.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinWOOFi.sol";
import "./mixins/MixinZeroExBridge.sol";
contract FantomBridgeAdapter is
AbstractBridgeAdapter(250, "Fantom"),
MixinAaveV2,
MixinBalancerV2,
MixinCurve,
MixinCurveV2,
MixinNerve,
MixinUniswapV2,
MixinWOOFi,
MixinZeroExBridge
{
constructor(IEtherTokenV06 weth)
public
MixinCurve(weth)
{}
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bool dryRun
)
internal
override
returns (uint256 boughtAmount, bool supportedSource)
{
uint128 protocolId = uint128(uint256(order.source) >> 128);
if (protocolId == BridgeProtocols.CURVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurve(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CURVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV2(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.BALANCERV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBalancerV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.AAVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeAaveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.WOOFI) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeWOOFi(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeZeroExBridge(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
}
emit BridgeFill(
order.source,
sellToken,
buyToken,
sellAmount,
boughtAmount
);
}
}

View File

@@ -50,6 +50,10 @@ interface IBridgeAdapter {
uint256 outputTokenAmount
);
function isSupportedSource(bytes32 source)
external
returns (bool isSupported);
function trade(
BridgeOrder calldata order,
IERC20TokenV06 sellToken,

View File

@@ -0,0 +1,122 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinSynthetix.sol";
import "./mixins/MixinUniswapV3.sol";
import "./mixins/MixinVelodrome.sol";
import "./mixins/MixinZeroExBridge.sol";
contract OptimismBridgeAdapter is
AbstractBridgeAdapter(10, "Optimism"),
MixinCurve,
MixinCurveV2,
MixinNerve,
MixinSynthetix,
MixinUniswapV3,
MixinVelodrome,
MixinZeroExBridge
{
constructor(IEtherTokenV06 weth)
public
MixinCurve(weth)
{}
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bool dryRun
)
internal
override
returns (uint256 boughtAmount, bool supportedSource)
{
uint128 protocolId = uint128(uint256(order.source) >> 128);
if (protocolId == BridgeProtocols.CURVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurve(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CURVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV3(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.VELODROME) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeVelodrome(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.SYNTHETIX) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeSynthetix(
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeZeroExBridge(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
}
emit BridgeFill(
order.source,
sellToken,
buyToken,
sellAmount,
boughtAmount
);
}
}

View File

@@ -0,0 +1,188 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinAaveV2.sol";
import "./mixins/MixinBalancerV2.sol";
import "./mixins/MixinBalancerV2Batch.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinDodo.sol";
import "./mixins/MixinDodoV2.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinMStable.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinUniswapV3.sol";
import "./mixins/MixinWOOFi.sol";
import "./mixins/MixinZeroExBridge.sol";
contract PolygonBridgeAdapter is
AbstractBridgeAdapter(137, "Polygon"),
MixinAaveV2,
MixinBalancerV2,
MixinBalancerV2Batch,
MixinCurve,
MixinCurveV2,
MixinDodo,
MixinDodoV2,
MixinKyberDmm,
MixinMStable,
MixinNerve,
MixinUniswapV2,
MixinUniswapV3,
MixinWOOFi,
MixinZeroExBridge
{
constructor(IEtherTokenV06 weth)
public
MixinCurve(weth)
{}
function _trade(
BridgeOrder memory order,
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bool dryRun
)
internal
override
returns (uint256 boughtAmount, bool supportedSource)
{
uint128 protocolId = uint128(uint256(order.source) >> 128);
if (protocolId == BridgeProtocols.CURVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurve(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CURVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV3(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV2(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.BALANCERV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBalancerV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.BALANCERV2BATCH) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBalancerV2Batch(
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.MSTABLE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeMStable(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.DODO) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeDodo(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.DODOV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeDodoV2(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.KYBERDMM) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeKyberDmm(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.AAVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeAaveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.WOOFI) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeWOOFi(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeZeroExBridge(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
}
emit BridgeFill(
order.source,
sellToken,
buyToken,
sellAmount,
boughtAmount
);
}
}

View File

@@ -0,0 +1,107 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
interface IBalancerV2BatchSwapVault {
enum SwapKind { GIVEN_IN, GIVEN_OUT }
struct BatchSwapStep {
bytes32 poolId;
uint256 assetInIndex;
uint256 assetOutIndex;
uint256 amount;
bytes userData;
}
struct FundManagement {
address sender;
bool fromInternalBalance;
address payable recipient;
bool toInternalBalance;
}
function batchSwap(
SwapKind kind,
BatchSwapStep[] calldata swaps,
IERC20TokenV06[] calldata assets,
FundManagement calldata funds,
int256[] calldata limits,
uint256 deadline
) external returns (int256[] memory amounts);
}
contract MixinBalancerV2Batch {
using LibERC20TokenV06 for IERC20TokenV06;
struct BalancerV2BatchBridgeData {
IBalancerV2BatchSwapVault vault;
IBalancerV2BatchSwapVault.BatchSwapStep[] swapSteps;
IERC20TokenV06[] assets;
}
function _tradeBalancerV2Batch(
uint256 sellAmount,
bytes memory bridgeData
)
internal
returns (uint256 boughtAmount)
{
// Decode the bridge data.
(
IBalancerV2BatchSwapVault vault,
IBalancerV2BatchSwapVault.BatchSwapStep[] memory swapSteps,
address[] memory assets_
) = abi.decode(bridgeData, (IBalancerV2BatchSwapVault, IBalancerV2BatchSwapVault.BatchSwapStep[], address[]));
IERC20TokenV06[] memory assets;
assembly { assets := assets_ }
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
assets[0].approveIfBelow(address(vault), sellAmount);
swapSteps[0].amount = sellAmount;
int256[] memory limits = new int256[](assets.length);
for (uint256 i = 0; i < limits.length; ++i) {
limits[i] = type(int256).max;
}
int256[] memory amounts = vault.batchSwap(
IBalancerV2BatchSwapVault.SwapKind.GIVEN_IN,
swapSteps,
assets,
IBalancerV2BatchSwapVault.FundManagement({
sender: address(this),
fromInternalBalance: false,
recipient: payable(address(this)),
toInternalBalance: false
}),
limits,
block.timestamp + 1
);
require(amounts[amounts.length - 1] <= 0, 'Unexpected BalancerV2Batch output');
return uint256(amounts[amounts.length - 1] * -1);
}
}

View File

@@ -0,0 +1,128 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
/*
BancorV3
*/
interface IBancorV3 {
/**
* @dev performs a trade by providing the source amount and returns the target amount and the associated fee
*
* requirements:
*
* - the caller must be the network contract
*/
function tradeBySourceAmount(
address sourceToken,
address targetToken,
uint256 sourceAmount,
uint256 minReturnAmount,
uint256 deadline,
address beneficiary
) external payable returns (uint256 amount);
}
contract MixinBancorV3 {
using LibERC20TokenV06 for IERC20TokenV06;
IERC20TokenV06 constant public BANCORV3_ETH_ADDRESS =
IERC20TokenV06(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
IEtherTokenV06 private immutable WETH;
constructor(IEtherTokenV06 weth)
public
{
WETH = weth;
}
function _tradeBancorV3(
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
internal
returns (uint256 amountOut)
{
IBancorV3 router;
IERC20TokenV06[] memory path;
address[] memory _path;
uint256 payableAmount = 0;
{
(router, _path) = abi.decode(bridgeData, (IBancorV3, address[]));
// To get around `abi.decode()` not supporting interface array types.
assembly { path := _path }
}
require(path.length >= 2, "MixinBancorV3/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(
path[path.length - 1] == buyToken,
"MixinBancorV3/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
);
//swap WETH->ETH as Bancor only deals in ETH
if(_path[0] == address(WETH)) {
//withdraw the sell amount of WETH for ETH
WETH.withdraw(sellAmount);
payableAmount = sellAmount;
// set _path[0] to the ETH address if WETH is our buy token
_path[0] = address(BANCORV3_ETH_ADDRESS);
} else {
// Grant the BancorV3 router an allowance to sell the first token.
path[0].approveIfBelow(address(router), sellAmount);
}
// if we are buying WETH we need to swap to ETH and deposit into WETH after the swap
if(_path[1] == address(WETH)){
_path[1] = address(BANCORV3_ETH_ADDRESS);
}
uint256 amountOut = router.tradeBySourceAmount{value: payableAmount}(
_path[0],
_path[1],
// Sell all tokens we hold.
sellAmount,
// Minimum buy amount.
1,
//deadline
block.timestamp + 1,
// address of the mixin
address(this)
);
// if we want to return WETH deposit the ETH amount we sold
if(buyToken == WETH){
WETH.deposit{value: amountOut}();
}
return amountOut;
}
}

View File

@@ -1,92 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
interface ICoFiXRouter {
// msg.value = fee
function swapExactTokensForETH(
address token,
uint amountIn,
uint amountOutMin,
address to,
address rewardTo,
uint deadline
) external payable returns (uint _amountIn, uint _amountOut);
// msg.value = amountIn + fee
function swapExactETHForTokens(
address token,
uint amountIn,
uint amountOutMin,
address to,
address rewardTo,
uint deadline
) external payable returns (uint _amountIn, uint _amountOut);
}
interface ICoFiXPair {
function swapWithExact(address outToken, address to)
external
payable
returns (
uint amountIn,
uint amountOut,
uint oracleFeeChange,
uint256[4] memory tradeInfo
);
}
contract MixinCoFiX {
using LibERC20TokenV06 for IERC20TokenV06;
function _tradeCoFiX(
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
internal
returns (uint256 boughtAmount)
{
(uint256 fee, ICoFiXPair pool) = abi.decode(bridgeData, (uint256, ICoFiXPair));
// Transfer tokens into the pool
LibERC20TokenV06.compatTransfer(
sellToken,
address(pool),
sellAmount
);
// Call the swap exact with the tokens now in the pool
// pay the NEST Oracle fee with ETH
(/* In */, boughtAmount, , ) = pool.swapWithExact{value: fee}(
address(buyToken),
address(this)
);
return boughtAmount;
}
}

View File

@@ -0,0 +1,98 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../IBridgeAdapter.sol";
/*
UniswapV2
*/
interface IGmxRouter {
// /// @dev Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path.
// /// The first element of path is the input token, the last is the output token, and any intermediate elements represent
// /// intermediate pairs to trade through (if, for example, a direct pair does not exist).
// /// @param _path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
// /// @param _amountIn The amount of input tokens to send.
// /// @param _minOut The minimum amount of output tokens that must be received for the transaction not to revert.
// /// @param _reciever Recipient of the output tokens.
function swap(
address[] calldata _path, uint256 _amountIn, uint256 _minOut, address _receiver
) external;
}
contract MixinGMX {
using LibERC20TokenV06 for IERC20TokenV06;
using LibSafeMathV06 for uint256;
function _tradeGMX(
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
public
returns (uint256 boughtAmount)
{
address _router;
address reader;
address vault;
address[] memory _path;
IGmxRouter router;
IERC20TokenV06[] memory path;
{
//decode the bridge data
(_router, reader, vault, _path) = abi.decode(bridgeData, (address, address, address, address[]));
// To get around `abi.decode()` not supporting interface array types.
assembly { path := _path }
}
require(path.length >= 2, "MixinGMX/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(
path[path.length - 1] == buyToken,
"MixinGMX/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
);
//connect to the GMX router
router = IGmxRouter(_router);
// Grant the GMX router an allowance to sell the first token.
path[0].approveIfBelow(address(router), sellAmount);
//track the balance to know how much we bought
uint256 beforeBalance = buyToken.balanceOf(address(this));
router.swap(
// Convert to `buyToken` along this path.
_path,
// Sell all tokens we hold.
sellAmount,
// Minimum buy amount.
0,
// Recipient is `this`.
address(this)
);
//calculate the difference in balance from preswap->postswap to find how many tokens out
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
return boughtAmount;
}
}

View File

@@ -1,124 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
import "../IBridgeAdapter.sol";
interface IKyberNetworkProxy {
/// @dev Sells `sellTokenAddress` tokens for `buyTokenAddress` tokens
/// using a hint for the reserve.
/// @param sellToken Token to sell.
/// @param sellAmount Amount of tokens to sell.
/// @param buyToken Token to buy.
/// @param recipientAddress Address to send bought tokens to.
/// @param maxBuyTokenAmount A limit on the amount of tokens to buy.
/// @param minConversionRate The minimal conversion rate. If actual rate
/// is lower, trade is canceled.
/// @param walletId The wallet ID to send part of the fees
/// @param hint The hint for the selective inclusion (or exclusion) of reserves
/// @return boughtAmount Amount of tokens bought.
function tradeWithHint(
IERC20TokenV06 sellToken,
uint256 sellAmount,
IERC20TokenV06 buyToken,
address payable recipientAddress,
uint256 maxBuyTokenAmount,
uint256 minConversionRate,
address payable walletId,
bytes calldata hint
)
external
payable
returns (uint256 boughtAmount);
}
contract MixinKyber {
using LibERC20TokenV06 for IERC20TokenV06;
/// @dev Address indicating the trade is using ETH
IERC20TokenV06 private immutable KYBER_ETH_ADDRESS =
IERC20TokenV06(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
/// @dev Mainnet address of the WETH contract.
IEtherTokenV06 private immutable WETH;
constructor(IEtherTokenV06 weth)
public
{
WETH = weth;
}
function _tradeKyber(
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
internal
returns (uint256 boughtAmount)
{
(IKyberNetworkProxy kyber, bytes memory hint) =
abi.decode(bridgeData, (IKyberNetworkProxy, bytes));
uint256 payableAmount = 0;
if (sellToken != WETH) {
// If the input token is not WETH, grant an allowance to the exchange
// to spend them.
sellToken.approveIfBelow(
address(kyber),
sellAmount
);
} else {
// If the input token is WETH, unwrap it and attach it to the call.
payableAmount = sellAmount;
WETH.withdraw(payableAmount);
}
// Try to sell all of this contract's input token balance through
// `KyberNetworkProxy.trade()`.
boughtAmount = kyber.tradeWithHint{ value: payableAmount }(
// Input token.
sellToken == WETH ? KYBER_ETH_ADDRESS : sellToken,
// Sell amount.
sellAmount,
// Output token.
buyToken == WETH ? KYBER_ETH_ADDRESS : buyToken,
// Transfer to this contract
address(uint160(address(this))),
// Buy as much as possible.
uint256(-1),
// Lowest minimum conversion rate
1,
// No affiliate address.
address(0),
hint
);
// If receving ETH, wrap it to WETH.
if (buyToken == WETH) {
WETH.deposit{ value: boughtAmount }();
}
return boughtAmount;
}
}

View File

@@ -26,7 +26,7 @@ import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
/// @dev Minimal interface for minting StETH
interface ILido {
interface IStETH {
/// @dev Adds eth to the pool
/// @param _referral optional address for referrals
/// @return StETH Amount of shares generated
@@ -37,6 +37,33 @@ interface ILido {
function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);
}
/// @dev Minimal interface for wrapping/unwrapping stETH.
interface IWstETH {
/**
* @notice Exchanges stETH to wstETH
* @param _stETHAmount amount of stETH to wrap in exchange for wstETH
* @dev Requirements:
* - `_stETHAmount` must be non-zero
* - msg.sender must approve at least `_stETHAmount` stETH to this
* contract.
* - msg.sender must have at least `_stETHAmount` of stETH.
* User should first approve _stETHAmount to the WstETH contract
* @return Amount of wstETH user receives after wrap
*/
function wrap(uint256 _stETHAmount) external returns (uint256);
/**
* @notice Exchanges wstETH to stETH
* @param _wstETHAmount amount of wstETH to uwrap in exchange for stETH
* @dev Requirements:
* - `_wstETHAmount` must be non-zero
* - msg.sender must have at least `_wstETHAmount` wstETH.
* @return Amount of stETH user receives after unwrap
*/
function unwrap(uint256 _wstETHAmount) external returns (uint256);
}
contract MixinLido {
using LibERC20TokenV06 for IERC20TokenV06;
@@ -59,12 +86,43 @@ contract MixinLido {
internal
returns (uint256 boughtAmount)
{
(ILido lido) = abi.decode(bridgeData, (ILido));
if (address(sellToken) == address(WETH) && address(buyToken) == address(lido)) {
if (address(sellToken) == address(WETH)) {
return _tradeStETH(buyToken, sellAmount, bridgeData);
}
return _tradeWstETH(sellToken, buyToken, sellAmount, bridgeData);
}
function _tradeStETH(
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
) private returns (uint256 boughtAmount) {
(IStETH stETH) = abi.decode(bridgeData, (IStETH));
if (address(buyToken) == address(stETH)) {
WETH.withdraw(sellAmount);
boughtAmount = lido.getPooledEthByShares(lido.submit{ value: sellAmount}(address(0)));
} else {
revert("MixinLido/UNSUPPORTED_TOKEN_PAIR");
return stETH.getPooledEthByShares(stETH.submit{ value: sellAmount}(address(0)));
}
revert("MixinLido/UNSUPPORTED_TOKEN_PAIR");
}
function _tradeWstETH(
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
) private returns(uint256 boughtAmount){
(IEtherTokenV06 stETH, IWstETH wstETH) = abi.decode(bridgeData, (IEtherTokenV06, IWstETH));
if (address(sellToken) == address(stETH) && address(buyToken) == address(wstETH) ) {
sellToken.approveIfBelow(address(wstETH), sellAmount);
return wstETH.wrap(sellAmount);
}
if (address(sellToken) == address(wstETH) && address(buyToken) == address(stETH) ) {
return wstETH.unwrap(sellAmount);
}
revert("MixinLido/UNSUPPORTED_TOKEN_PAIR");
}
}

View File

@@ -1,76 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../IBridgeAdapter.sol";
interface IOasis {
/// @dev Sell `sellAmount` of `sellToken` token and receive `buyToken` token.
/// @param sellToken The token being sold.
/// @param sellAmount The amount of `sellToken` token being sold.
/// @param buyToken The token being bought.
/// @param minBoughtAmount Minimum amount of `buyToken` token to buy.
/// @return boughtAmount Amount of `buyToken` bought.
function sellAllAmount(
IERC20TokenV06 sellToken,
uint256 sellAmount,
IERC20TokenV06 buyToken,
uint256 minBoughtAmount
)
external
returns (uint256 boughtAmount);
}
contract MixinOasis {
using LibERC20TokenV06 for IERC20TokenV06;
function _tradeOasis(
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
internal
returns (uint256 boughtAmount)
{
(IOasis oasis) = abi.decode(bridgeData, (IOasis));
// Grant an allowance to the exchange to spend `sellToken` token.
sellToken.approveIfBelow(
address(oasis),
sellAmount
);
// Try to sell all of this contract's `sellToken` token balance.
boughtAmount = oasis.sellAllAmount(
sellToken,
sellAmount,
buyToken,
// min fill amount
1
);
return boughtAmount;
}
}

View File

@@ -0,0 +1,98 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
interface IPlatypusRouter {
function swapTokensForTokens(
address[] calldata tokenPath,
address[] calldata poolPath,
uint256 fromAmount,
uint256 minimumToAmount,
address to,
uint256 deadline
) external returns (uint256 amountOut, uint256 haircut);
}
contract MixinPlatypus {
using LibERC20TokenV06 for IERC20TokenV06;
using LibSafeMathV06 for uint256;
function _tradePlatypus(
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
public
returns (uint256 boughtAmount)
{
IPlatypusRouter router;
address _router;
address[] memory _pool;
IERC20TokenV06[] memory path;
address[] memory _path;
{
(_router, _pool, _path) = abi.decode(bridgeData, (address, address[], address[]));
// To get around `abi.decode()` not supporting interface array types.
assembly { path := _path }
}
//connect to the ptp router
router = IPlatypusRouter(_router);
require(path.length >= 2, "MixinPlatypus/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(
path[path.length - 1] == buyToken,
"MixinPlatypus/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
);
// Grant the Platypus router an allowance to sell the first token.
path[0].approveIfBelow(address(router), sellAmount);
//keep track of the previous balance to confirm amount out
uint256 beforeBalance = buyToken.balanceOf(address(this));
router.swapTokensForTokens(
// Convert to `buyToken` along this path.
_path,
// pool to swap on
_pool,
// Sell all tokens we hold.
sellAmount,
// Minimum buy amount.
0,
// Recipient is `this`.
address(this),
block.timestamp + 1
);
//calculate the buy amount from the tokens we recieved
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
return boughtAmount;
}
}

View File

@@ -0,0 +1,99 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
interface ISynthetix {
// Ethereum Mainnet
function exchangeAtomically(
bytes32 sourceCurrencyKey,
uint256 sourceAmount,
bytes32 destinationCurrencyKey,
bytes32 trackingCode,
uint256 minAmount
) external returns (uint256 amountReceived);
// Optimism
function exchangeWithTracking(
bytes32 sourceCurrencyKey,
uint256 sourceAmount,
bytes32 destinationCurrencyKey,
address rewardAddress,
bytes32 trackingCode
) external returns (uint256 amountReceived);
}
contract MixinSynthetix {
address private constant rewardAddress =
0x5C80239D97E1eB216b5c3D8fBa5DE5Be5d38e4C9;
bytes32 constant trackingCode =
0x3058000000000000000000000000000000000000000000000000000000000000;
function _tradeSynthetix(uint256 sellAmount, bytes memory bridgeData)
public
returns (uint256 boughtAmount)
{
(
ISynthetix synthetix,
bytes32 sourceCurrencyKey,
bytes32 destinationCurrencyKey
) = abi.decode(
bridgeData,
(ISynthetix, bytes32, bytes32)
);
boughtAmount = exchange(
synthetix,
sourceCurrencyKey,
destinationCurrencyKey,
sellAmount
);
}
function exchange(
ISynthetix synthetix,
bytes32 sourceCurrencyKey,
bytes32 destinationCurrencyKey,
uint256 sellAmount
) internal returns (uint256 boughtAmount) {
uint256 chainId;
assembly {
chainId := chainid()
}
if (chainId == 1) {
boughtAmount = synthetix.exchangeAtomically(
sourceCurrencyKey,
sellAmount,
destinationCurrencyKey,
trackingCode,
0
);
} else {
boughtAmount = synthetix.exchangeWithTracking(
sourceCurrencyKey,
sellAmount,
destinationCurrencyKey,
rewardAddress,
trackingCode
);
}
}
}

View File

@@ -0,0 +1,64 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
interface IVelodromeRouter {
function swapExactTokensForTokensSimple(
uint256 amountIn,
uint256 amountOutMin,
address tokenFrom,
address tokenTo,
bool stable,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
}
contract MixinVelodrome {
using LibERC20TokenV06 for IERC20TokenV06;
function _tradeVelodrome(
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
internal
returns (uint256 boughtAmount)
{
(IVelodromeRouter router, bool stable) = abi.decode(bridgeData, (IVelodromeRouter, bool));
sellToken.approveIfBelow(address(router), sellAmount);
boughtAmount = router.swapExactTokensForTokensSimple(
sellAmount,
0,
address(sellToken),
address(buyToken),
stable,
address(this),
block.timestamp + 1
)[1];
}
}

View File

@@ -0,0 +1,136 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
import "../IBridgeAdapter.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
/// @dev WooFI pool interface.
interface IWooPP {
function quoteToken() external view returns (address);
function sellBase(
address baseToken,
uint256 baseAmount,
uint256 minQuoteAmount,
address to,
address rebateTo
) external returns (uint256 quoteAmount);
function sellQuote(
address baseToken,
uint256 quoteAmount,
uint256 minBaseAmount,
address to,
address rebateTo
) external returns (uint256 baseAmount);
/// @dev Query the amount for selling the base token amount.
/// @param baseToken the base token to sell
/// @param baseAmount the amount to sell
/// @return quoteAmount the swapped quote amount
function querySellBase(
address baseToken,
uint256 baseAmount
) external view returns (uint256 quoteAmount);
}
contract MixinWOOFi{
using LibERC20TokenV06 for IERC20TokenV06;
using LibERC20TokenV06 for IEtherTokenV06;
using LibSafeMathV06 for uint256;
address constant rebateAddress = 0xBfdcBB4C05843163F491C24f9c0019c510786304;
// /// @dev Swaps an exact amount of input tokens for as many output tokens as possible.
// /// @param _amountIn Amount of input tokens to send
// /// @param _minAmountOut The minimum amount of output tokens that must be received for the transaction not to revert.
// /// @param _tokenIn Input token
// /// @param _tokenOut Output token
// /// @param _to recipient of tokens
// /// @param pool WOOFi pool where the swap will happen
function _tradeWOOFi(
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
public
returns (uint256 boughtAmount)
{
(IWooPP _pool) = abi.decode(bridgeData, (IWooPP));
uint256 beforeBalance = buyToken.balanceOf(address(this));
sellToken.approveIfBelow(address(_pool), sellAmount);
_swap(
sellAmount,
address(sellToken),
address(buyToken),
_pool
);
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
}
function _swap(
uint _amountIn,
address _tokenIn,
address _tokenOut,
IWooPP pool
) internal {
address quoteToken = pool.quoteToken();
if (_tokenIn == quoteToken) {
pool.sellQuote(
_tokenOut,
_amountIn,
1,
address(this),
rebateAddress
);
} else if (_tokenOut == quoteToken) {
pool.sellBase(
_tokenIn,
_amountIn,
1,
address(this),
rebateAddress
);
} else {
uint256 quoteAmount = pool.sellBase(
_tokenIn,
_amountIn,
0,
address(this),
rebateAddress
);
IERC20TokenV06(pool.quoteToken()).approveIfBelow(address(pool), quoteAmount);
pool.sellQuote(
_tokenOut,
quoteAmount,
1,
address(this),
rebateAddress
);
}
}
}

View File

@@ -0,0 +1,30 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
import "forge-std/Test.sol";
contract ContractTest is Test {
function setUp() public {}
function testExample() public {
assertTrue(true);
}
}

View File

@@ -0,0 +1,8 @@
[default]
src = 'contracts/src'
out = 'foundry-artifacts'
test = 'contracts/test/foundry'
libs = ["contracts/deps/", "../utils/contracts/src/"]
remappings = ['@0x/contracts-utils/=../utils/', '@0x/contracts-erc20/=../erc20/', 'src/=./contracts/src']
cache_path = 'foundry-cache'
optimizer_runs = 1000000

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-zero-ex",
"version": "0.31.1",
"version": "0.36.2",
"engines": {
"node": ">=6.12"
},
@@ -38,12 +38,13 @@
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES",
"publish:private": "yarn build && gitpkg publish",
"rollback": "node ./lib/scripts/rollback.js"
"rollback": "node ./lib/scripts/rollback.js",
"typechain": "typechain --target=ethers-v5 --out-dir='typechain-wrappers' './foundry-artifacts/**/*.json'"
},
"config": {
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature",
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature,AvalancheBridgeAdapter,BSCBridgeAdapter,CeloBridgeAdapter,EthereumBridgeAdapter,FantomBridgeAdapter,OptimismBridgeAdapter,PolygonBridgeAdapter",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
"abis": "./test/generated-artifacts/@(AbstractBridgeAdapter|AffiliateFeeTransformer|AvalancheBridgeAdapter|BSCBridgeAdapter|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeProtocols|CeloBridgeAdapter|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|EthereumBridgeAdapter|FantomBridgeAdapter|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2|MixinBalancerV2Batch|MixinBancor|MixinBancorV3|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinGMX|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinPlatypus|MixinShell|MixinSynthetix|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinVelodrome|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OptimismBridgeAdapter|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PolygonBridgeAdapter|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
},
"repository": {
"type": "git",
@@ -55,16 +56,17 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/zero-ex",
"devDependencies": {
"@0x/abi-gen": "^5.7.2",
"@0x/contract-addresses": "^6.12.0",
"@0x/contracts-erc20": "^3.3.27",
"@0x/contracts-gen": "^2.0.43",
"@0x/contracts-test-utils": "^5.4.18",
"@0x/dev-utils": "^4.2.11",
"@0x/abi-gen": "^5.8.0",
"@0x/contract-addresses": "^6.19.1",
"@0x/contracts-erc20": "^3.3.35",
"@0x/contracts-gen": "^2.0.46",
"@0x/contracts-test-utils": "^5.4.26",
"@0x/dev-utils": "^4.2.14",
"@0x/order-utils": "^10.4.28",
"@0x/sol-compiler": "^4.7.8",
"@0x/sol-compiler": "^4.8.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
"@typechain/ethers-v5": "^10.0.0",
"@types/isomorphic-fetch": "^0.0.35",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
@@ -78,18 +80,19 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typechain": "^8.0.0",
"typedoc": "~0.16.11",
"typescript": "4.2.2"
"typescript": "4.6.3"
},
"dependencies": {
"@0x/base-contract": "^6.4.5",
"@0x/protocol-utils": "^1.11.1",
"@0x/subproviders": "^6.6.2",
"@0x/types": "^3.3.4",
"@0x/typescript-typings": "^5.2.1",
"@0x/utils": "^6.5.0",
"@0x/web3-wrapper": "^7.6.2",
"ethereum-types": "^3.6.0",
"@0x/base-contract": "^6.5.0",
"@0x/protocol-utils": "^11.16.2",
"@0x/subproviders": "^6.6.5",
"@0x/types": "^3.3.6",
"@0x/typescript-typings": "^5.3.1",
"@0x/utils": "^6.5.3",
"@0x/web3-wrapper": "^7.6.5",
"ethereum-types": "^3.7.0",
"ethereumjs-util": "^7.0.10",
"ethers": "~4.0.4"
},

View File

@@ -6,9 +6,13 @@
import { ContractArtifact } from 'ethereum-types';
import * as AffiliateFeeTransformer from '../generated-artifacts/AffiliateFeeTransformer.json';
import * as AvalancheBridgeAdapter from '../generated-artifacts/AvalancheBridgeAdapter.json';
import * as BatchFillNativeOrdersFeature from '../generated-artifacts/BatchFillNativeOrdersFeature.json';
import * as BridgeAdapter from '../generated-artifacts/BridgeAdapter.json';
import * as BSCBridgeAdapter from '../generated-artifacts/BSCBridgeAdapter.json';
import * as CeloBridgeAdapter from '../generated-artifacts/CeloBridgeAdapter.json';
import * as CurveLiquidityProvider from '../generated-artifacts/CurveLiquidityProvider.json';
import * as EthereumBridgeAdapter from '../generated-artifacts/EthereumBridgeAdapter.json';
import * as FantomBridgeAdapter from '../generated-artifacts/FantomBridgeAdapter.json';
import * as FeeCollector from '../generated-artifacts/FeeCollector.json';
import * as FeeCollectorController from '../generated-artifacts/FeeCollectorController.json';
import * as FillQuoteTransformer from '../generated-artifacts/FillQuoteTransformer.json';
@@ -30,9 +34,11 @@ import * as LogMetadataTransformer from '../generated-artifacts/LogMetadataTrans
import * as MetaTransactionsFeature from '../generated-artifacts/MetaTransactionsFeature.json';
import * as MultiplexFeature from '../generated-artifacts/MultiplexFeature.json';
import * as NativeOrdersFeature from '../generated-artifacts/NativeOrdersFeature.json';
import * as OptimismBridgeAdapter from '../generated-artifacts/OptimismBridgeAdapter.json';
import * as OtcOrdersFeature from '../generated-artifacts/OtcOrdersFeature.json';
import * as OwnableFeature from '../generated-artifacts/OwnableFeature.json';
import * as PayTakerTransformer from '../generated-artifacts/PayTakerTransformer.json';
import * as PolygonBridgeAdapter from '../generated-artifacts/PolygonBridgeAdapter.json';
import * as PositiveSlippageFeeTransformer from '../generated-artifacts/PositiveSlippageFeeTransformer.json';
import * as SimpleFunctionRegistryFeature from '../generated-artifacts/SimpleFunctionRegistryFeature.json';
import * as TransformERC20Feature from '../generated-artifacts/TransformERC20Feature.json';
@@ -58,7 +64,6 @@ export const artifacts = {
AffiliateFeeTransformer: AffiliateFeeTransformer as ContractArtifact,
MetaTransactionsFeature: MetaTransactionsFeature as ContractArtifact,
LogMetadataTransformer: LogMetadataTransformer as ContractArtifact,
BridgeAdapter: BridgeAdapter as ContractArtifact,
LiquidityProviderFeature: LiquidityProviderFeature as ContractArtifact,
ILiquidityProviderFeature: ILiquidityProviderFeature as ContractArtifact,
NativeOrdersFeature: NativeOrdersFeature as ContractArtifact,
@@ -72,4 +77,11 @@ export const artifacts = {
IMultiplexFeature: IMultiplexFeature as ContractArtifact,
OtcOrdersFeature: OtcOrdersFeature as ContractArtifact,
IOtcOrdersFeature: IOtcOrdersFeature as ContractArtifact,
AvalancheBridgeAdapter: AvalancheBridgeAdapter as ContractArtifact,
BSCBridgeAdapter: BSCBridgeAdapter as ContractArtifact,
CeloBridgeAdapter: CeloBridgeAdapter as ContractArtifact,
EthereumBridgeAdapter: EthereumBridgeAdapter as ContractArtifact,
FantomBridgeAdapter: FantomBridgeAdapter as ContractArtifact,
OptimismBridgeAdapter: OptimismBridgeAdapter as ContractArtifact,
PolygonBridgeAdapter: PolygonBridgeAdapter as ContractArtifact,
};

View File

@@ -35,7 +35,11 @@ export * from './bloom_filter_utils';
export { GREEDY_TOKENS } from './constants';
export {
AffiliateFeeTransformerContract,
BridgeAdapterContract,
AvalancheBridgeAdapterContract,
BSCBridgeAdapterContract,
CeloBridgeAdapterContract,
EthereumBridgeAdapterContract,
FantomBridgeAdapterContract,
FillQuoteTransformerContract,
IOwnableFeatureContract,
IOwnableFeatureEvents,
@@ -45,7 +49,9 @@ export {
IZeroExContract,
LogMetadataTransformerContract,
MultiplexFeatureContract,
OptimismBridgeAdapterContract,
PayTakerTransformerContract,
PolygonBridgeAdapterContract,
PositiveSlippageFeeTransformerContract,
TransformERC20FeatureContract,
WethTransformerContract,

View File

@@ -4,9 +4,13 @@
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/affiliate_fee_transformer';
export * from '../generated-wrappers/avalanche_bridge_adapter';
export * from '../generated-wrappers/b_s_c_bridge_adapter';
export * from '../generated-wrappers/batch_fill_native_orders_feature';
export * from '../generated-wrappers/bridge_adapter';
export * from '../generated-wrappers/celo_bridge_adapter';
export * from '../generated-wrappers/curve_liquidity_provider';
export * from '../generated-wrappers/ethereum_bridge_adapter';
export * from '../generated-wrappers/fantom_bridge_adapter';
export * from '../generated-wrappers/fee_collector';
export * from '../generated-wrappers/fee_collector_controller';
export * from '../generated-wrappers/fill_quote_transformer';
@@ -28,9 +32,11 @@ export * from '../generated-wrappers/log_metadata_transformer';
export * from '../generated-wrappers/meta_transactions_feature';
export * from '../generated-wrappers/multiplex_feature';
export * from '../generated-wrappers/native_orders_feature';
export * from '../generated-wrappers/optimism_bridge_adapter';
export * from '../generated-wrappers/otc_orders_feature';
export * from '../generated-wrappers/ownable_feature';
export * from '../generated-wrappers/pay_taker_transformer';
export * from '../generated-wrappers/polygon_bridge_adapter';
export * from '../generated-wrappers/positive_slippage_fee_transformer';
export * from '../generated-wrappers/simple_function_registry_feature';
export * from '../generated-wrappers/transform_erc20_feature';

View File

@@ -5,15 +5,20 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as AbstractBridgeAdapter from '../test/generated-artifacts/AbstractBridgeAdapter.json';
import * as AffiliateFeeTransformer from '../test/generated-artifacts/AffiliateFeeTransformer.json';
import * as AvalancheBridgeAdapter from '../test/generated-artifacts/AvalancheBridgeAdapter.json';
import * as BatchFillNativeOrdersFeature from '../test/generated-artifacts/BatchFillNativeOrdersFeature.json';
import * as BootstrapFeature from '../test/generated-artifacts/BootstrapFeature.json';
import * as BridgeAdapter from '../test/generated-artifacts/BridgeAdapter.json';
import * as BridgeProtocols from '../test/generated-artifacts/BridgeProtocols.json';
import * as BSCBridgeAdapter from '../test/generated-artifacts/BSCBridgeAdapter.json';
import * as CeloBridgeAdapter from '../test/generated-artifacts/CeloBridgeAdapter.json';
import * as CurveLiquidityProvider from '../test/generated-artifacts/CurveLiquidityProvider.json';
import * as ERC1155OrdersFeature from '../test/generated-artifacts/ERC1155OrdersFeature.json';
import * as ERC165Feature from '../test/generated-artifacts/ERC165Feature.json';
import * as ERC721OrdersFeature from '../test/generated-artifacts/ERC721OrdersFeature.json';
import * as EthereumBridgeAdapter from '../test/generated-artifacts/EthereumBridgeAdapter.json';
import * as FantomBridgeAdapter from '../test/generated-artifacts/FantomBridgeAdapter.json';
import * as FeeCollector from '../test/generated-artifacts/FeeCollector.json';
import * as FeeCollectorController from '../test/generated-artifacts/FeeCollectorController.json';
import * as FillQuoteTransformer from '../test/generated-artifacts/FillQuoteTransformer.json';
@@ -101,26 +106,29 @@ import * as MetaTransactionsFeature from '../test/generated-artifacts/MetaTransa
import * as MixinAaveV2 from '../test/generated-artifacts/MixinAaveV2.json';
import * as MixinBalancer from '../test/generated-artifacts/MixinBalancer.json';
import * as MixinBalancerV2 from '../test/generated-artifacts/MixinBalancerV2.json';
import * as MixinBalancerV2Batch from '../test/generated-artifacts/MixinBalancerV2Batch.json';
import * as MixinBancor from '../test/generated-artifacts/MixinBancor.json';
import * as MixinCoFiX from '../test/generated-artifacts/MixinCoFiX.json';
import * as MixinBancorV3 from '../test/generated-artifacts/MixinBancorV3.json';
import * as MixinCompound from '../test/generated-artifacts/MixinCompound.json';
import * as MixinCryptoCom from '../test/generated-artifacts/MixinCryptoCom.json';
import * as MixinCurve from '../test/generated-artifacts/MixinCurve.json';
import * as MixinCurveV2 from '../test/generated-artifacts/MixinCurveV2.json';
import * as MixinDodo from '../test/generated-artifacts/MixinDodo.json';
import * as MixinDodoV2 from '../test/generated-artifacts/MixinDodoV2.json';
import * as MixinKyber from '../test/generated-artifacts/MixinKyber.json';
import * as MixinGMX from '../test/generated-artifacts/MixinGMX.json';
import * as MixinKyberDmm from '../test/generated-artifacts/MixinKyberDmm.json';
import * as MixinLido from '../test/generated-artifacts/MixinLido.json';
import * as MixinMakerPSM from '../test/generated-artifacts/MixinMakerPSM.json';
import * as MixinMooniswap from '../test/generated-artifacts/MixinMooniswap.json';
import * as MixinMStable from '../test/generated-artifacts/MixinMStable.json';
import * as MixinNerve from '../test/generated-artifacts/MixinNerve.json';
import * as MixinOasis from '../test/generated-artifacts/MixinOasis.json';
import * as MixinPlatypus from '../test/generated-artifacts/MixinPlatypus.json';
import * as MixinShell from '../test/generated-artifacts/MixinShell.json';
import * as MixinSynthetix from '../test/generated-artifacts/MixinSynthetix.json';
import * as MixinUniswap from '../test/generated-artifacts/MixinUniswap.json';
import * as MixinUniswapV2 from '../test/generated-artifacts/MixinUniswapV2.json';
import * as MixinUniswapV3 from '../test/generated-artifacts/MixinUniswapV3.json';
import * as MixinVelodrome from '../test/generated-artifacts/MixinVelodrome.json';
import * as MixinZeroExBridge from '../test/generated-artifacts/MixinZeroExBridge.json';
import * as MooniswapLiquidityProvider from '../test/generated-artifacts/MooniswapLiquidityProvider.json';
import * as MultiplexFeature from '../test/generated-artifacts/MultiplexFeature.json';
@@ -136,11 +144,13 @@ import * as NativeOrdersInfo from '../test/generated-artifacts/NativeOrdersInfo.
import * as NativeOrdersProtocolFees from '../test/generated-artifacts/NativeOrdersProtocolFees.json';
import * as NativeOrdersSettlement from '../test/generated-artifacts/NativeOrdersSettlement.json';
import * as NFTOrders from '../test/generated-artifacts/NFTOrders.json';
import * as OptimismBridgeAdapter from '../test/generated-artifacts/OptimismBridgeAdapter.json';
import * as OtcOrdersFeature from '../test/generated-artifacts/OtcOrdersFeature.json';
import * as OwnableFeature from '../test/generated-artifacts/OwnableFeature.json';
import * as PancakeSwapFeature from '../test/generated-artifacts/PancakeSwapFeature.json';
import * as PayTakerTransformer from '../test/generated-artifacts/PayTakerTransformer.json';
import * as PermissionlessTransformerDeployer from '../test/generated-artifacts/PermissionlessTransformerDeployer.json';
import * as PolygonBridgeAdapter from '../test/generated-artifacts/PolygonBridgeAdapter.json';
import * as PositiveSlippageFeeTransformer from '../test/generated-artifacts/PositiveSlippageFeeTransformer.json';
import * as SimpleFunctionRegistryFeature from '../test/generated-artifacts/SimpleFunctionRegistryFeature.json';
import * as TestBridge from '../test/generated-artifacts/TestBridge.json';
@@ -200,198 +210,208 @@ import * as WethTransformer from '../test/generated-artifacts/WethTransformer.js
import * as ZeroEx from '../test/generated-artifacts/ZeroEx.json';
import * as ZeroExOptimized from '../test/generated-artifacts/ZeroExOptimized.json';
export const artifacts = {
IZeroEx: IZeroEx as ContractArtifact,
ZeroEx: ZeroEx as ContractArtifact,
ZeroExOptimized: ZeroExOptimized as ContractArtifact,
LibCommonRichErrors: LibCommonRichErrors as ContractArtifact,
LibLiquidityProviderRichErrors: LibLiquidityProviderRichErrors as ContractArtifact,
LibMetaTransactionsRichErrors: LibMetaTransactionsRichErrors as ContractArtifact,
LibNFTOrdersRichErrors: LibNFTOrdersRichErrors as ContractArtifact,
LibNativeOrdersRichErrors: LibNativeOrdersRichErrors as ContractArtifact,
LibOwnableRichErrors: LibOwnableRichErrors as ContractArtifact,
LibProxyRichErrors: LibProxyRichErrors as ContractArtifact,
LibSignatureRichErrors: LibSignatureRichErrors as ContractArtifact,
LibSimpleFunctionRegistryRichErrors: LibSimpleFunctionRegistryRichErrors as ContractArtifact,
LibTransformERC20RichErrors: LibTransformERC20RichErrors as ContractArtifact,
LibWalletRichErrors: LibWalletRichErrors as ContractArtifact,
FeeCollector: FeeCollector as ContractArtifact,
FeeCollectorController: FeeCollectorController as ContractArtifact,
FlashWallet: FlashWallet as ContractArtifact,
IFlashWallet: IFlashWallet as ContractArtifact,
ILiquidityProviderSandbox: ILiquidityProviderSandbox as ContractArtifact,
LibFeeCollector: LibFeeCollector as ContractArtifact,
LiquidityProviderSandbox: LiquidityProviderSandbox as ContractArtifact,
PermissionlessTransformerDeployer: PermissionlessTransformerDeployer as ContractArtifact,
TransformerDeployer: TransformerDeployer as ContractArtifact,
BatchFillNativeOrdersFeature: BatchFillNativeOrdersFeature as ContractArtifact,
BootstrapFeature: BootstrapFeature as ContractArtifact,
ERC165Feature: ERC165Feature as ContractArtifact,
FundRecoveryFeature: FundRecoveryFeature as ContractArtifact,
LiquidityProviderFeature: LiquidityProviderFeature as ContractArtifact,
MetaTransactionsFeature: MetaTransactionsFeature as ContractArtifact,
NativeOrdersFeature: NativeOrdersFeature as ContractArtifact,
OtcOrdersFeature: OtcOrdersFeature as ContractArtifact,
OwnableFeature: OwnableFeature as ContractArtifact,
PancakeSwapFeature: PancakeSwapFeature as ContractArtifact,
SimpleFunctionRegistryFeature: SimpleFunctionRegistryFeature as ContractArtifact,
TransformERC20Feature: TransformERC20Feature as ContractArtifact,
UniswapFeature: UniswapFeature as ContractArtifact,
UniswapV3Feature: UniswapV3Feature as ContractArtifact,
IBatchFillNativeOrdersFeature: IBatchFillNativeOrdersFeature as ContractArtifact,
IBootstrapFeature: IBootstrapFeature as ContractArtifact,
IERC1155OrdersFeature: IERC1155OrdersFeature as ContractArtifact,
IERC165Feature: IERC165Feature as ContractArtifact,
IERC721OrdersFeature: IERC721OrdersFeature as ContractArtifact,
IFeature: IFeature as ContractArtifact,
IFundRecoveryFeature: IFundRecoveryFeature as ContractArtifact,
ILiquidityProviderFeature: ILiquidityProviderFeature as ContractArtifact,
IMetaTransactionsFeature: IMetaTransactionsFeature as ContractArtifact,
IMultiplexFeature: IMultiplexFeature as ContractArtifact,
INativeOrdersEvents: INativeOrdersEvents as ContractArtifact,
INativeOrdersFeature: INativeOrdersFeature as ContractArtifact,
IOtcOrdersFeature: IOtcOrdersFeature as ContractArtifact,
IOwnableFeature: IOwnableFeature as ContractArtifact,
IPancakeSwapFeature: IPancakeSwapFeature as ContractArtifact,
ISimpleFunctionRegistryFeature: ISimpleFunctionRegistryFeature as ContractArtifact,
ITokenSpenderFeature: ITokenSpenderFeature as ContractArtifact,
ITransformERC20Feature: ITransformERC20Feature as ContractArtifact,
IUniswapFeature: IUniswapFeature as ContractArtifact,
IUniswapV3Feature: IUniswapV3Feature as ContractArtifact,
LibNFTOrder: LibNFTOrder as ContractArtifact,
LibNativeOrder: LibNativeOrder as ContractArtifact,
LibSignature: LibSignature as ContractArtifact,
MultiplexFeature: MultiplexFeature as ContractArtifact,
MultiplexLiquidityProvider: MultiplexLiquidityProvider as ContractArtifact,
MultiplexOtc: MultiplexOtc as ContractArtifact,
MultiplexRfq: MultiplexRfq as ContractArtifact,
MultiplexTransformERC20: MultiplexTransformERC20 as ContractArtifact,
MultiplexUniswapV2: MultiplexUniswapV2 as ContractArtifact,
MultiplexUniswapV3: MultiplexUniswapV3 as ContractArtifact,
NativeOrdersCancellation: NativeOrdersCancellation as ContractArtifact,
NativeOrdersInfo: NativeOrdersInfo as ContractArtifact,
NativeOrdersProtocolFees: NativeOrdersProtocolFees as ContractArtifact,
NativeOrdersSettlement: NativeOrdersSettlement as ContractArtifact,
ERC1155OrdersFeature: ERC1155OrdersFeature as ContractArtifact,
ERC721OrdersFeature: ERC721OrdersFeature as ContractArtifact,
NFTOrders: NFTOrders as ContractArtifact,
FixinCommon: FixinCommon as ContractArtifact,
FixinEIP712: FixinEIP712 as ContractArtifact,
FixinERC1155Spender: FixinERC1155Spender as ContractArtifact,
FixinERC721Spender: FixinERC721Spender as ContractArtifact,
FixinProtocolFees: FixinProtocolFees as ContractArtifact,
FixinReentrancyGuard: FixinReentrancyGuard as ContractArtifact,
FixinTokenSpender: FixinTokenSpender as ContractArtifact,
CurveLiquidityProvider: CurveLiquidityProvider as ContractArtifact,
MooniswapLiquidityProvider: MooniswapLiquidityProvider as ContractArtifact,
FullMigration: FullMigration as ContractArtifact,
InitialMigration: InitialMigration as ContractArtifact,
LibBootstrap: LibBootstrap as ContractArtifact,
LibMigrate: LibMigrate as ContractArtifact,
LibERC1155OrdersStorage: LibERC1155OrdersStorage as ContractArtifact,
LibERC721OrdersStorage: LibERC721OrdersStorage as ContractArtifact,
LibMetaTransactionsStorage: LibMetaTransactionsStorage as ContractArtifact,
LibNativeOrdersStorage: LibNativeOrdersStorage as ContractArtifact,
LibOtcOrdersStorage: LibOtcOrdersStorage as ContractArtifact,
LibOwnableStorage: LibOwnableStorage as ContractArtifact,
LibProxyStorage: LibProxyStorage as ContractArtifact,
LibReentrancyGuardStorage: LibReentrancyGuardStorage as ContractArtifact,
LibSimpleFunctionRegistryStorage: LibSimpleFunctionRegistryStorage as ContractArtifact,
LibStorage: LibStorage as ContractArtifact,
LibTransformERC20Storage: LibTransformERC20Storage as ContractArtifact,
AffiliateFeeTransformer: AffiliateFeeTransformer as ContractArtifact,
FillQuoteTransformer: FillQuoteTransformer as ContractArtifact,
IERC20Transformer: IERC20Transformer as ContractArtifact,
LibERC20Transformer: LibERC20Transformer as ContractArtifact,
LogMetadataTransformer: LogMetadataTransformer as ContractArtifact,
PayTakerTransformer: PayTakerTransformer as ContractArtifact,
PositiveSlippageFeeTransformer: PositiveSlippageFeeTransformer as ContractArtifact,
Transformer: Transformer as ContractArtifact,
WethTransformer: WethTransformer as ContractArtifact,
BridgeAdapter: BridgeAdapter as ContractArtifact,
BridgeProtocols: BridgeProtocols as ContractArtifact,
IBridgeAdapter: IBridgeAdapter as ContractArtifact,
MixinAaveV2: MixinAaveV2 as ContractArtifact,
MixinBalancer: MixinBalancer as ContractArtifact,
MixinBalancerV2: MixinBalancerV2 as ContractArtifact,
MixinBancor: MixinBancor as ContractArtifact,
MixinCoFiX: MixinCoFiX as ContractArtifact,
MixinCompound: MixinCompound as ContractArtifact,
MixinCryptoCom: MixinCryptoCom as ContractArtifact,
MixinCurve: MixinCurve as ContractArtifact,
MixinCurveV2: MixinCurveV2 as ContractArtifact,
MixinDodo: MixinDodo as ContractArtifact,
MixinDodoV2: MixinDodoV2 as ContractArtifact,
MixinKyber: MixinKyber as ContractArtifact,
MixinKyberDmm: MixinKyberDmm as ContractArtifact,
MixinLido: MixinLido as ContractArtifact,
MixinMStable: MixinMStable as ContractArtifact,
MixinMakerPSM: MixinMakerPSM as ContractArtifact,
MixinMooniswap: MixinMooniswap as ContractArtifact,
MixinNerve: MixinNerve as ContractArtifact,
MixinOasis: MixinOasis as ContractArtifact,
MixinShell: MixinShell as ContractArtifact,
MixinUniswap: MixinUniswap as ContractArtifact,
MixinUniswapV2: MixinUniswapV2 as ContractArtifact,
MixinUniswapV3: MixinUniswapV3 as ContractArtifact,
MixinZeroExBridge: MixinZeroExBridge as ContractArtifact,
IERC1155Token: IERC1155Token as ContractArtifact,
IERC721Token: IERC721Token as ContractArtifact,
IFeeRecipient: IFeeRecipient as ContractArtifact,
ILiquidityProvider: ILiquidityProvider as ContractArtifact,
IMooniswapPool: IMooniswapPool as ContractArtifact,
IPropertyValidator: IPropertyValidator as ContractArtifact,
ITakerCallback: ITakerCallback as ContractArtifact,
IUniswapV2Pair: IUniswapV2Pair as ContractArtifact,
IUniswapV3Pool: IUniswapV3Pool as ContractArtifact,
IERC20Bridge: IERC20Bridge as ContractArtifact,
IStaking: IStaking as ContractArtifact,
ITestSimpleFunctionRegistryFeature: ITestSimpleFunctionRegistryFeature as ContractArtifact,
TestFixinProtocolFees: TestFixinProtocolFees as ContractArtifact,
TestTransformerHost: TestTransformerHost as ContractArtifact,
TestFillQuoteTransformerHost: TestFillQuoteTransformerHost as ContractArtifact,
TestTransformerDeployerTransformer: TestTransformerDeployerTransformer as ContractArtifact,
TestUniswapV3Feature: TestUniswapV3Feature as ContractArtifact,
TestBridge: TestBridge as ContractArtifact,
TestCallTarget: TestCallTarget as ContractArtifact,
TestDelegateCaller: TestDelegateCaller as ContractArtifact,
TestFeeCollectorController: TestFeeCollectorController as ContractArtifact,
TestFeeRecipient: TestFeeRecipient as ContractArtifact,
TestFillQuoteTransformerBridge: TestFillQuoteTransformerBridge as ContractArtifact,
TestFillQuoteTransformerExchange: TestFillQuoteTransformerExchange as ContractArtifact,
TestFillQuoteTransformerHost: TestFillQuoteTransformerHost as ContractArtifact,
TestFixinProtocolFees: TestFixinProtocolFees as ContractArtifact,
TestFixinTokenSpender: TestFixinTokenSpender as ContractArtifact,
TestFullMigration: TestFullMigration as ContractArtifact,
TestInitialMigration: TestInitialMigration as ContractArtifact,
TestLibNativeOrder: TestLibNativeOrder as ContractArtifact,
TestLibSignature: TestLibSignature as ContractArtifact,
TestMetaTransactionsNativeOrdersFeature: TestMetaTransactionsNativeOrdersFeature as ContractArtifact,
TestMetaTransactionsTransformERC20Feature: TestMetaTransactionsTransformERC20Feature as ContractArtifact,
TestMigrator: TestMigrator as ContractArtifact,
TestMintTokenERC20Transformer: TestMintTokenERC20Transformer as ContractArtifact,
TestNFTOrderPresigner: TestNFTOrderPresigner as ContractArtifact,
TestNativeOrdersFeature: TestNativeOrdersFeature as ContractArtifact,
TestNoEthRecipient: TestNoEthRecipient as ContractArtifact,
TestOrderSignerRegistryWithContractWallet: TestOrderSignerRegistryWithContractWallet as ContractArtifact,
TestPermissionlessTransformerDeployerSuicidal: TestPermissionlessTransformerDeployerSuicidal as ContractArtifact,
TestPermissionlessTransformerDeployerTransformer: TestPermissionlessTransformerDeployerTransformer as ContractArtifact,
TestPropertyValidator: TestPropertyValidator as ContractArtifact,
TestRfqOriginRegistration: TestRfqOriginRegistration as ContractArtifact,
TestSimpleFunctionRegistryFeatureImpl1: TestSimpleFunctionRegistryFeatureImpl1 as ContractArtifact,
TestSimpleFunctionRegistryFeatureImpl2: TestSimpleFunctionRegistryFeatureImpl2 as ContractArtifact,
TestStaking: TestStaking as ContractArtifact,
TestTransformERC20: TestTransformERC20 as ContractArtifact,
TestTransformerBase: TestTransformerBase as ContractArtifact,
TestTransformerDeployerTransformer: TestTransformerDeployerTransformer as ContractArtifact,
TestTransformerHost: TestTransformerHost as ContractArtifact,
TestUniswapV3Feature: TestUniswapV3Feature as ContractArtifact,
TestWethTransformerHost: TestWethTransformerHost as ContractArtifact,
TestZeroExFeature: TestZeroExFeature as ContractArtifact,
TestCurve: TestCurve as ContractArtifact,
TestLiquidityProvider: TestLiquidityProvider as ContractArtifact,
TestMooniswap: TestMooniswap as ContractArtifact,
TestUniswapV2Factory: TestUniswapV2Factory as ContractArtifact,
TestUniswapV2Pool: TestUniswapV2Pool as ContractArtifact,
TestUniswapV3Factory: TestUniswapV3Factory as ContractArtifact,
TestFullMigration: TestFullMigration as ContractArtifact,
TestLibSignature: TestLibSignature as ContractArtifact,
TestUniswapV3Pool: TestUniswapV3Pool as ContractArtifact,
TestMintableERC1155Token: TestMintableERC1155Token as ContractArtifact,
TestMintableERC20Token: TestMintableERC20Token as ContractArtifact,
TestMooniswap: TestMooniswap as ContractArtifact,
TestUniswapV3Factory: TestUniswapV3Factory as ContractArtifact,
TestCurve: TestCurve as ContractArtifact,
TestUniswapV2Pool: TestUniswapV2Pool as ContractArtifact,
TestUniswapV2Factory: TestUniswapV2Factory as ContractArtifact,
TestLiquidityProvider: TestLiquidityProvider as ContractArtifact,
TestMetaTransactionsNativeOrdersFeature: TestMetaTransactionsNativeOrdersFeature as ContractArtifact,
TestFeeCollectorController: TestFeeCollectorController as ContractArtifact,
TestNFTOrderPresigner: TestNFTOrderPresigner as ContractArtifact,
TestMetaTransactionsTransformERC20Feature: TestMetaTransactionsTransformERC20Feature as ContractArtifact,
TestTransformERC20: TestTransformERC20 as ContractArtifact,
TestFeeRecipient: TestFeeRecipient as ContractArtifact,
TestPermissionlessTransformerDeployerTransformer: TestPermissionlessTransformerDeployerTransformer as ContractArtifact,
TestMigrator: TestMigrator as ContractArtifact,
TestFixinTokenSpender: TestFixinTokenSpender as ContractArtifact,
TestDelegateCaller: TestDelegateCaller as ContractArtifact,
TestTransformerBase: TestTransformerBase as ContractArtifact,
TestZeroExFeature: TestZeroExFeature as ContractArtifact,
TestLibNativeOrder: TestLibNativeOrder as ContractArtifact,
TestWethTransformerHost: TestWethTransformerHost as ContractArtifact,
TestPropertyValidator: TestPropertyValidator as ContractArtifact,
TestMintTokenERC20Transformer: TestMintTokenERC20Transformer as ContractArtifact,
TestFillQuoteTransformerBridge: TestFillQuoteTransformerBridge as ContractArtifact,
TestOrderSignerRegistryWithContractWallet: TestOrderSignerRegistryWithContractWallet as ContractArtifact,
TestNativeOrdersFeature: TestNativeOrdersFeature as ContractArtifact,
TestRfqOriginRegistration: TestRfqOriginRegistration as ContractArtifact,
TestStaking: TestStaking as ContractArtifact,
TestFillQuoteTransformerExchange: TestFillQuoteTransformerExchange as ContractArtifact,
TestInitialMigration: TestInitialMigration as ContractArtifact,
TestMintableERC721Token: TestMintableERC721Token as ContractArtifact,
TestTokenSpenderERC20Token: TestTokenSpenderERC20Token as ContractArtifact,
TestWeth: TestWeth as ContractArtifact,
TestMintableERC1155Token: TestMintableERC1155Token as ContractArtifact,
TestMintableERC20Token: TestMintableERC20Token as ContractArtifact,
TestSimpleFunctionRegistryFeatureImpl1: TestSimpleFunctionRegistryFeatureImpl1 as ContractArtifact,
ITestSimpleFunctionRegistryFeature: ITestSimpleFunctionRegistryFeature as ContractArtifact,
TestPermissionlessTransformerDeployerSuicidal: TestPermissionlessTransformerDeployerSuicidal as ContractArtifact,
TestSimpleFunctionRegistryFeatureImpl2: TestSimpleFunctionRegistryFeatureImpl2 as ContractArtifact,
InitialMigration: InitialMigration as ContractArtifact,
LibMigrate: LibMigrate as ContractArtifact,
LibBootstrap: LibBootstrap as ContractArtifact,
FullMigration: FullMigration as ContractArtifact,
ZeroExOptimized: ZeroExOptimized as ContractArtifact,
FixinERC721Spender: FixinERC721Spender as ContractArtifact,
FixinTokenSpender: FixinTokenSpender as ContractArtifact,
FixinERC1155Spender: FixinERC1155Spender as ContractArtifact,
FixinReentrancyGuard: FixinReentrancyGuard as ContractArtifact,
FixinProtocolFees: FixinProtocolFees as ContractArtifact,
FixinEIP712: FixinEIP712 as ContractArtifact,
FixinCommon: FixinCommon as ContractArtifact,
BatchFillNativeOrdersFeature: BatchFillNativeOrdersFeature as ContractArtifact,
LiquidityProviderFeature: LiquidityProviderFeature as ContractArtifact,
ERC165Feature: ERC165Feature as ContractArtifact,
MetaTransactionsFeature: MetaTransactionsFeature as ContractArtifact,
NFTOrders: NFTOrders as ContractArtifact,
ERC1155OrdersFeature: ERC1155OrdersFeature as ContractArtifact,
ERC721OrdersFeature: ERC721OrdersFeature as ContractArtifact,
TransformERC20Feature: TransformERC20Feature as ContractArtifact,
OwnableFeature: OwnableFeature as ContractArtifact,
LibSignature: LibSignature as ContractArtifact,
LibNativeOrder: LibNativeOrder as ContractArtifact,
LibNFTOrder: LibNFTOrder as ContractArtifact,
NativeOrdersSettlement: NativeOrdersSettlement as ContractArtifact,
NativeOrdersCancellation: NativeOrdersCancellation as ContractArtifact,
NativeOrdersProtocolFees: NativeOrdersProtocolFees as ContractArtifact,
NativeOrdersInfo: NativeOrdersInfo as ContractArtifact,
UniswapV3Feature: UniswapV3Feature as ContractArtifact,
NativeOrdersFeature: NativeOrdersFeature as ContractArtifact,
UniswapFeature: UniswapFeature as ContractArtifact,
BootstrapFeature: BootstrapFeature as ContractArtifact,
MultiplexTransformERC20: MultiplexTransformERC20 as ContractArtifact,
MultiplexRfq: MultiplexRfq as ContractArtifact,
MultiplexFeature: MultiplexFeature as ContractArtifact,
MultiplexLiquidityProvider: MultiplexLiquidityProvider as ContractArtifact,
MultiplexOtc: MultiplexOtc as ContractArtifact,
MultiplexUniswapV3: MultiplexUniswapV3 as ContractArtifact,
MultiplexUniswapV2: MultiplexUniswapV2 as ContractArtifact,
OtcOrdersFeature: OtcOrdersFeature as ContractArtifact,
FundRecoveryFeature: FundRecoveryFeature as ContractArtifact,
SimpleFunctionRegistryFeature: SimpleFunctionRegistryFeature as ContractArtifact,
PancakeSwapFeature: PancakeSwapFeature as ContractArtifact,
IMultiplexFeature: IMultiplexFeature as ContractArtifact,
IPancakeSwapFeature: IPancakeSwapFeature as ContractArtifact,
IUniswapV3Feature: IUniswapV3Feature as ContractArtifact,
INativeOrdersFeature: INativeOrdersFeature as ContractArtifact,
IOwnableFeature: IOwnableFeature as ContractArtifact,
IERC165Feature: IERC165Feature as ContractArtifact,
IFundRecoveryFeature: IFundRecoveryFeature as ContractArtifact,
IERC721OrdersFeature: IERC721OrdersFeature as ContractArtifact,
ILiquidityProviderFeature: ILiquidityProviderFeature as ContractArtifact,
IFeature: IFeature as ContractArtifact,
IMetaTransactionsFeature: IMetaTransactionsFeature as ContractArtifact,
IBootstrapFeature: IBootstrapFeature as ContractArtifact,
IOtcOrdersFeature: IOtcOrdersFeature as ContractArtifact,
IERC1155OrdersFeature: IERC1155OrdersFeature as ContractArtifact,
IUniswapFeature: IUniswapFeature as ContractArtifact,
ITokenSpenderFeature: ITokenSpenderFeature as ContractArtifact,
ISimpleFunctionRegistryFeature: ISimpleFunctionRegistryFeature as ContractArtifact,
ITransformERC20Feature: ITransformERC20Feature as ContractArtifact,
INativeOrdersEvents: INativeOrdersEvents as ContractArtifact,
IBatchFillNativeOrdersFeature: IBatchFillNativeOrdersFeature as ContractArtifact,
IZeroEx: IZeroEx as ContractArtifact,
ZeroEx: ZeroEx as ContractArtifact,
LibNativeOrdersStorage: LibNativeOrdersStorage as ContractArtifact,
LibTransformERC20Storage: LibTransformERC20Storage as ContractArtifact,
LibOtcOrdersStorage: LibOtcOrdersStorage as ContractArtifact,
LibSimpleFunctionRegistryStorage: LibSimpleFunctionRegistryStorage as ContractArtifact,
LibStorage: LibStorage as ContractArtifact,
LibERC721OrdersStorage: LibERC721OrdersStorage as ContractArtifact,
LibReentrancyGuardStorage: LibReentrancyGuardStorage as ContractArtifact,
LibMetaTransactionsStorage: LibMetaTransactionsStorage as ContractArtifact,
LibProxyStorage: LibProxyStorage as ContractArtifact,
LibOwnableStorage: LibOwnableStorage as ContractArtifact,
LibERC1155OrdersStorage: LibERC1155OrdersStorage as ContractArtifact,
FillQuoteTransformer: FillQuoteTransformer as ContractArtifact,
AffiliateFeeTransformer: AffiliateFeeTransformer as ContractArtifact,
PositiveSlippageFeeTransformer: PositiveSlippageFeeTransformer as ContractArtifact,
Transformer: Transformer as ContractArtifact,
LibERC20Transformer: LibERC20Transformer as ContractArtifact,
MixinShell: MixinShell as ContractArtifact,
MixinMakerPSM: MixinMakerPSM as ContractArtifact,
MixinDodoV2: MixinDodoV2 as ContractArtifact,
MixinMStable: MixinMStable as ContractArtifact,
MixinBalancerV2: MixinBalancerV2 as ContractArtifact,
MixinCurveV2: MixinCurveV2 as ContractArtifact,
MixinPlatypus: MixinPlatypus as ContractArtifact,
MixinNerve: MixinNerve as ContractArtifact,
MixinBancor: MixinBancor as ContractArtifact,
MixinUniswap: MixinUniswap as ContractArtifact,
MixinBalancer: MixinBalancer as ContractArtifact,
MixinCompound: MixinCompound as ContractArtifact,
MixinBalancerV2Batch: MixinBalancerV2Batch as ContractArtifact,
MixinLido: MixinLido as ContractArtifact,
MixinUniswapV2: MixinUniswapV2 as ContractArtifact,
MixinZeroExBridge: MixinZeroExBridge as ContractArtifact,
MixinUniswapV3: MixinUniswapV3 as ContractArtifact,
MixinBancorV3: MixinBancorV3 as ContractArtifact,
MixinKyberDmm: MixinKyberDmm as ContractArtifact,
MixinGMX: MixinGMX as ContractArtifact,
MixinCurve: MixinCurve as ContractArtifact,
MixinMooniswap: MixinMooniswap as ContractArtifact,
MixinDodo: MixinDodo as ContractArtifact,
MixinCryptoCom: MixinCryptoCom as ContractArtifact,
MixinSynthetix: MixinSynthetix as ContractArtifact,
MixinAaveV2: MixinAaveV2 as ContractArtifact,
MixinVelodrome: MixinVelodrome as ContractArtifact,
CeloBridgeAdapter: CeloBridgeAdapter as ContractArtifact,
FantomBridgeAdapter: FantomBridgeAdapter as ContractArtifact,
OptimismBridgeAdapter: OptimismBridgeAdapter as ContractArtifact,
AbstractBridgeAdapter: AbstractBridgeAdapter as ContractArtifact,
EthereumBridgeAdapter: EthereumBridgeAdapter as ContractArtifact,
PolygonBridgeAdapter: PolygonBridgeAdapter as ContractArtifact,
AvalancheBridgeAdapter: AvalancheBridgeAdapter as ContractArtifact,
BridgeProtocols: BridgeProtocols as ContractArtifact,
IBridgeAdapter: IBridgeAdapter as ContractArtifact,
BSCBridgeAdapter: BSCBridgeAdapter as ContractArtifact,
LogMetadataTransformer: LogMetadataTransformer as ContractArtifact,
IERC20Transformer: IERC20Transformer as ContractArtifact,
PayTakerTransformer: PayTakerTransformer as ContractArtifact,
WethTransformer: WethTransformer as ContractArtifact,
PermissionlessTransformerDeployer: PermissionlessTransformerDeployer as ContractArtifact,
FlashWallet: FlashWallet as ContractArtifact,
FeeCollector: FeeCollector as ContractArtifact,
IFlashWallet: IFlashWallet as ContractArtifact,
LiquidityProviderSandbox: LiquidityProviderSandbox as ContractArtifact,
TransformerDeployer: TransformerDeployer as ContractArtifact,
LibFeeCollector: LibFeeCollector as ContractArtifact,
FeeCollectorController: FeeCollectorController as ContractArtifact,
ILiquidityProviderSandbox: ILiquidityProviderSandbox as ContractArtifact,
LibLiquidityProviderRichErrors: LibLiquidityProviderRichErrors as ContractArtifact,
LibSignatureRichErrors: LibSignatureRichErrors as ContractArtifact,
LibWalletRichErrors: LibWalletRichErrors as ContractArtifact,
LibTransformERC20RichErrors: LibTransformERC20RichErrors as ContractArtifact,
LibNativeOrdersRichErrors: LibNativeOrdersRichErrors as ContractArtifact,
LibNFTOrdersRichErrors: LibNFTOrdersRichErrors as ContractArtifact,
LibMetaTransactionsRichErrors: LibMetaTransactionsRichErrors as ContractArtifact,
LibCommonRichErrors: LibCommonRichErrors as ContractArtifact,
LibOwnableRichErrors: LibOwnableRichErrors as ContractArtifact,
LibProxyRichErrors: LibProxyRichErrors as ContractArtifact,
LibSimpleFunctionRegistryRichErrors: LibSimpleFunctionRegistryRichErrors as ContractArtifact,
MooniswapLiquidityProvider: MooniswapLiquidityProvider as ContractArtifact,
CurveLiquidityProvider: CurveLiquidityProvider as ContractArtifact,
IMooniswapPool: IMooniswapPool as ContractArtifact,
IFeeRecipient: IFeeRecipient as ContractArtifact,
IERC721Token: IERC721Token as ContractArtifact,
IERC1155Token: IERC1155Token as ContractArtifact,
IPropertyValidator: IPropertyValidator as ContractArtifact,
ITakerCallback: ITakerCallback as ContractArtifact,
IUniswapV3Pool: IUniswapV3Pool as ContractArtifact,
IStaking: IStaking as ContractArtifact,
IERC20Bridge: IERC20Bridge as ContractArtifact,
IUniswapV2Pair: IUniswapV2Pair as ContractArtifact,
ILiquidityProvider: ILiquidityProvider as ContractArtifact,
};

View File

@@ -28,7 +28,7 @@ import { artifacts } from '../artifacts';
import { TestFillQuoteTransformerBridgeContract } from '../generated-wrappers/test_fill_quote_transformer_bridge';
import { getRandomLimitOrder, getRandomRfqOrder } from '../utils/orders';
import {
BridgeAdapterContract,
EthereumBridgeAdapterContract,
FillQuoteTransformerContract,
TestFillQuoteTransformerExchangeContract,
TestFillQuoteTransformerHostContract,
@@ -52,7 +52,8 @@ blockchainTests.resets('FillQuoteTransformer', env => {
let singleProtocolFee: BigNumber;
const GAS_PRICE = 1337;
const TEST_BRIDGE_SOURCE = hexUtils.random(32);
// Left half is 0, corresponding to BridgeProtocol.Unknown
const TEST_BRIDGE_SOURCE = hexUtils.leftPad(hexUtils.random(16), 32);
const HIGH_BIT = new BigNumber(2).pow(255);
const REVERT_AMOUNT = new BigNumber('0xdeadbeef');
@@ -64,8 +65,8 @@ blockchainTests.resets('FillQuoteTransformer', env => {
env.txDefaults,
artifacts,
);
const bridgeAdapter = await BridgeAdapterContract.deployFrom0xArtifactAsync(
artifacts.BridgeAdapter,
const bridgeAdapter = await EthereumBridgeAdapterContract.deployFrom0xArtifactAsync(
artifacts.EthereumBridgeAdapter,
env.provider,
env.txDefaults,
artifacts,

View File

@@ -3,15 +3,20 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../test/generated-wrappers/abstract_bridge_adapter';
export * from '../test/generated-wrappers/affiliate_fee_transformer';
export * from '../test/generated-wrappers/avalanche_bridge_adapter';
export * from '../test/generated-wrappers/b_s_c_bridge_adapter';
export * from '../test/generated-wrappers/batch_fill_native_orders_feature';
export * from '../test/generated-wrappers/bootstrap_feature';
export * from '../test/generated-wrappers/bridge_adapter';
export * from '../test/generated-wrappers/bridge_protocols';
export * from '../test/generated-wrappers/celo_bridge_adapter';
export * from '../test/generated-wrappers/curve_liquidity_provider';
export * from '../test/generated-wrappers/erc1155_orders_feature';
export * from '../test/generated-wrappers/erc165_feature';
export * from '../test/generated-wrappers/erc721_orders_feature';
export * from '../test/generated-wrappers/ethereum_bridge_adapter';
export * from '../test/generated-wrappers/fantom_bridge_adapter';
export * from '../test/generated-wrappers/fee_collector';
export * from '../test/generated-wrappers/fee_collector_controller';
export * from '../test/generated-wrappers/fill_quote_transformer';
@@ -99,26 +104,29 @@ export * from '../test/generated-wrappers/meta_transactions_feature';
export * from '../test/generated-wrappers/mixin_aave_v2';
export * from '../test/generated-wrappers/mixin_balancer';
export * from '../test/generated-wrappers/mixin_balancer_v2';
export * from '../test/generated-wrappers/mixin_balancer_v2_batch';
export * from '../test/generated-wrappers/mixin_bancor';
export * from '../test/generated-wrappers/mixin_co_fi_x';
export * from '../test/generated-wrappers/mixin_bancor_v3';
export * from '../test/generated-wrappers/mixin_compound';
export * from '../test/generated-wrappers/mixin_crypto_com';
export * from '../test/generated-wrappers/mixin_curve';
export * from '../test/generated-wrappers/mixin_curve_v2';
export * from '../test/generated-wrappers/mixin_dodo';
export * from '../test/generated-wrappers/mixin_dodo_v2';
export * from '../test/generated-wrappers/mixin_kyber';
export * from '../test/generated-wrappers/mixin_g_m_x';
export * from '../test/generated-wrappers/mixin_kyber_dmm';
export * from '../test/generated-wrappers/mixin_lido';
export * from '../test/generated-wrappers/mixin_m_stable';
export * from '../test/generated-wrappers/mixin_maker_p_s_m';
export * from '../test/generated-wrappers/mixin_mooniswap';
export * from '../test/generated-wrappers/mixin_nerve';
export * from '../test/generated-wrappers/mixin_oasis';
export * from '../test/generated-wrappers/mixin_platypus';
export * from '../test/generated-wrappers/mixin_shell';
export * from '../test/generated-wrappers/mixin_synthetix';
export * from '../test/generated-wrappers/mixin_uniswap';
export * from '../test/generated-wrappers/mixin_uniswap_v2';
export * from '../test/generated-wrappers/mixin_uniswap_v3';
export * from '../test/generated-wrappers/mixin_velodrome';
export * from '../test/generated-wrappers/mixin_zero_ex_bridge';
export * from '../test/generated-wrappers/mooniswap_liquidity_provider';
export * from '../test/generated-wrappers/multiplex_feature';
@@ -134,11 +142,13 @@ export * from '../test/generated-wrappers/native_orders_feature';
export * from '../test/generated-wrappers/native_orders_info';
export * from '../test/generated-wrappers/native_orders_protocol_fees';
export * from '../test/generated-wrappers/native_orders_settlement';
export * from '../test/generated-wrappers/optimism_bridge_adapter';
export * from '../test/generated-wrappers/otc_orders_feature';
export * from '../test/generated-wrappers/ownable_feature';
export * from '../test/generated-wrappers/pancake_swap_feature';
export * from '../test/generated-wrappers/pay_taker_transformer';
export * from '../test/generated-wrappers/permissionless_transformer_deployer';
export * from '../test/generated-wrappers/polygon_bridge_adapter';
export * from '../test/generated-wrappers/positive_slippage_fee_transformer';
export * from '../test/generated-wrappers/simple_function_registry_feature';
export * from '../test/generated-wrappers/test_bridge';

View File

@@ -4,9 +4,13 @@
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*", "./scripts/**/*"],
"files": [
"generated-artifacts/AffiliateFeeTransformer.json",
"generated-artifacts/AvalancheBridgeAdapter.json",
"generated-artifacts/BSCBridgeAdapter.json",
"generated-artifacts/BatchFillNativeOrdersFeature.json",
"generated-artifacts/BridgeAdapter.json",
"generated-artifacts/CeloBridgeAdapter.json",
"generated-artifacts/CurveLiquidityProvider.json",
"generated-artifacts/EthereumBridgeAdapter.json",
"generated-artifacts/FantomBridgeAdapter.json",
"generated-artifacts/FeeCollector.json",
"generated-artifacts/FeeCollectorController.json",
"generated-artifacts/FillQuoteTransformer.json",
@@ -28,23 +32,30 @@
"generated-artifacts/MetaTransactionsFeature.json",
"generated-artifacts/MultiplexFeature.json",
"generated-artifacts/NativeOrdersFeature.json",
"generated-artifacts/OptimismBridgeAdapter.json",
"generated-artifacts/OtcOrdersFeature.json",
"generated-artifacts/OwnableFeature.json",
"generated-artifacts/PayTakerTransformer.json",
"generated-artifacts/PolygonBridgeAdapter.json",
"generated-artifacts/PositiveSlippageFeeTransformer.json",
"generated-artifacts/SimpleFunctionRegistryFeature.json",
"generated-artifacts/TransformERC20Feature.json",
"generated-artifacts/WethTransformer.json",
"generated-artifacts/ZeroEx.json",
"test/generated-artifacts/AbstractBridgeAdapter.json",
"test/generated-artifacts/AffiliateFeeTransformer.json",
"test/generated-artifacts/AvalancheBridgeAdapter.json",
"test/generated-artifacts/BSCBridgeAdapter.json",
"test/generated-artifacts/BatchFillNativeOrdersFeature.json",
"test/generated-artifacts/BootstrapFeature.json",
"test/generated-artifacts/BridgeAdapter.json",
"test/generated-artifacts/BridgeProtocols.json",
"test/generated-artifacts/CeloBridgeAdapter.json",
"test/generated-artifacts/CurveLiquidityProvider.json",
"test/generated-artifacts/ERC1155OrdersFeature.json",
"test/generated-artifacts/ERC165Feature.json",
"test/generated-artifacts/ERC721OrdersFeature.json",
"test/generated-artifacts/EthereumBridgeAdapter.json",
"test/generated-artifacts/FantomBridgeAdapter.json",
"test/generated-artifacts/FeeCollector.json",
"test/generated-artifacts/FeeCollectorController.json",
"test/generated-artifacts/FillQuoteTransformer.json",
@@ -132,26 +143,29 @@
"test/generated-artifacts/MixinAaveV2.json",
"test/generated-artifacts/MixinBalancer.json",
"test/generated-artifacts/MixinBalancerV2.json",
"test/generated-artifacts/MixinBalancerV2Batch.json",
"test/generated-artifacts/MixinBancor.json",
"test/generated-artifacts/MixinCoFiX.json",
"test/generated-artifacts/MixinBancorV3.json",
"test/generated-artifacts/MixinCompound.json",
"test/generated-artifacts/MixinCryptoCom.json",
"test/generated-artifacts/MixinCurve.json",
"test/generated-artifacts/MixinCurveV2.json",
"test/generated-artifacts/MixinDodo.json",
"test/generated-artifacts/MixinDodoV2.json",
"test/generated-artifacts/MixinKyber.json",
"test/generated-artifacts/MixinGMX.json",
"test/generated-artifacts/MixinKyberDmm.json",
"test/generated-artifacts/MixinLido.json",
"test/generated-artifacts/MixinMStable.json",
"test/generated-artifacts/MixinMakerPSM.json",
"test/generated-artifacts/MixinMooniswap.json",
"test/generated-artifacts/MixinNerve.json",
"test/generated-artifacts/MixinOasis.json",
"test/generated-artifacts/MixinPlatypus.json",
"test/generated-artifacts/MixinShell.json",
"test/generated-artifacts/MixinSynthetix.json",
"test/generated-artifacts/MixinUniswap.json",
"test/generated-artifacts/MixinUniswapV2.json",
"test/generated-artifacts/MixinUniswapV3.json",
"test/generated-artifacts/MixinVelodrome.json",
"test/generated-artifacts/MixinZeroExBridge.json",
"test/generated-artifacts/MooniswapLiquidityProvider.json",
"test/generated-artifacts/MultiplexFeature.json",
@@ -167,11 +181,13 @@
"test/generated-artifacts/NativeOrdersInfo.json",
"test/generated-artifacts/NativeOrdersProtocolFees.json",
"test/generated-artifacts/NativeOrdersSettlement.json",
"test/generated-artifacts/OptimismBridgeAdapter.json",
"test/generated-artifacts/OtcOrdersFeature.json",
"test/generated-artifacts/OwnableFeature.json",
"test/generated-artifacts/PancakeSwapFeature.json",
"test/generated-artifacts/PayTakerTransformer.json",
"test/generated-artifacts/PermissionlessTransformerDeployer.json",
"test/generated-artifacts/PolygonBridgeAdapter.json",
"test/generated-artifacts/PositiveSlippageFeeTransformer.json",
"test/generated-artifacts/SimpleFunctionRegistryFeature.json",
"test/generated-artifacts/TestBridge.json",

View File

@@ -52,16 +52,16 @@
},
"config": {
"contractsPackages": "@0x/contracts-erc20 @0x/contracts-test-utils @0x/contracts-utils @0x/contracts-zero-ex @0x/contracts-treasury",
"nonContractPackages": "@0x/migrations @0x/contract-wrappers @0x/contract-addresses @0x/contract-artifacts @0x/contract-wrappers-test @0x/asset-swapper",
"nonContractPackages": "@0x/contract-wrappers @0x/contract-addresses @0x/contract-artifacts @0x/contract-wrappers-test @0x/asset-swapper",
"ignoreTestsForPackages": "",
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
"packagesWithDocPages": "@0x/contract-wrappers @0x/migrations",
"packagesWithDocPages": "@0x/contract-wrappers",
"ignoreDependencyVersions": "@types/styled-components @types/node",
"ignoreDependencyVersionsForPackage": "contract-wrappers"
},
"devDependencies": {
"@0x/monorepo-scripts": "^3.2.1",
"@0x-lerna-fork/lerna": "3.16.10",
"@0x/monorepo-scripts": "^3.2.4",
"@0xproject/npm-cli-login": "^0.0.11",
"async-child-process": "^1.1.1",
"coveralls": "^3.0.0",
@@ -71,10 +71,11 @@
"npm-run-all": "^4.1.2",
"prettier": "1.19.1",
"source-map-support": "^0.5.6",
"typescript": "4.2.2",
"typescript": "4.6.3",
"wsrun": "^5.2.4"
},
"resolutions": {
"merkle-patricia-tree": "3.0.0"
"merkle-patricia-tree": "3.0.0",
"**/bignumber.js": "^9.0.2"
}
}

View File

@@ -1,4 +1,320 @@
[
{
"version": "16.66.2",
"changes": [
{
"note": "Upgrade dependency",
"pr": 543
}
],
"timestamp": 1660073235
},
{
"version": "16.66.1",
"changes": [
{
"note": "Upgrade dependency",
"pr": 538
}
],
"timestamp": 1659926840
},
{
"version": "16.66.0",
"changes": [
{
"note": "Add WOOFi support",
"pr": 513
}
],
"timestamp": 1659750766
},
{
"version": "16.65.0",
"changes": [
{
"note": "Use 0x gas api instead of eth gas station api",
"pr": 532
}
],
"timestamp": 1659391840
},
{
"version": "16.64.0",
"changes": [
{
"note": "Refactor `TokenAdjacency` and `TokenAdjacencyBuilder`",
"pr": 517
},
{
"note": "Add Synthetix support`",
"pr": 518
},
{
"note": "Replace Beethoven X subgraph URL",
"pr": 519
},
{
"note": "Remove Mooniswap on Ethereum mainnet",
"pr": 529
}
],
"timestamp": 1658950329
},
{
"version": "16.63.1",
"changes": [
{
"note": "Better error handling for balancer cache",
"pr": 515
}
],
"timestamp": 1657661207
},
{
"version": "16.63.0",
"changes": [
{
"note": "Remove JS router",
"pr": 480
},
{
"note": "Removed Median price in favour of best gas adjusted price",
"pr": 480
}
],
"timestamp": 1656491792
},
{
"version": "16.62.2",
"changes": [
{
"note": "Offboard Smoothy and ComethSwap",
"pr": 509
}
]
},
{
"version": "16.62.1",
"changes": [
{
"note": "Remove nUSD from intermediate liquidity to save on sampler gas",
"pr": 505
}
],
"timestamp": 1655253622
},
{
"version": "16.62.0",
"changes": [
{
"note": "Add MDEX on BSC",
"pr": 496
},
{
"note": "Add KnightSwap on BSC",
"pr": 498
},
{
"note": "Add Velodrome support on Optimism",
"pr": 494
},
{
"note": "Do not send empty entries on Quote Report",
"pr": 501
},
{
"note": "KnightSwap/Mdex cosmetic change",
"pr": 502
},
{
"note": "Offboard JetSwap, CafeSwap, JulSwap, and PolyDex",
"pr": 503
}
],
"timestamp": 1655244958
},
{
"version": "16.61.0",
"changes": [
{
"note": "Add stETH wrap/unwrap support",
"pr": 476
},
{
"note": "Offboard/clean up Oasis, CoFix, and legacy Kyber",
"pr": 482
},
{
"note": "Add MeshSwap on Polygon",
"pr": 491
}
],
"timestamp": 1654284040
},
{
"version": "16.60.1",
"changes": [
{
"note": "Alias Balancer sor to the old version",
"pr": 481
}
],
"timestamp": 1652931596
},
{
"version": "16.60.0",
"changes": [
{
"note": "Add BiSwap on BSC",
"pr": 467
},
{
"note": "Add GMX and Platypus on Avalanche and Enable KyberDMM on bsc",
"pr": 478
},
{
"note": "Add Yoshi Exchange support in Fantom",
"pr": 473
},
{
"note": "Fix KyberDMM gas underestimation",
"pr": 479
}
],
"timestamp": 1652919697
},
{
"version": "16.59.0",
"changes": [
{
"note": "Remove SnowSwap on mainnet",
"pr": 468
},
{
"note": "Offboard Swerve Finance and LinkSwap",
"pr": 469
},
{
"note": "Offboard Eth2Dai",
"pr": 470
},
{
"note": "Add an optional IRfqClient for SwapQuoter#getSwapQuoteAsync",
"pr": 467
}
],
"timestamp": 1652400434
},
{
"version": "16.58.0",
"changes": [
{
"note": "Update Saddle pools on Mainnet",
"pr": 450
}
]
},
{
"version": "16.57.3",
"changes": [
{
"note": "Fix a runtime error related to BalancerV2SwapInfoCache",
"pr": 472
}
],
"timestamp": 1652146864
},
{
"version": "16.57.2",
"changes": [
{
"note": "Fix missing AMM quotes on indicative Quote Reports",
"pr": 466
}
],
"timestamp": 1651526551
},
{
"version": "16.57.1",
"changes": [
{
"note": "Added QUICK/ANY pair on Polygon",
"pr": 464
},
{
"note": "Added cvxFXS/FXS curve pool on mainnet",
"pr": 465
}
]
},
{
"version": "16.57.0",
"changes": [
{
"note": "Add BalancerV2 batch swap support",
"pr": 462
}
],
"timestamp": 1650611093
},
{
"version": "16.56.0",
"changes": [
{
"note": "Add estimatedGas to ExtendedQuoteReport",
"pr": 463
}
],
"timestamp": 1650575781
},
{
"version": "16.55.0",
"changes": [
{
"note": "Fix fillRfqOrder VIP being used for swaps that need transformERC20",
"pr": 461
}
],
"timestamp": 1649347667
},
{
"version": "16.54.0",
"changes": [
{
"note": "Add true VIP support for eligible RFQt swaps",
"pr": 458
}
],
"timestamp": 1649215576
},
{
"version": "16.53.0",
"changes": [
{
"note": "Adds support for STG/USDC pool on Curve Mainnet",
"pr": 451
},
{
"note": "Use neon-router in asset-swapper tests",
"pr": 453
},
{
"note": "Add sampler blocknumber to quote report data",
"pr": 448
}
],
"timestamp": 1648739346
},
{
"version": "16.52.0",
"changes": [
{
"note": "Adds support for mobius money on celo",
"pr": 423
}
]
},
{
"version": "16.51.0",
"changes": [

View File

@@ -5,6 +5,122 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v16.66.2 - _August 9, 2022_
* Upgrade dependency (#543)
## v16.66.1 - _August 8, 2022_
* Upgrade dependency (#538)
## v16.66.0 - _August 6, 2022_
* Add WOOFi support (#513)
## v16.65.0 - _August 1, 2022_
* Use 0x gas api instead of eth gas station api (#532)
## v16.64.0 - _July 27, 2022_
* Refactor `TokenAdjacency` and `TokenAdjacencyBuilder` (#517)
* Add Synthetix support` (#518)
* Replace Beethoven X subgraph URL (#519)
* Remove Mooniswap on Ethereum mainnet (#529)
## v16.63.1 - _July 12, 2022_
* Better error handling for balancer cache (#515)
## v16.63.0 - _June 29, 2022_
* Remove JS router (#480)
* Removed Median price in favour of best gas adjusted price (#480)
## v16.62.2 - _Invalid date_
* Offboard Smoothy and ComethSwap (#509)
## v16.62.1 - _June 15, 2022_
* Remove nUSD from intermediate liquidity to save on sampler gas (#505)
## v16.62.0 - _June 14, 2022_
* Add MDEX on BSC (#496)
* Add KnightSwap on BSC (#498)
* Add Velodrome support on Optimism (#494)
* Do not send empty entries on Quote Report (#501)
* KnightSwap/Mdex cosmetic change (#502)
* Offboard JetSwap, CafeSwap, JulSwap, and PolyDex (#503)
## v16.61.0 - _June 3, 2022_
* Add stETH wrap/unwrap support (#476)
* Offboard/clean up Oasis, CoFix, and legacy Kyber (#482)
* Add MeshSwap on Polygon (#491)
## v16.60.1 - _May 19, 2022_
* Alias Balancer sor to the old version (#481)
## v16.60.0 - _May 19, 2022_
* Add BiSwap on BSC (#467)
* Add GMX and Platypus on Avalanche and Enable KyberDMM on bsc (#478)
* Add Yoshi Exchange support in Fantom (#473)
* Fix KyberDMM gas underestimation (#479)
## v16.59.0 - _May 13, 2022_
* Remove SnowSwap on mainnet (#468)
* Offboard Swerve Finance and LinkSwap (#469)
* Offboard Eth2Dai (#470)
* Add an optional IRfqClient for SwapQuoter#getSwapQuoteAsync (#467)
## v16.58.0 - _Invalid date_
* Update Saddle pools on Mainnet (#450)
## v16.57.3 - _May 10, 2022_
* Fix a runtime error related to BalancerV2SwapInfoCache (#472)
## v16.57.2 - _May 2, 2022_
* Fix missing AMM quotes on indicative Quote Reports (#466)
## v16.57.1 - _Invalid date_
* Added QUICK/ANY pair on Polygon (#464)
* Added cvxFXS/FXS curve pool on mainnet (#465)
## v16.57.0 - _April 22, 2022_
* Add BalancerV2 batch swap support (#462)
## v16.56.0 - _April 21, 2022_
* Add estimatedGas to ExtendedQuoteReport (#463)
## v16.55.0 - _April 7, 2022_
* Fix fillRfqOrder VIP being used for swaps that need transformERC20 (#461)
## v16.54.0 - _April 6, 2022_
* Add true VIP support for eligible RFQt swaps (#458)
## v16.53.0 - _March 31, 2022_
* Adds support for STG/USDC pool on Curve Mainnet (#451)
* Use neon-router in asset-swapper tests (#453)
* Add sampler blocknumber to quote report data (#448)
## v16.52.0 - _Invalid date_
* Adds support for mobius money on celo (#423)
## v16.51.0 - _March 10, 2022_
* Added `Curve` `YFI-ETH` pool (#444)

View File

@@ -6,7 +6,7 @@
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": { "enabled": true, "runs": 200, "details": { "yul": true, "deduplicate": true } },
"optimizer": { "enabled": true, "runs": 200, "details": { "yul": false, "deduplicate": true } },
"outputSelection": {
"*": {
"*": [

View File

@@ -0,0 +1,105 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2021 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./interfaces/IBalancerV2Vault.sol";
import "./BalancerV2Common.sol";
contract BalancerV2BatchSampler is BalancerV2Common {
// Replaces amount for first step with each takerTokenAmount and calls queryBatchSwap using supplied steps
/// @dev Sample sell quotes from Balancer V2 supporting multihops.
/// @param swapSteps Array of swap steps (can be >= 1).
/// @param swapAssets Array of token address for swaps.
/// @param takerTokenAmounts Taker token sell amount for each sample.
function sampleMultihopSellsFromBalancerV2(
IBalancerV2Vault vault,
IBalancerV2Vault.BatchSwapStep[] memory swapSteps,
address[] memory swapAssets,
uint256[] memory takerTokenAmounts
)
public
returns (uint256[] memory makerTokenAmounts)
{
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
IBalancerV2Vault.FundManagement memory swapFunds =
_createSwapFunds();
for (uint256 i = 0; i < numSamples; i++) {
swapSteps[0].amount = takerTokenAmounts[i];
try
// For sells we specify the takerToken which is what the vault will receive from the trade
vault.queryBatchSwap(IBalancerV2Vault.SwapKind.GIVEN_IN, swapSteps, swapAssets, swapFunds)
// amounts represent pool balance deltas from the swap (incoming balance, outgoing balance)
returns (int256[] memory amounts) {
// Outgoing balance is negative so we need to flip the sign
// Note - queryBatchSwap will return a delta for each token in the assets array and last asset should be tokenOut
int256 amountOutFromPool = amounts[amounts.length - 1] * -1;
if (amountOutFromPool <= 0) {
break;
}
makerTokenAmounts[i] = uint256(amountOutFromPool);
} catch {
// Swallow failures, leaving all results as zero.
break;
}
}
}
// Replaces amount for first step with each makerTokenAmount and calls queryBatchSwap using supplied steps
/// @dev Sample buy quotes from Balancer V2 supporting multihops.
/// @param swapSteps Array of swap steps (can be >= 1).
/// @param swapAssets Array of token address for swaps.
/// @param makerTokenAmounts Maker token buy amount for each sample.
function sampleMultihopBuysFromBalancerV2(
IBalancerV2Vault vault,
IBalancerV2Vault.BatchSwapStep[] memory swapSteps,
address[] memory swapAssets,
uint256[] memory makerTokenAmounts
)
public
returns (uint256[] memory takerTokenAmounts)
{
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = new uint256[](numSamples);
IBalancerV2Vault.FundManagement memory swapFunds =
_createSwapFunds();
for (uint256 i = 0; i < numSamples; i++) {
swapSteps[0].amount = makerTokenAmounts[i];
try
// Uses GIVEN_OUT type for Buy
vault.queryBatchSwap(IBalancerV2Vault.SwapKind.GIVEN_OUT, swapSteps, swapAssets, swapFunds)
// amounts represent pool balance deltas from the swap (incoming balance, outgoing balance)
returns (int256[] memory amounts) {
int256 amountIntoPool = amounts[0];
if (amountIntoPool <= 0) {
break;
}
takerTokenAmounts[i] = uint256(amountIntoPool);
} catch {
// Swallow failures, leaving all results as zero.
break;
}
}
}
}

View File

@@ -18,28 +18,24 @@
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./interfaces/IBalancerV2Vault.sol";
interface ISmoothy {
contract BalancerV2Common {
function getBalance (
uint256 tid
)
external
function _createSwapFunds()
internal
view
returns (uint256 balance);
function _yBalances (
uint256 tid
)
external
view
returns (uint256 balance);
function getTokenStats (
uint256 tid
)
external
view
returns (uint256 softWeight, uint256 hardWeight, uint256 balance, uint256 decimals);
returns (IBalancerV2Vault.FundManagement memory)
{
return
IBalancerV2Vault.FundManagement({
sender: address(this),
fromInternalBalance: false,
recipient: payable(address(this)),
toInternalBalance: false
});
}
}

View File

@@ -21,44 +21,11 @@ pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./SamplerUtils.sol";
import "./interfaces/IBalancerV2Vault.sol";
import "./BalancerV2Common.sol";
/// @dev Minimal Balancer V2 Vault interface
/// for documentation refer to https://github.com/balancer-labs/balancer-core-v2/blob/master/contracts/vault/interfaces/IVault.sol
interface IBalancerV2Vault {
enum SwapKind { GIVEN_IN, GIVEN_OUT }
struct BatchSwapStep {
bytes32 poolId;
uint256 assetInIndex;
uint256 assetOutIndex;
uint256 amount;
bytes userData;
}
struct FundManagement {
address sender;
bool fromInternalBalance;
address payable recipient;
bool toInternalBalance;
}
function queryBatchSwap(
SwapKind kind,
BatchSwapStep[] calldata swaps,
IAsset[] calldata assets,
FundManagement calldata funds
) external returns (int256[] memory assetDeltas);
}
interface IAsset {
// solhint-disable-previous-line no-empty-blocks
}
contract BalancerV2Sampler is SamplerUtils {
struct BalancerV2PoolInfo {
bytes32 poolId;
address vault;
}
contract BalancerV2Sampler is SamplerUtils, BalancerV2Common {
/// @dev Sample sell quotes from Balancer V2.
/// @param poolInfo Struct with pool related data
@@ -68,7 +35,7 @@ contract BalancerV2Sampler is SamplerUtils {
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromBalancerV2(
BalancerV2PoolInfo memory poolInfo,
IBalancerV2Vault.BalancerV2PoolInfo memory poolInfo,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
@@ -78,9 +45,9 @@ contract BalancerV2Sampler is SamplerUtils {
{
_assertValidPair(makerToken, takerToken);
IBalancerV2Vault vault = IBalancerV2Vault(poolInfo.vault);
IAsset[] memory swapAssets = new IAsset[](2);
swapAssets[0] = IAsset(takerToken);
swapAssets[1] = IAsset(makerToken);
address[] memory swapAssets = new address[](2);
swapAssets[0] = takerToken;
swapAssets[1] = makerToken;
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
@@ -97,7 +64,7 @@ contract BalancerV2Sampler is SamplerUtils {
// amounts represent pool balance deltas from the swap (incoming balance, outgoing balance)
returns (int256[] memory amounts) {
// Outgoing balance is negative so we need to flip the sign
int256 amountOutFromPool = amounts[1] * -1;
int256 amountOutFromPool = amounts[amounts.length - 1] * -1;
if (amountOutFromPool <= 0) {
break;
}
@@ -117,7 +84,7 @@ contract BalancerV2Sampler is SamplerUtils {
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromBalancerV2(
BalancerV2PoolInfo memory poolInfo,
IBalancerV2Vault.BalancerV2PoolInfo memory poolInfo,
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts
@@ -127,9 +94,9 @@ contract BalancerV2Sampler is SamplerUtils {
{
_assertValidPair(makerToken, takerToken);
IBalancerV2Vault vault = IBalancerV2Vault(poolInfo.vault);
IAsset[] memory swapAssets = new IAsset[](2);
swapAssets[0] = IAsset(takerToken);
swapAssets[1] = IAsset(makerToken);
address[] memory swapAssets = new address[](2);
swapAssets[0] = takerToken;
swapAssets[1] = makerToken;
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = new uint256[](numSamples);
@@ -157,7 +124,7 @@ contract BalancerV2Sampler is SamplerUtils {
}
function _createSwapSteps(
BalancerV2PoolInfo memory poolInfo,
IBalancerV2Vault.BalancerV2PoolInfo memory poolInfo,
uint256 amount
) private pure returns (IBalancerV2Vault.BatchSwapStep[] memory) {
IBalancerV2Vault.BatchSwapStep[] memory swapSteps =
@@ -172,18 +139,4 @@ contract BalancerV2Sampler is SamplerUtils {
return swapSteps;
}
function _createSwapFunds()
private
view
returns (IBalancerV2Vault.FundManagement memory)
{
return
IBalancerV2Vault.FundManagement({
sender: address(this),
fromInternalBalance: false,
recipient: payable(address(this)),
toInternalBalance: false
});
}
}

View File

@@ -22,9 +22,8 @@ pragma experimental ABIEncoderV2;
import "./interfaces/IBancor.sol";
contract CompilerHack {}
contract BancorSampler is CompilerHack {
contract BancorSampler {
/// @dev Base gas limit for Bancor calls.
uint256 constant private BANCOR_CALL_GAS = 300e3; // 300k

View File

@@ -0,0 +1,120 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./interfaces/IBancorV3.sol";
contract BancorV3Sampler
{
/// @dev Gas limit for BancorV3 calls.
uint256 constant private BancorV3_CALL_GAS = 150e3; // 150k
address constant public ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev Sample sell quotes from BancorV3.
/// @param weth The WETH contract address
/// @param router Router to look up tokens and amounts
/// @param path Token route. Should be takerToken -> makerToken
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromBancorV3(
address weth,
address router,
address[] memory path,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
if(path[0] == weth){
path[0] = ETH;
}
if(path[1] == weth){
path[1] = ETH;
}
for (uint256 i = 0; i < numSamples; i++) {
try
IBancorV3(router).tradeOutputBySourceAmount(path[0], path[1], takerTokenAmounts[i])
returns (uint256 amount)
{
makerTokenAmounts[i] = amount;
// Break early if there are 0 amounts
if (makerTokenAmounts[i] == 0) {
break;
}
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
break;
}
}
}
/// @dev Sample buy quotes from BancorV3.
/// @param weth The WETH contract address
/// @param router Router to look up tokens and amounts
/// @param path Token route. Should be takerToken -> makerToken.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromBancorV3(
address weth,
address router,
address[] memory path,
uint256[] memory makerTokenAmounts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = new uint256[](numSamples);
if(path[0] == weth){
path[0] = ETH;
}
if(path[1] == weth){
path[1] = ETH;
}
for (uint256 i = 0; i < numSamples; i++) {
try
IBancorV3(router).tradeInputByTargetAmount(path[0], path[1], makerTokenAmounts[i])
returns (uint256 amount)
{
takerTokenAmounts[i] = amount;
// Break early if there are 0 amounts
if (takerTokenAmounts[i] == 0) {
break;
}
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
break;
}
}
}
}

View File

@@ -22,52 +22,60 @@ pragma experimental ABIEncoderV2;
import "./BalancerSampler.sol";
import "./BalancerV2Sampler.sol";
import "./BalancerV2BatchSampler.sol";
import "./BancorSampler.sol";
import "./BancorV3Sampler.sol";
import "./CompoundSampler.sol";
import "./CurveSampler.sol";
import "./DODOSampler.sol";
import "./DODOV2Sampler.sol";
import "./KyberSampler.sol";
import "./GMXSampler.sol";
import "./KyberDmmSampler.sol";
import "./LidoSampler.sol";
import "./LiquidityProviderSampler.sol";
import "./MakerPSMSampler.sol";
import "./MultiBridgeSampler.sol";
import "./MStableSampler.sol";
import "./MooniswapSampler.sol";
import "./NativeOrderSampler.sol";
import "./PlatypusSampler.sol";
import "./ShellSampler.sol";
import "./SmoothySampler.sol";
import "./SynthetixSampler.sol";
import "./TwoHopSampler.sol";
import "./UniswapSampler.sol";
import "./UniswapV2Sampler.sol";
import "./UniswapV3Sampler.sol";
import "./VelodromeSampler.sol";
import "./WooPPSampler.sol";
import "./UtilitySampler.sol";
contract ERC20BridgeSampler is
BalancerSampler,
BalancerV2Sampler,
BalancerV2BatchSampler,
BancorSampler,
BancorV3Sampler,
CompoundSampler,
CurveSampler,
DODOSampler,
DODOV2Sampler,
KyberSampler,
GMXSampler,
KyberDmmSampler,
LidoSampler,
LiquidityProviderSampler,
MakerPSMSampler,
MStableSampler,
MooniswapSampler,
MultiBridgeSampler,
NativeOrderSampler,
PlatypusSampler,
ShellSampler,
SmoothySampler,
SynthetixSampler,
TwoHopSampler,
UniswapSampler,
UniswapV2Sampler,
UniswapV3Sampler,
VelodromeSampler,
WooPPSampler,
UtilitySampler
{
@@ -92,4 +100,6 @@ contract ERC20BridgeSampler is
(callResults[i].success, callResults[i].data) = address(this).call(callDatas[i]);
}
}
receive() external payable {}
}

View File

@@ -0,0 +1,96 @@
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./interfaces/IGMX.sol";
import "./ApproximateBuys.sol";
import "./SamplerUtils.sol";
contract GMXSampler is
SamplerUtils,
ApproximateBuys
{
struct GMXInfo {
address reader;
address vault;
address[] path;
}
function sampleSellsFromGMX(
address reader,
address vault,
address[] memory path,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
try
IGMX(reader).getAmountOut(IVault(vault), path[0], path[1], takerTokenAmounts[i])
returns (uint256 amountAfterFees, uint256 feeAmount)
{
makerTokenAmounts[i] = amountAfterFees;
// Break early if there are 0 amounts
if (makerTokenAmounts[i] == 0) {
break;
}
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
break;
}
}
}
function sampleBuysFromGMX(
address reader,
address vault,
address[] memory path,
uint256[] memory makerTokenAmounts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
address[] memory invertBuyPath = new address[](2);
invertBuyPath[0] = path[1];
invertBuyPath[1] = path[0];
return _sampleApproximateBuys(
ApproximateBuyQuoteOpts({
makerTokenData: abi.encode(reader, vault, invertBuyPath),
takerTokenData: abi.encode(reader, vault, path),
getSellQuoteCallback: _sampleSellForApproximateBuyFromGMX
}),
makerTokenAmounts
);
}
function _sampleSellForApproximateBuyFromGMX(
bytes memory takerTokenData,
bytes memory makerTokenData,
uint256 sellAmount
)
private
view
returns (uint256 buyAmount)
{
(address _reader, address _vault, address[] memory _path ) = abi.decode(takerTokenData, (address, address, address[]));
(bool success, bytes memory resultData) = address(this).staticcall(abi.encodeWithSelector(
this.sampleSellsFromGMX.selector,
_reader,
_vault,
_path,
_toSingleValueArray(sellAmount)
));
if(!success) {
return 0;
}
// solhint-disable-next-line indent
return abi.decode(resultData, (uint256[]))[0];
}
}

View File

@@ -1,301 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./interfaces/IKyberNetwork.sol";
import "./ApproximateBuys.sol";
import "./SamplerUtils.sol";
contract KyberSampler is
SamplerUtils,
ApproximateBuys
{
/// @dev Gas limit for Kyber calls.
uint256 constant private KYBER_CALL_GAS = 500e3; // 500k
/// @dev Kyber ETH pseudo-address.
address constant internal KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
struct KyberSamplerOpts {
uint256 reserveOffset;
address hintHandler;
address networkProxy;
address weth;
bytes hint;
}
/// @dev Sample sell quotes from Kyber.
/// @param opts KyberSamplerOpts The nth reserve
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return reserveId The id of the reserve found at reserveOffset
/// @return hint The hint for the selected reserve
/// @return makerTokenAmounts Maker amounts bought at each taker token amount.
function sampleSellsFromKyberNetwork(
KyberSamplerOpts memory opts,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
)
public
view
returns (bytes32 reserveId, bytes memory hint, uint256[] memory makerTokenAmounts)
{
_assertValidPair(makerToken, takerToken);
reserveId = _getNextReserveId(opts, takerToken, makerToken);
if (reserveId == 0x0) {
return (reserveId, hint, makerTokenAmounts);
}
opts.hint = this.encodeKyberHint(opts, reserveId, takerToken, makerToken);
hint = opts.hint;
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
uint256 value = this.sampleSellFromKyberNetwork(
opts,
takerToken,
makerToken,
takerTokenAmounts[i]
);
makerTokenAmounts[i] = value;
// Break early if there are 0 amounts
if (makerTokenAmounts[i] == 0) {
break;
}
}
}
/// @dev Sample buy quotes from Kyber.
/// @param opts KyberSamplerOpts The nth reserve
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return reserveId The id of the reserve found at reserveOffset
/// @return hint The hint for the selected reserve
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
function sampleBuysFromKyberNetwork(
KyberSamplerOpts memory opts,
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts
)
public
view
returns (bytes32 reserveId, bytes memory hint, uint256[] memory takerTokenAmounts)
{
_assertValidPair(makerToken, takerToken);
reserveId = _getNextReserveId(opts, takerToken, makerToken);
if (reserveId == 0x0) {
return (reserveId, hint, takerTokenAmounts);
}
opts.hint = this.encodeKyberHint(opts, reserveId, takerToken, makerToken);
hint = opts.hint;
takerTokenAmounts = _sampleApproximateBuys(
ApproximateBuyQuoteOpts({
makerTokenData: abi.encode(makerToken, opts),
takerTokenData: abi.encode(takerToken, opts),
getSellQuoteCallback: _sampleSellForApproximateBuyFromKyber
}),
makerTokenAmounts
);
return (reserveId, hint, takerTokenAmounts);
}
function encodeKyberHint(
KyberSamplerOpts memory opts,
bytes32 reserveId,
address takerToken,
address makerToken
)
public
view
returns (bytes memory hint)
{
// Build a hint selecting the single reserve
IKyberHintHandler kyberHint = IKyberHintHandler(opts.hintHandler);
// All other reserves should be ignored with this hint
bytes32[] memory selectedReserves = new bytes32[](1);
selectedReserves[0] = reserveId;
uint256[] memory emptySplits = new uint256[](0);
if (takerToken == opts.weth) {
// ETH to Token
try
kyberHint.buildEthToTokenHint
{gas: KYBER_CALL_GAS}
(
makerToken,
IKyberHintHandler.TradeType.MaskIn,
selectedReserves,
emptySplits
)
returns (bytes memory result)
{
return result;
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
}
} else if (makerToken == opts.weth) {
// Token to ETH
try
kyberHint.buildTokenToEthHint
{gas: KYBER_CALL_GAS}
(
takerToken,
IKyberHintHandler.TradeType.MaskIn,
selectedReserves,
emptySplits
)
returns (bytes memory result)
{
return result;
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
}
} else {
// Token to Token
// We use the same reserve both ways
try
kyberHint.buildTokenToTokenHint
{gas: KYBER_CALL_GAS}
(
takerToken,
IKyberHintHandler.TradeType.MaskIn,
selectedReserves,
emptySplits,
makerToken,
IKyberHintHandler.TradeType.MaskIn,
selectedReserves,
emptySplits
)
returns (bytes memory result)
{
return result;
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
}
}
}
function _sampleSellForApproximateBuyFromKyber(
bytes memory takerTokenData,
bytes memory makerTokenData,
uint256 sellAmount
)
private
view
returns (uint256)
{
(address makerToken, KyberSamplerOpts memory opts) =
abi.decode(makerTokenData, (address, KyberSamplerOpts));
(address takerToken, ) =
abi.decode(takerTokenData, (address, KyberSamplerOpts));
try
this.sampleSellFromKyberNetwork
(opts, takerToken, makerToken, sellAmount)
returns (uint256 amount)
{
return amount;
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
return 0;
}
}
function sampleSellFromKyberNetwork(
KyberSamplerOpts memory opts,
address takerToken,
address makerToken,
uint256 takerTokenAmount
)
public
view
returns (uint256 makerTokenAmount)
{
// If there is no hint do not continue
if (opts.hint.length == 0) {
return 0;
}
try
IKyberNetworkProxy(opts.networkProxy).getExpectedRateAfterFee
{gas: KYBER_CALL_GAS}
(
takerToken == opts.weth ? KYBER_ETH_ADDRESS : takerToken,
makerToken == opts.weth ? KYBER_ETH_ADDRESS : makerToken,
takerTokenAmount,
0, // fee
opts.hint
)
returns (uint256 rate)
{
uint256 makerTokenDecimals = _getTokenDecimals(makerToken);
uint256 takerTokenDecimals = _getTokenDecimals(takerToken);
makerTokenAmount =
rate *
takerTokenAmount *
10 ** makerTokenDecimals /
10 ** takerTokenDecimals /
10 ** 18;
return makerTokenAmount;
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
return 0;
}
}
function _getNextReserveId(
KyberSamplerOpts memory opts,
address takerToken,
address makerToken
)
internal
view
returns (bytes32 reserveId)
{
// Fetch the registered reserves for this pair
IKyberHintHandler kyberHint = IKyberHintHandler(opts.hintHandler);
(bytes32[] memory reserveIds, ,) = kyberHint.getTradingReserves(
takerToken == opts.weth ? KYBER_ETH_ADDRESS : takerToken,
makerToken == opts.weth ? KYBER_ETH_ADDRESS : makerToken,
true,
new bytes(0) // empty hint
);
if (opts.reserveOffset >= reserveIds.length) {
return 0x0;
}
reserveId = reserveIds[opts.reserveOffset];
// Ignore Kyber Bridged Reserves (0xbb)
if (uint256(reserveId >> 248) == 0xbb) {
return 0x0;
}
return reserveId;
}
}

View File

@@ -22,10 +22,18 @@ pragma experimental ABIEncoderV2;
import "./SamplerUtils.sol";
interface IWstETH {
function getWstETHByStETH(uint256 _stETHAmount) external view returns (uint256);
function getStETHByWstETH(uint256 _wstETHAmount) external view returns (uint256);
}
contract LidoSampler is SamplerUtils {
struct LidoInfo {
address stEthToken;
address wethToken;
address wstEthToken;
}
/// @dev Sample sell quotes from Lido
@@ -42,20 +50,17 @@ contract LidoSampler is SamplerUtils {
uint256[] memory takerTokenAmounts
)
public
pure
view
returns (uint256[] memory)
{
_assertValidPair(makerToken, takerToken);
if (takerToken != lidoInfo.wethToken || makerToken != address(lidoInfo.stEthToken)) {
// Return 0 values if not selling WETH for stETH
uint256 numSamples = takerTokenAmounts.length;
uint256[] memory makerTokenAmounts = new uint256[](numSamples);
return makerTokenAmounts;
if (takerToken == lidoInfo.wethToken && makerToken == address(lidoInfo.stEthToken)) {
// Minting stETH is always 1:1 therefore we can just return the same amounts back.
return takerTokenAmounts;
}
// Minting stETH is always 1:1 therefore we can just return the same amounts back
return takerTokenAmounts;
return _sampleSellsForWrapped(lidoInfo, takerToken, makerToken, takerTokenAmounts);
}
/// @dev Sample buy quotes from Lido.
@@ -72,20 +77,43 @@ contract LidoSampler is SamplerUtils {
uint256[] memory makerTokenAmounts
)
public
pure
view
returns (uint256[] memory)
{
_assertValidPair(makerToken, takerToken);
if (takerToken != lidoInfo.wethToken || makerToken != address(lidoInfo.stEthToken)) {
// Return 0 values if not buying stETH for WETH
uint256 numSamples = makerTokenAmounts.length;
uint256[] memory takerTokenAmounts = new uint256[](numSamples);
return takerTokenAmounts;
if (takerToken == lidoInfo.wethToken && makerToken == address(lidoInfo.stEthToken)) {
// Minting stETH is always 1:1 therefore we can just return the same amounts back.
return makerTokenAmounts;
}
// Minting stETH is always 1:1 therefore we can just return the same amounts back
return makerTokenAmounts;
// Swap out `makerToken` and `takerToken` and re-use `_sampleSellsForWrapped`.
return _sampleSellsForWrapped(lidoInfo, makerToken, takerToken, makerTokenAmounts);
}
function _sampleSellsForWrapped(
LidoInfo memory lidoInfo,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
) private view returns (uint256[] memory) {
IWstETH wstETH = IWstETH(lidoInfo.wstEthToken);
uint256 numSamples = takerTokenAmounts.length;
uint256[] memory makerTokenAmounts = new uint256[](numSamples);
if (takerToken == lidoInfo.stEthToken && makerToken == lidoInfo.wstEthToken) {
for (uint256 i = 0; i < numSamples; i++) {
makerTokenAmounts[i] = wstETH.getWstETHByStETH(takerTokenAmounts[i]);
}
return makerTokenAmounts;
}
if (takerToken == lidoInfo.wstEthToken && makerToken == lidoInfo.stEthToken) {
for (uint256 i = 0; i < numSamples; i++) {
makerTokenAmounts[i] = wstETH.getStETHByWstETH(takerTokenAmounts[i]);
}
return makerTokenAmounts;
}
// Returns 0 values.
return makerTokenAmounts;
}
}

View File

@@ -1,82 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./interfaces/IMultiBridge.sol";
contract MultiBridgeSampler {
/// @dev Default gas limit for multibridge calls.
uint256 constant private DEFAULT_CALL_GAS = 400e3; // 400k
/// @dev Sample sell quotes from MultiBridge.
/// @param multibridge Address of the MultiBridge contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param intermediateToken The address of the intermediate token to
/// use in an indirect route.
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromMultiBridge(
address multibridge,
address takerToken,
address intermediateToken,
address makerToken,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
// Initialize array of maker token amounts.
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
// If no address provided, return all zeros.
if (multibridge == address(0)) {
return makerTokenAmounts;
}
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
multibridge.staticcall.gas(DEFAULT_CALL_GAS)(
abi.encodeWithSelector(
IMultiBridge(0).getSellQuote.selector,
takerToken,
intermediateToken,
makerToken,
takerTokenAmounts[i]
));
uint256 buyAmount = 0;
if (didSucceed) {
buyAmount = abi.decode(resultData, (uint256));
}
// Exit early if the amount is too high for the source to serve
if (buyAmount == 0) {
break;
}
makerTokenAmounts[i] = buyAmount;
}
}
}

View File

@@ -0,0 +1,89 @@
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./interfaces/IPlatypus.sol";
import "./ApproximateBuys.sol";
import "./SamplerUtils.sol";
contract PlatypusSampler is
SamplerUtils,
ApproximateBuys
{
function sampleSellsFromPlatypus(
address pool,
address[] memory path,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
try
IPlatypus(pool).quotePotentialSwap(path[0], path[1], takerTokenAmounts[i])
returns (uint256 amountAfterFees, uint256 feeAmount)
{
makerTokenAmounts[i] = amountAfterFees;
// Break early if there are 0 amounts
if (makerTokenAmounts[i] == 0) {
break;
}
} catch (bytes memory result) {
// Swallow failures, leaving all results as zero.
break;
}
}
}
function sampleBuysFromPlatypus(
address pool,
address[] memory path,
uint256[] memory makerTokenAmounts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
address[] memory invertBuyPath = new address[](2);
invertBuyPath[0] = path[1];
invertBuyPath[1] = path[0];
return _sampleApproximateBuys(
ApproximateBuyQuoteOpts({
makerTokenData: abi.encode(pool, invertBuyPath),
takerTokenData: abi.encode(pool, path),
getSellQuoteCallback: _sampleSellForApproximateBuyFromPlatypus
}),
makerTokenAmounts
);
}
function _sampleSellForApproximateBuyFromPlatypus(
bytes memory makerTokenData,
bytes memory takerTokenData,
uint256 sellAmount
)
private
view
returns (uint256 buyAmount)
{
(address _pool, address[] memory _path ) = abi.decode(makerTokenData, (address, address[]));
(bool success, bytes memory resultData) = address(this).staticcall(abi.encodeWithSelector(
this.sampleSellsFromPlatypus.selector,
_pool,
_path,
_toSingleValueArray(sellAmount)
));
if(!success) {
return 0;
}
// solhint-disable-next-line indent
return abi.decode(resultData, (uint256[]))[0];
}
}

View File

@@ -1,156 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
// import "./interfaces/ISmoothy.sol";
import "./ApproximateBuys.sol";
import "./SamplerUtils.sol";
import "./interfaces/ISmoothy.sol";
contract SmoothySampler is
SamplerUtils,
ApproximateBuys
{
/// @dev Information for sampling from smoothy sources.
struct SmoothyInfo {
address poolAddress;
bytes4 sellQuoteFunctionSelector;
bytes4 buyQuoteFunctionSelector;
}
/// @dev Base gas limit for Smoothy calls.
uint256 constant private SMOOTHY_CALL_GAS = 600e3;
/// @dev Sample sell quotes from Smoothy.
/// @param smoothyInfo Smoothy information specific to this token pair.
/// @param fromTokenIdx Index of the taker token (what to sell).
/// @param toTokenIdx Index of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromSmoothy(
SmoothyInfo memory smoothyInfo,
int128 fromTokenIdx,
int128 toTokenIdx,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
// Basically a Curve fork
// Smoothy only keep a percentage of its tokens available in reserve
uint256 poolReserveMakerAmount = ISmoothy(smoothyInfo.poolAddress).getBalance(uint256(toTokenIdx)) -
ISmoothy(smoothyInfo.poolAddress)._yBalances(uint256(toTokenIdx));
(, , , uint256 decimals) = ISmoothy(smoothyInfo.poolAddress).getTokenStats(uint256(toTokenIdx));
poolReserveMakerAmount = poolReserveMakerAmount/(10**(18-decimals));
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
smoothyInfo.poolAddress.staticcall.gas(SMOOTHY_CALL_GAS)(
abi.encodeWithSelector(
smoothyInfo.sellQuoteFunctionSelector,
fromTokenIdx,
toTokenIdx,
takerTokenAmounts[i]
));
uint256 buyAmount = 0;
if (didSucceed) {
buyAmount = abi.decode(resultData, (uint256));
}
// Make sure the quoted buyAmount is available in the pool reserve
if (buyAmount >= poolReserveMakerAmount) {
// Assign pool reserve amount for all higher samples to break early
for (uint256 j = i; j < numSamples; j++) {
makerTokenAmounts[j] = poolReserveMakerAmount;
}
break;
} else {
makerTokenAmounts[i] = buyAmount;
}
// Break early if there are 0 amounts
if (makerTokenAmounts[i] == 0) {
break;
}
}
}
/// @dev Sample buy quotes from Smoothy.
/// @param smoothyInfo Smoothy information specific to this token pair.
/// @param fromTokenIdx Index of the taker token (what to sell).
/// @param toTokenIdx Index of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromSmoothy(
SmoothyInfo memory smoothyInfo,
int128 fromTokenIdx,
int128 toTokenIdx,
uint256[] memory makerTokenAmounts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
// Buys not supported so approximate it.
return _sampleApproximateBuys(
ApproximateBuyQuoteOpts({
makerTokenData: abi.encode(toTokenIdx, smoothyInfo),
takerTokenData: abi.encode(fromTokenIdx, smoothyInfo),
getSellQuoteCallback: _sampleSellForApproximateBuyFromSmoothy
}),
makerTokenAmounts
);
}
function _sampleSellForApproximateBuyFromSmoothy(
bytes memory takerTokenData,
bytes memory makerTokenData,
uint256 sellAmount
)
private
view
returns (uint256 buyAmount)
{
(int128 takerTokenIdx, SmoothyInfo memory smoothyInfo) =
abi.decode(takerTokenData, (int128, SmoothyInfo));
(int128 makerTokenIdx) =
abi.decode(makerTokenData, (int128));
(bool success, bytes memory resultData) =
address(this).staticcall(abi.encodeWithSelector(
this.sampleSellsFromSmoothy.selector,
smoothyInfo,
takerTokenIdx,
makerTokenIdx,
_toSingleValueArray(sellAmount)
));
if (!success) {
return 0;
}
// solhint-disable-next-line indent
return abi.decode(resultData, (uint256[]))[0];
}
}

View File

@@ -0,0 +1,173 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
interface IReadProxyAddressResolver {
function target() external view returns (address);
}
interface IAddressResolver {
function getAddress(bytes32 name) external view returns (address);
}
interface IExchanger {
// Ethereum Mainnet
function getAmountsForAtomicExchange(
uint256 sourceAmount,
bytes32 sourceCurrencyKey,
bytes32 destinationCurrencyKey
)
external
view
returns (
uint256 amountReceived,
uint256 fee,
uint256 exchangeFeeRate
);
// Optimism
function getAmountsForExchange(
uint256 sourceAmount,
bytes32 sourceCurrencyKey,
bytes32 destinationCurrencyKey
)
external
view
returns (
uint256 amountReceived,
uint256 fee,
uint256 exchangeFeeRate
);
}
contract SynthetixSampler {
/// @dev Sample sell quotes from Synthetix Atomic Swap.
/// @param takerTokenSymbol Symbol (currency key) of the taker token (what to sell).
/// @param makerTokenSymbol Symbol (currency key) of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample (sorted in ascending order).
/// @return synthetix Synthetix address.
/// @return makerTokenAmounts Maker amounts bought at each taker token amount.
function sampleSellsFromSynthetix(
IReadProxyAddressResolver readProxy,
bytes32 takerTokenSymbol,
bytes32 makerTokenSymbol,
uint256[] memory takerTokenAmounts
) public view returns (address synthetix, uint256[] memory makerTokenAmounts) {
synthetix = getSynthetixAddress(readProxy);
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
if (numSamples == 0) {
return (synthetix, makerTokenAmounts);
}
makerTokenAmounts[0] = exchange(
readProxy,
takerTokenAmounts[0],
takerTokenSymbol,
makerTokenSymbol
);
// Synthetix atomic swap has a fixed rate. Calculate the rest based on the first value (and save gas).
for (uint256 i = 1; i < numSamples; i++) {
makerTokenAmounts[i] =
(makerTokenAmounts[0] * takerTokenAmounts[i]) /
takerTokenAmounts[0];
}
}
/// @dev Sample buy quotes from Synthetix Atomic Swap.
/// @param takerTokenSymbol Symbol (currency key) of the taker token (what to sell).
/// @param makerTokenSymbol Symbol (currency key) of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample (sorted in ascending order).
/// @return synthetix Synthetix address.
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
function sampleBuysFromSynthetix(
IReadProxyAddressResolver readProxy,
bytes32 takerTokenSymbol,
bytes32 makerTokenSymbol,
uint256[] memory makerTokenAmounts
) public view returns (address synthetix, uint256[] memory takerTokenAmounts) {
synthetix = getSynthetixAddress(readProxy);
// Since Synthetix atomic have a fixed rate, we can pick any reasonablely size takerTokenAmount (fixed to 1 ether here) and calculate the rest.
uint256 amountReceivedForEther = exchange(
readProxy,
1 ether,
takerTokenSymbol,
makerTokenSymbol
);
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
takerTokenAmounts[i] =
(1 ether * makerTokenAmounts[i]) /
amountReceivedForEther;
}
}
function exchange(
IReadProxyAddressResolver readProxy,
uint256 sourceAmount,
bytes32 sourceCurrencyKey,
bytes32 destinationCurrencyKey
) private view returns (uint256 amountReceived) {
IExchanger exchanger = getExchanger(readProxy);
uint256 chainId;
assembly {
chainId := chainid()
}
if (chainId == 1) {
(amountReceived, , ) = exchanger.getAmountsForAtomicExchange(
sourceAmount,
sourceCurrencyKey,
destinationCurrencyKey
);
} else {
(amountReceived, , ) = exchanger.getAmountsForExchange(
sourceAmount,
sourceCurrencyKey,
destinationCurrencyKey
);
}
}
function getSynthetixAddress(IReadProxyAddressResolver readProxy)
private
view
returns (address)
{
return IAddressResolver(readProxy.target()).getAddress("Synthetix");
}
function getExchanger(IReadProxyAddressResolver readProxy)
private
view
returns (IExchanger)
{
return
IExchanger(
IAddressResolver(readProxy.target()).getAddress("Exchanger")
);
}
}

View File

@@ -0,0 +1,134 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import './ApproximateBuys.sol';
import './SamplerUtils.sol';
struct VeloRoute {
address from;
address to;
bool stable;
}
interface IVelodromeRouter {
function getAmountOut(
uint256 amountIn,
address tokenIn,
address tokenOut
) external view returns (uint256 amount, bool stable);
function getAmountsOut(uint256 amountIn, VeloRoute[] calldata routes)
external
view
returns (uint256[] memory amounts);
}
contract VelodromeSampler is SamplerUtils, ApproximateBuys {
/// @dev Sample sell quotes from Velodrome
/// @param router Address of Velodrome router.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample (sorted in ascending order).
/// @return stable Whether the pool is a stable pool (vs volatile).
/// @return makerTokenAmounts Maker amounts bought at each taker token amount.
function sampleSellsFromVelodrome(
IVelodromeRouter router,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
) public view returns (bool stable, uint256[] memory makerTokenAmounts) {
_assertValidPair(makerToken, takerToken);
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
// Sampling should not mix stable and volatile pools.
// Find the most liquid pool based on max(takerTokenAmounts) and stick with it.
stable = _isMostLiquidPoolStablePool(router, takerToken, makerToken, takerTokenAmounts);
VeloRoute[] memory routes = new VeloRoute[](1);
routes[0] = VeloRoute({ from: takerToken, to: makerToken, stable: stable });
for (uint256 i = 0; i < numSamples; i++) {
makerTokenAmounts[i] = router.getAmountsOut(takerTokenAmounts[i], routes)[1];
// Break early if there are 0 amounts
if (makerTokenAmounts[i] == 0) {
break;
}
}
}
/// @dev Sample buy quotes from Velodrome.
/// @param router Address of Velodrome router.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return stable Whether the pool is a stable pool (vs volatile).
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
function sampleBuysFromVelodrome(
IVelodromeRouter router,
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts
) public view returns (bool stable, uint256[] memory takerTokenAmounts) {
_assertValidPair(makerToken, takerToken);
// Sampling should not mix stable and volatile pools.
// Find the most liquid pool based on the reverse swap (maker -> taker) and stick with it.
stable = _isMostLiquidPoolStablePool(router, makerToken, takerToken, makerTokenAmounts);
takerTokenAmounts = _sampleApproximateBuys(
ApproximateBuyQuoteOpts({
takerTokenData: abi.encode(router, VeloRoute({ from: takerToken, to: makerToken, stable: stable })),
makerTokenData: abi.encode(router, VeloRoute({ from: makerToken, to: takerToken, stable: stable })),
getSellQuoteCallback: _sampleSellForApproximateBuyFromVelodrome
}),
makerTokenAmounts
);
}
function _sampleSellForApproximateBuyFromVelodrome(
bytes memory takerTokenData,
bytes memory, /* makerTokenData */
uint256 sellAmount
) internal view returns (uint256) {
(IVelodromeRouter router, VeloRoute memory route) = abi.decode(takerTokenData, (IVelodromeRouter, VeloRoute));
VeloRoute[] memory routes = new VeloRoute[](1);
routes[0] = route;
return router.getAmountsOut(sellAmount, routes)[1];
}
/// @dev Returns whether the most liquid pool is a stable pool.
/// @param router Address of Velodrome router.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token buy amount for each sample (sorted in ascending order)
/// @return stable Whether the pool is a stable pool (vs volatile).
function _isMostLiquidPoolStablePool(
IVelodromeRouter router,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
) internal view returns (bool stable) {
uint256 numSamples = takerTokenAmounts.length;
(, stable) = router.getAmountOut(takerTokenAmounts[numSamples - 1], takerToken, makerToken);
}
}

View File

@@ -0,0 +1,121 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./SamplerUtils.sol";
import "./ApproximateBuys.sol";
interface IWooPP {
/// @dev get the quote token address (immutable)
/// @return address of quote token
function quoteToken() external view returns (address);
/// @dev Query the amount for selling the base token amount.
/// @param baseToken the base token to sell
/// @param baseAmount the amount to sell
/// @return quoteAmount the swapped quote amount
function querySellBase(address baseToken, uint256 baseAmount) external view returns (uint256 quoteAmount);
/// @dev Query the amount for selling the quote token.
/// @param baseToken the base token to receive (buy)
/// @param quoteAmount the amount to sell
/// @return baseAmount the swapped base token amount
function querySellQuote(address baseToken, uint256 quoteAmount) external view returns (uint256 baseAmount);
}
contract WooPPSampler is SamplerUtils, ApproximateBuys{
function query(
uint amountIn,
address tokenIn,
address tokenOut,
address pool
) internal view returns (uint256 amountOut) {
if (amountIn == 0) {
return 0;
}
address quoteToken = IWooPP(pool).quoteToken();
if (tokenIn == quoteToken) {
amountOut = IWooPP(pool).querySellQuote(tokenOut, amountIn);
} else if (tokenOut == quoteToken) {
amountOut = IWooPP(pool).querySellBase(tokenIn, amountIn);
} else {
uint quoteAmount = IWooPP(pool).querySellBase(tokenIn, amountIn);
amountOut = IWooPP(pool).querySellQuote(tokenOut, quoteAmount);
}
}
/// @dev Sample sell quotes from WooFI.
/// @param pool Address of the pool we are sampling from
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample (sorted in ascending order).
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromWooPP(
address pool,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
makerTokenAmounts[i] = query(takerTokenAmounts[i], takerToken, makerToken, pool);
if (makerTokenAmounts[i] == 0) {
break;
}
}
}
/// @dev Sample buy quotes from WooFI.
/// @param pool Address of the pool we are sampling from
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token sell amount for each sample (sorted in ascending order).
/// @return takerTokenAmounts Taker amounts bought at each taker token
/// amount.
function sampleBuysFromWooPP(
address pool,
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = _sampleApproximateBuys(
ApproximateBuyQuoteOpts({
takerTokenData: abi.encode(pool,takerToken, makerToken),
makerTokenData: abi.encode(pool, makerToken, takerToken),
getSellQuoteCallback: _sampleSellForApproximateBuyFromWoofi
}),
makerTokenAmounts
);
}
function _sampleSellForApproximateBuyFromWoofi(
bytes memory takerTokenData,
bytes memory makerTokenData,
uint256 sellAmount
) internal view returns (uint256) {
(address _pool, address _takerToken, address _makerToken) = abi.decode(takerTokenData, (address, address, address));
(bool success, bytes memory resultData) = address(this).staticcall(abi.encodeWithSelector(
this.sampleSellsFromWooPP.selector,
_pool,
_takerToken,
_makerToken,
_toSingleValueArray(sellAmount)
));
if(!success) {
return 0;
}
return abi.decode(resultData, (uint256[]))[0];
}
}

View File

@@ -0,0 +1,54 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
/// @dev Minimal Balancer V2 Vault interface
/// for documentation refer to https://github.com/balancer-labs/balancer-core-v2/blob/master/contracts/vault/interfaces/IVault.sol
interface IBalancerV2Vault {
enum SwapKind { GIVEN_IN, GIVEN_OUT }
struct BatchSwapStep {
bytes32 poolId;
uint256 assetInIndex;
uint256 assetOutIndex;
uint256 amount;
bytes userData;
}
struct FundManagement {
address sender;
bool fromInternalBalance;
address payable recipient;
bool toInternalBalance;
}
struct BalancerV2PoolInfo {
bytes32 poolId;
address vault;
}
function queryBatchSwap(
SwapKind kind,
BatchSwapStep[] calldata swaps,
address[] calldata assets,
FundManagement calldata funds
) external returns (int256[] memory assetDeltas);
}

View File

@@ -0,0 +1,43 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2022 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
interface IBancorV3 {
/**
* @dev returns the output amount when trading by providing the source amount
*/
function tradeOutputBySourceAmount(
address sourceToken,
address targetToken,
uint256 sourceAmount
) external view returns (uint256);
/**
* @dev returns the input amount when trading by providing the target amount
*/
function tradeInputByTargetAmount(
address sourceToken,
address targetToken,
uint256 targetAmount
) external view returns (uint256);
}

View File

@@ -0,0 +1,23 @@
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
interface IGMX {
function getMaxAmountIn(IVault _vault, address _tokenIn, address _tokenOut)
external
view
returns (uint256);
function getAmountOut(IVault _vault, address _tokenIn, address _tokenOut, uint256 _amountIn)
external
view
returns (uint256, uint256);
}
interface IVault {
function getFeeBasisPoints(address _token, uint256 _usdgDelta, uint256 _feeBasisPoints, uint256 _taxBasisPoints, bool _increment) external view returns (uint256);
function stableSwapFeeBasisPoints() external view returns (uint256);
function stableTokens(address _token) external view returns (bool);
function tokenDecimals(address _token) external view returns (uint256);
function getMaxPrice(address _token) external view returns (uint256);
function getMinPrice(address _token) external view returns (uint256);
}

View File

@@ -1,96 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
// Keepin everything together
interface IKyberNetwork {
}
interface IKyberNetworkProxy {
function getExpectedRateAfterFee(
address src,
address dest,
uint256 srcQty,
uint256 platformFeeBps,
bytes calldata hint
)
external
view
returns (uint256 expectedRate);
}
interface IKyberHintHandler {
enum TradeType {BestOfAll, MaskIn, MaskOut, Split}
enum ProcessWithRate {NotRequired, Required}
function getTradingReserves(
address tokenSrc,
address tokenDest,
bool isTokenToToken,
bytes calldata hint
)
external
view
returns (
bytes32[] memory reserveIds,
uint256[] memory splitValuesBps,
ProcessWithRate processWithRate
);
function buildTokenToEthHint(
address tokenSrc,
TradeType tokenToEthType,
bytes32[] calldata tokenToEthReserveIds,
uint256[] calldata tokenToEthSplits
)
external
view
returns (bytes memory hint);
function buildEthToTokenHint(
address tokenDest,
TradeType ethToTokenType,
bytes32[] calldata ethToTokenReserveIds,
uint256[] calldata ethToTokenSplits
)
external
view
returns (bytes memory hint);
function buildTokenToTokenHint(
address tokenSrc,
TradeType tokenToEthType,
bytes32[] calldata tokenToEthReserveIds,
uint256[] calldata tokenToEthSplits,
address tokenDest,
TradeType ethToTokenType,
bytes32[] calldata ethToTokenReserveIds,
uint256[] calldata ethToTokenSplits
)
external
view
returns (bytes memory hint);
}

View File

@@ -0,0 +1,11 @@
pragma solidity ^0.6;
interface IPlatypus {
function quotePotentialSwap(
address fromToken,
address toToken,
uint256 fromAmount
) external view returns (uint256 potentialOutcome, uint256 haircut);
function assetOf(address token) external view returns (address);
}

View File

@@ -1,39 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
contract DummyLiquidityProvider
{
/// @dev Quotes the amount of `makerToken` that would be obtained by
/// selling `sellAmount` of `takerToken`.
/// @param sellAmount Amount of `takerToken` to sell.
/// @return makerTokenAmount Amount of `makerToken` that would be obtained.
function getSellQuote(
address, /* takerToken */
address, /* makerToken */
uint256 sellAmount
)
external
view
returns (uint256 makerTokenAmount)
{
makerTokenAmount = sellAmount - 1;
}
/// @dev Quotes the amount of `takerToken` that would need to be sold in
/// order to obtain `buyAmount` of `makerToken`.
/// @param buyAmount Amount of `makerToken` to buy.
/// @return takerTokenAmount Amount of `takerToken` that would need to be sold.
function getBuyQuote(
address, /* takerToken */
address, /* makerToken */
uint256 buyAmount
)
external
view
returns (uint256 takerTokenAmount)
{
takerTokenAmount = buyAmount + 1;
}
}

View File

@@ -1,455 +0,0 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "../src/ERC20BridgeSampler.sol";
import "../src/interfaces/IKyberNetwork.sol";
import "../src/interfaces/IUniswapV2Router01.sol";
library LibDeterministicQuotes {
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
uint256 private constant RATE_DENOMINATOR = 1 ether;
uint256 private constant MIN_RATE = RATE_DENOMINATOR / 100;
uint256 private constant MAX_RATE = 100 * RATE_DENOMINATOR;
uint8 private constant MIN_DECIMALS = 4;
uint8 private constant MAX_DECIMALS = 20;
function getDeterministicSellQuote(
bytes32 salt,
address sellToken,
address buyToken,
uint256 sellAmount
)
internal
pure
returns (uint256 buyAmount)
{
uint256 sellBase = uint256(10) ** getDeterministicTokenDecimals(sellToken);
uint256 buyBase = uint256(10) ** getDeterministicTokenDecimals(buyToken);
uint256 rate = getDeterministicRate(salt, sellToken, buyToken);
return sellAmount * rate * buyBase / sellBase / RATE_DENOMINATOR;
}
function getDeterministicBuyQuote(
bytes32 salt,
address sellToken,
address buyToken,
uint256 buyAmount
)
internal
pure
returns (uint256 sellAmount)
{
uint256 sellBase = uint256(10) ** getDeterministicTokenDecimals(sellToken);
uint256 buyBase = uint256(10) ** getDeterministicTokenDecimals(buyToken);
uint256 rate = getDeterministicRate(salt, sellToken, buyToken);
return buyAmount * RATE_DENOMINATOR * sellBase / rate / buyBase;
}
function getDeterministicTokenDecimals(address token)
internal
pure
returns (uint8 decimals)
{
if (token == WETH_ADDRESS) {
return 18;
}
bytes32 seed = keccak256(abi.encodePacked(token));
return uint8(uint256(seed) % (MAX_DECIMALS - MIN_DECIMALS)) + MIN_DECIMALS;
}
function getDeterministicRate(bytes32 salt, address sellToken, address buyToken)
internal
pure
returns (uint256 rate)
{
bytes32 seed = keccak256(abi.encodePacked(salt, sellToken, buyToken));
return uint256(seed) % (MAX_RATE - MIN_RATE) + MIN_RATE;
}
}
contract TestDeploymentConstants {
// solhint-disable separate-by-one-line-in-contract
// Mainnet addresses ///////////////////////////////////////////////////////
/// @dev Mainnet address of the WETH contract.
address constant private WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
/// @dev Overridable way to get the WETH address.
/// @return wethAddress The WETH address.
function _getWethAddress()
internal
view
returns (address wethAddress)
{
return WETH_ADDRESS;
}
}
contract FailTrigger {
// Give this address a balance to force operations to fail.
address payable constant public FAILURE_ADDRESS = 0xe9dB8717BC5DFB20aaf538b4a5a02B7791FF430C;
// Funds `FAILURE_ADDRESS`.
function enableFailTrigger() external payable {
FAILURE_ADDRESS.transfer(msg.value);
}
function _revertIfShouldFail() internal view {
if (FAILURE_ADDRESS.balance != 0) {
revert("FAIL_TRIGGERED");
}
}
}
contract TestERC20BridgeSamplerUniswapExchange is
IUniswapExchangeQuotes,
TestDeploymentConstants,
FailTrigger
{
bytes32 constant private BASE_SALT = 0x1d6a6a0506b0b4a554b907a4c29d9f4674e461989d9c1921feb17b26716385ab;
address public tokenAddress;
bytes32 public salt;
constructor(address _tokenAddress) public {
tokenAddress = _tokenAddress;
salt = keccak256(abi.encodePacked(BASE_SALT, _tokenAddress));
}
// Deterministic `IUniswapExchangeQuotes.getEthToTokenInputPrice()`.
function getEthToTokenInputPrice(
uint256 ethSold
)
override
external
view
returns (uint256 tokensBought)
{
_revertIfShouldFail();
return LibDeterministicQuotes.getDeterministicSellQuote(
salt,
tokenAddress,
_getWethAddress(),
ethSold
);
}
// Deterministic `IUniswapExchangeQuotes.getEthToTokenOutputPrice()`.
function getEthToTokenOutputPrice(
uint256 tokensBought
)
override
external
view
returns (uint256 ethSold)
{
_revertIfShouldFail();
return LibDeterministicQuotes.getDeterministicBuyQuote(
salt,
_getWethAddress(),
tokenAddress,
tokensBought
);
}
// Deterministic `IUniswapExchangeQuotes.getTokenToEthInputPrice()`.
function getTokenToEthInputPrice(
uint256 tokensSold
)
override
external
view
returns (uint256 ethBought)
{
_revertIfShouldFail();
return LibDeterministicQuotes.getDeterministicSellQuote(
salt,
tokenAddress,
_getWethAddress(),
tokensSold
);
}
// Deterministic `IUniswapExchangeQuotes.getTokenToEthOutputPrice()`.
function getTokenToEthOutputPrice(
uint256 ethBought
)
override
external
view
returns (uint256 tokensSold)
{
_revertIfShouldFail();
return LibDeterministicQuotes.getDeterministicBuyQuote(
salt,
_getWethAddress(),
tokenAddress,
ethBought
);
}
}
contract TestERC20BridgeSamplerUniswapV2Router01 is
IUniswapV2Router01,
TestDeploymentConstants,
FailTrigger
{
bytes32 constant private SALT = 0xadc7fcb33c735913b8635927e66896b356a53a912ab2ceff929e60a04b53b3c1;
// Deterministic `IUniswapV2Router01.getAmountsOut()`.
function getAmountsOut(uint256 amountIn, address[] calldata path)
override
external
view
returns (uint256[] memory amounts)
{
require(path.length >= 2, "PATH_TOO_SHORT");
_revertIfShouldFail();
amounts = new uint256[](path.length);
amounts[0] = amountIn;
for (uint256 i = 0; i < path.length - 1; ++i) {
amounts[i + 1] = LibDeterministicQuotes.getDeterministicSellQuote(
SALT,
path[i],
path[i + 1],
amounts[i]
);
}
}
// Deterministic `IUniswapV2Router01.getAmountsInt()`.
function getAmountsIn(uint256 amountOut, address[] calldata path)
override
external
view
returns (uint256[] memory amounts)
{
require(path.length >= 2, "PATH_TOO_SHORT");
_revertIfShouldFail();
amounts = new uint256[](path.length);
amounts[path.length - 1] = amountOut;
for (uint256 i = path.length - 1; i > 0; --i) {
amounts[i - 1] = LibDeterministicQuotes.getDeterministicBuyQuote(
SALT,
path[i - 1],
path[i],
amounts[i]
);
}
}
}
// solhint-disable space-after-comma
contract TestERC20BridgeSamplerKyberNetwork is
TestDeploymentConstants,
FailTrigger
{
bytes32 constant private SALT = 0x0ff3ca9d46195c39f9a12afb74207b4970349fb3cfb1e459bbf170298d326bc7;
address constant public ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
enum TradeType {BestOfAll, MaskIn, MaskOut, Split}
enum ProcessWithRate {NotRequired, Required}
// IKyberHintHandler
function buildTokenToEthHint(
address tokenSrc,
TradeType /* tokenToEthType */,
bytes32[] calldata /* tokenToEthReserveIds */,
uint256[] calldata /* tokenToEthSplits */
) external view returns (bytes memory hint)
{
return abi.encode(tokenSrc);
}
function buildEthToTokenHint(
address tokenDest,
TradeType /* ethToTokenType */,
bytes32[] calldata /* ethToTokenReserveIds */,
uint256[] calldata /* ethToTokenSplits */
) external view returns (bytes memory hint)
{
return abi.encode(tokenDest);
}
// IKyberHintHandler
function buildTokenToTokenHint(
address tokenSrc,
TradeType /* tokenToEthType */,
bytes32[] calldata /* tokenToEthReserveIds */,
uint256[] calldata /* tokenToEthSplits */,
address /* tokenDest */,
TradeType /* EthToTokenType */,
bytes32[] calldata /* EthToTokenReserveIds */,
uint256[] calldata /* EthToTokenSplits */
) external view returns (bytes memory hint)
{
return abi.encode(tokenSrc);
}
// IKyberHintHandler
function getTradingReserves(
address tokenSrc,
address tokenDest,
bool isTokenToToken,
bytes calldata hint
)
external
view
returns (
bytes32[] memory reserveIds,
uint256[] memory splitValuesBps,
ProcessWithRate processWithRate
)
{
reserveIds = new bytes32[](1);
reserveIds[0] = bytes32(uint256(1));
splitValuesBps = new uint256[](0);
processWithRate = ProcessWithRate.NotRequired;
}
// Deterministic `IKyberNetworkProxy.getExpectedRateAfterFee()`.
function getExpectedRateAfterFee(
address fromToken,
address toToken,
uint256 /* srcQty */,
uint256 /* fee */,
bytes calldata /* hint */
)
external
view
returns
(uint256 expectedRate)
{
_revertIfShouldFail();
fromToken = fromToken == ETH_ADDRESS ? _getWethAddress() : fromToken;
toToken = toToken == ETH_ADDRESS ? _getWethAddress() : toToken;
expectedRate = LibDeterministicQuotes.getDeterministicRate(
SALT,
fromToken,
toToken
);
}
// Deterministic `IKyberNetworkProxy.getExpectedRate()`.
function getExpectedRate(
address fromToken,
address toToken,
uint256
)
external
view
returns (uint256 expectedRate, uint256)
{
_revertIfShouldFail();
fromToken = fromToken == ETH_ADDRESS ? _getWethAddress() : fromToken;
toToken = toToken == ETH_ADDRESS ? _getWethAddress() : toToken;
expectedRate = LibDeterministicQuotes.getDeterministicRate(
SALT,
fromToken,
toToken
);
}
}
contract TestERC20BridgeSamplerUniswapExchangeFactory is
IUniswapExchangeFactory
{
mapping (address => IUniswapExchangeQuotes) private _exchangesByToken;
// Creates Uniswap exchange contracts for tokens.
function createTokenExchanges(address[] calldata tokenAddresses)
external
{
for (uint256 i = 0; i < tokenAddresses.length; i++) {
address tokenAddress = tokenAddresses[i];
_exchangesByToken[tokenAddress] =
new TestERC20BridgeSamplerUniswapExchange(tokenAddress);
}
}
// `IUniswapExchangeFactory.getExchange()`.
function getExchange(address tokenAddress)
override
external
view
returns (address)
{
return address(_exchangesByToken[tokenAddress]);
}
}
contract TestERC20BridgeSampler is
ERC20BridgeSampler,
FailTrigger
{
TestERC20BridgeSamplerUniswapExchangeFactory public uniswap;
TestERC20BridgeSamplerUniswapV2Router01 public uniswapV2Router;
TestERC20BridgeSamplerKyberNetwork public kyber;
uint8 private constant MAX_ORDER_STATUS = uint8(IExchange.OrderStatus.CANCELLED) + 1;
constructor() public ERC20BridgeSampler() {
uniswap = new TestERC20BridgeSamplerUniswapExchangeFactory();
uniswapV2Router = new TestERC20BridgeSamplerUniswapV2Router01();
kyber = new TestERC20BridgeSamplerKyberNetwork();
}
// Creates Uniswap exchange contracts for tokens.
function createTokenExchanges(address[] calldata tokenAddresses)
external
{
uniswap.createTokenExchanges(tokenAddresses);
}
// Overridden to return deterministic states.
function getLimitOrderFillableTakerAmount(
IExchange.LimitOrder memory order,
IExchange.Signature memory,
IExchange
)
override
public
view
returns (uint256 fillableTakerAmount)
{
return uint256(keccak256(abi.encode(order.salt))) % order.takerAmount;
}
// Overriden to return deterministic decimals.
function _getTokenDecimals(address tokenAddress)
override
internal
view
returns (uint8 decimals)
{
return LibDeterministicQuotes.getDeterministicTokenDecimals(tokenAddress);
}
}

View File

@@ -1897,7 +1897,7 @@ ___
# Interface: SwapQuoteRequestOpts
slippagePercentage: The percentage buffer to add to account for slippage. Affects max ETH price estimates. Defaults to 0.2 (20%).
slippagePercentage: The percentage buffer to add to account for slippage. Affects max ETH price estimates. Defaults to 0.01 (1%).
gasPrice: gas price to determine protocolFee amount, default to ethGasStation fast amount

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/asset-swapper",
"version": "16.51.0",
"version": "16.66.2",
"engines": {
"node": ">=6.12"
},
@@ -34,12 +34,13 @@
"contracts:gen": "contracts-gen generate",
"contracts:copy": "contracts-gen copy",
"publish:private": "yarn build && gitpkg publish",
"sampler-size": "jq .compilerOutput.evm.deployedBytecode.object -- test/generated-artifacts/ERC20BridgeSampler.json | echo $(( $(wc -c) / 2 - 1 ))"
"sampler-size": "jq .compilerOutput.evm.deployedBytecode.object -- test/generated-artifacts/ERC20BridgeSampler.json | echo $(( $(wc -c) / 2 - 1 ))",
"list:deps": "yarn lerna list -l"
},
"config": {
"publicInterfaceContracts": "ERC20BridgeSampler,BalanceChecker,FakeTaker",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BalancerV2Sampler|BancorSampler|CompoundSampler|CurveSampler|DODOSampler|DODOV2Sampler|DummyLiquidityProvider|ERC20BridgeSampler|FakeTaker|IBalancer|IBancor|ICurve|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|ISmoothy|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|KyberSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SmoothySampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler).json",
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BalancerV2BatchSampler|BalancerV2Common|BalancerV2Sampler|BancorSampler|BancorV3Sampler|CompoundSampler|CurveSampler|DODOSampler|DODOV2Sampler|ERC20BridgeSampler|FakeTaker|GMXSampler|IBalancer|IBalancerV2Vault|IBancor|IBancorV3|ICurve|IGMX|IMStable|IMooniswap|IMultiBridge|IPlatypus|IShell|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|NativeOrderSampler|PlatypusSampler|SamplerUtils|ShellSampler|SynthetixSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler|VelodromeSampler|WooPPSampler).json",
"postpublish": {
"assets": []
}
@@ -58,22 +59,22 @@
"registry": "git@github.com:0xProject/gitpkg-registry.git"
},
"dependencies": {
"@0x/assert": "^3.0.31",
"@0x/base-contract": "^6.4.5",
"@0x/contract-addresses": "^6.12.0",
"@0x/contract-wrappers": "^13.19.1",
"@0x/contracts-erc20": "^3.3.27",
"@0x/contracts-zero-ex": "^0.31.1",
"@0x/dev-utils": "^4.2.11",
"@0x/json-schemas": "^6.4.1",
"@0x/assert": "^3.0.34",
"@0x/base-contract": "^6.5.0",
"@0x/contract-addresses": "^6.19.1",
"@0x/contract-wrappers": "^13.20.7",
"@0x/contracts-erc20": "^3.3.35",
"@0x/contracts-zero-ex": "^0.36.2",
"@0x/dev-utils": "^4.2.14",
"@0x/fast-abi": "^0.0.5",
"@0x/json-schemas": "^6.4.4",
"@0x/neon-router": "^0.3.5",
"@0x/protocol-utils": "^1.11.1",
"@0x/quote-server": "^6.0.6",
"@0x/types": "^3.3.4",
"@0x/typescript-typings": "^5.2.1",
"@0x/utils": "^6.5.0",
"@0x/web3-wrapper": "^7.6.2",
"@balancer-labs/sor": "0.3.2",
"@0x/protocol-utils": "^11.16.2",
"@0x/quote-server": "^8.0.0",
"@0x/types": "^3.3.6",
"@0x/utils": "^6.5.3",
"@0x/web3-wrapper": "^7.6.5",
"@balancer-labs/sdk": "0.1.6",
"@bancor/sdk": "0.2.9",
"@ethersproject/abi": "^5.0.1",
"@ethersproject/address": "^5.0.1",
@@ -82,32 +83,24 @@
"@ethersproject/strings": "^5.0.10",
"axios": "^0.21.1",
"axios-mock-adapter": "^1.19.0",
"balancer-labs-sor-v1": "npm:@balancer-labs/sor@0.3.2",
"cream-sor": "^0.3.3",
"decimal.js": "^10.2.0",
"ethereum-types": "^3.6.0",
"ethereumjs-util": "^7.0.10",
"fast-abi": "^0.0.4",
"ethereum-types": "^3.7.0",
"graphql": "^15.4.0",
"graphql-request": "^3.4.0",
"heartbeats": "^5.0.1",
"lodash": "^4.17.11"
"lodash": "^4.17.15",
"msw": "^0.44.2"
},
"devDependencies": {
"@0x/abi-gen": "^5.7.2",
"@0x/contracts-asset-proxy": "^3.7.19",
"@0x/contracts-exchange": "^3.2.38",
"@0x/contracts-exchange-libs": "^4.3.37",
"@0x/contracts-gen": "^2.0.43",
"@0x/contracts-test-utils": "^5.4.18",
"@0x/contracts-utils": "^4.8.8",
"@0x/mesh-rpc-client": "^9.4.2",
"@0x/migrations": "^8.1.16",
"@0x/sol-compiler": "^4.7.8",
"@0x/subproviders": "^6.6.2",
"@0x/abi-gen": "^5.8.0",
"@0x/contracts-gen": "^2.0.46",
"@0x/contracts-test-utils": "^5.4.26",
"@0x/sol-compiler": "^4.8.1",
"@0x/subproviders": "^6.6.5",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
"@0x/types": "^3.3.4",
"@types/lodash": "4.14.104",
"@types/lodash": "4.14.137",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"chai": "^4.0.1",
@@ -115,15 +108,14 @@
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"gitpkg": "https://github.com/0xProject/gitpkg.git",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
"tslint": "^6.1.3",
"typedoc": "~0.16.11",
"typemoq": "^2.1.0",
"typescript": "4.2.2"
"typescript": "4.6.3"
},
"publishConfig": {
"access": "public"

View File

@@ -19,7 +19,7 @@ import {
DEFAULT_TOKEN_ADJACENCY_GRAPH_BY_CHAIN_ID,
} from './utils/market_operation_utils/constants';
const ETH_GAS_STATION_API_URL = 'https://ethgasstation.info/api/ethgasAPI.json';
const ZERO_EX_GAS_API_URL = 'https://gas.api.0x.org/source/median';
const NULL_BYTES = '0x';
const NULL_ERC20_ASSET_DATA = '0xf47261b00000000000000000000000000000000000000000000000000000000000000000';
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
@@ -48,7 +48,7 @@ const DEFAULT_SWAP_QUOTER_OPTS: SwapQuoterOpts = {
orderRefreshIntervalMs: 10000, // 10 seconds
...DEFAULT_ORDER_PRUNER_OPTS,
samplerGasLimit: 500e6,
ethGasStationUrl: ETH_GAS_STATION_API_URL,
zeroExGasApiUrl: ZERO_EX_GAS_API_URL,
rfqt: {
integratorsWhitelist: [],
makerAssetOfferings: {},
@@ -95,11 +95,10 @@ export { DEFAULT_FEE_SCHEDULE, DEFAULT_GAS_SCHEDULE } from './utils/market_opera
export const POSITIVE_SLIPPAGE_FEE_TRANSFORMER_GAS = new BigNumber(30000);
// tslint:disable-next-line: custom-no-magic-numbers
export const KEEP_ALIVE_TTL = 5 * 60 * ONE_SECOND_MS;
export const constants = {
ETH_GAS_STATION_API_URL,
ZERO_EX_GAS_API_URL,
PROTOCOL_FEE_MULTIPLIER,
POSITIVE_SLIPPAGE_FEE_TRANSFORMER_GAS,
NULL_BYTES,

View File

@@ -4,7 +4,7 @@ export {
ContractTxFunctionObj,
SendTransactionOpts,
} from '@0x/base-contract';
export { ContractAddresses } from '@0x/contract-addresses';
export { ContractAddresses, ChainId, getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
export {
V4RFQFirmQuote,
V4RFQIndicativeQuote,
@@ -116,6 +116,15 @@ export {
SamplerMetrics,
} from './types';
export { affiliateFeeUtils } from './utils/affiliate_fee_utils';
export {
IRfqClient,
RfqClientV1Price,
RfqClientV1PriceRequest,
RfqClientV1PriceResponse,
RfqClientV1Quote,
RfqClientV1QuoteRequest,
RfqClientV1QuoteResponse,
} from './utils/irfq_client';
export {
DEFAULT_TOKEN_ADJACENCY_GRAPH_BY_CHAIN_ID,
DEFAULT_GAS_SCHEDULE,
@@ -123,6 +132,7 @@ export {
BUY_SOURCE_FILTER_BY_CHAIN_ID,
SELL_SOURCE_FILTER_BY_CHAIN_ID,
NATIVE_FEE_TOKEN_BY_CHAIN_ID,
ZERO_AMOUNT,
} from './utils/market_operation_utils/constants';
export {
Parameters,
@@ -132,7 +142,6 @@ export {
export {
BalancerFillData,
BancorFillData,
CollapsedFill,
CurveFillData,
CurveFunctionSelectors,
CurveInfo,
@@ -141,25 +150,25 @@ export {
ERC20BridgeSource,
ExchangeProxyOverhead,
FeeSchedule,
GasSchedule,
Fill,
FillAdjustor,
FillData,
GetMarketOrdersRfqOpts,
KyberFillData,
LiquidityProviderFillData,
LiquidityProviderRegistry,
MarketDepth,
MarketDepthSide,
MooniswapFillData,
MultiHopFillData,
NativeCollapsedFill,
NativeRfqOrderFillData,
NativeLimitOrderFillData,
NativeFillData,
OptimizedMarketOrder,
SourceQuoteOperation,
TokenAdjacencyGraph,
UniswapV2FillData,
} from './utils/market_operation_utils/types';
export { TokenAdjacencyGraph, TokenAdjacencyGraphBuilder } from './utils/token_adjacency_graph';
export { IdentityFillAdjustor } from './utils/market_operation_utils/identity_fill_adjustor';
export { ProtocolFeeUtils } from './utils/protocol_fee_utils';
export {
BridgeQuoteReportEntry,
@@ -183,3 +192,5 @@ export type Native = ERC20BridgeSource.Native;
export type MultiHop = ERC20BridgeSource.MultiHop;
export { rfqtMocker, RfqtQuoteEndpoint } from './utils/rfqt_mocker';
export { adjustOutput } from './utils/market_operation_utils/fills';

View File

@@ -32,16 +32,14 @@ import {
import { assert } from '../utils/assert';
import {
CURVE_LIQUIDITY_PROVIDER_BY_CHAIN_ID,
MOONISWAP_LIQUIDITY_PROVIDER_BY_CHAIN_ID,
NATIVE_FEE_TOKEN_BY_CHAIN_ID,
} from '../utils/market_operation_utils/constants';
import { poolEncoder } from '../utils/market_operation_utils/orders';
import {
CurveFillData,
ERC20BridgeSource,
FinalUniswapV3FillData,
LiquidityProviderFillData,
MooniswapFillData,
NativeRfqOrderFillData,
OptimizedMarketBridgeOrder,
OptimizedMarketOrder,
UniswapV2FillData,
@@ -60,9 +58,9 @@ import {
isDirectSwapCompatible,
isMultiplexBatchFillCompatible,
isMultiplexMultiHopFillCompatible,
requiresTransformERC20,
} from './quote_consumer_utils';
// tslint:disable-next-line:custom-no-magic-numbers
const MAX_UINT256 = new BigNumber(2).pow(256).minus(1);
const { NULL_ADDRESS, NULL_BYTES, ZERO_AMOUNT } = constants;
@@ -73,9 +71,7 @@ const PANCAKE_SWAP_FORKS = [
ERC20BridgeSource.BakerySwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.ApeSwap,
ERC20BridgeSource.CafeSwap,
ERC20BridgeSource.CheeseSwap,
ERC20BridgeSource.JulSwap,
];
const FAKE_PROVIDER: any = {
sendAsync(): void {
@@ -220,9 +216,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
ERC20BridgeSource.BakerySwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.ApeSwap,
ERC20BridgeSource.CafeSwap,
ERC20BridgeSource.CheeseSwap,
ERC20BridgeSource.JulSwap,
])
) {
const source = slippedOrders[0].source;
@@ -278,13 +272,13 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
if (
this.chainId === ChainId.Mainnet &&
isDirectSwapCompatible(quote, optsWithDefaults, [ERC20BridgeSource.Curve, ERC20BridgeSource.Swerve]) &&
isDirectSwapCompatible(quote, optsWithDefaults, [ERC20BridgeSource.Curve]) &&
// Curve VIP cannot currently support WETH buy/sell as the functionality needs to WITHDRAW or DEPOSIT
// into WETH prior/post the trade.
// ETH buy/sell is supported
![sellToken, buyToken].includes(NATIVE_FEE_TOKEN_BY_CHAIN_ID[ChainId.Mainnet])
) {
const fillData = slippedOrders[0].fills[0].fillData as CurveFillData;
const fillData = slippedOrders[0].fillData as CurveFillData;
return {
calldataHexString: this._exchangeProxy
.sellToLiquidityProvider(
@@ -309,26 +303,45 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
};
}
// RFQT VIP
if (
this.chainId === ChainId.Mainnet &&
isDirectSwapCompatible(quote, optsWithDefaults, [ERC20BridgeSource.Mooniswap])
[ChainId.Mainnet, ChainId.Polygon].includes(this.chainId) &&
!isToETH &&
!isFromETH &&
quote.orders.every(o => o.type === FillQuoteTransformerOrderType.Rfq) &&
!requiresTransformERC20(optsWithDefaults)
) {
const fillData = slippedOrders[0].fills[0].fillData as MooniswapFillData;
const rfqOrdersData = quote.orders.map(o => o.fillData as NativeRfqOrderFillData);
const fillAmountPerOrder = (() => {
// Don't think order taker amounts are clipped to actual sell amount
// (the last one might be too large) so figure them out manually.
let remaining = sellAmount;
const fillAmounts = [];
for (const o of quote.orders) {
const fillAmount = BigNumber.min(o.takerAmount, remaining);
fillAmounts.push(fillAmount);
remaining = remaining.minus(fillAmount);
}
return fillAmounts;
})();
const callData =
quote.orders.length === 1
? this._exchangeProxy
.fillRfqOrder(rfqOrdersData[0].order, rfqOrdersData[0].signature, fillAmountPerOrder[0])
.getABIEncodedTransactionData()
: this._exchangeProxy
.batchFillRfqOrders(
rfqOrdersData.map(d => d.order),
rfqOrdersData.map(d => d.signature),
fillAmountPerOrder,
true,
)
.getABIEncodedTransactionData();
return {
calldataHexString: this._exchangeProxy
.sellToLiquidityProvider(
isFromETH ? ETH_TOKEN_ADDRESS : sellToken,
isToETH ? ETH_TOKEN_ADDRESS : buyToken,
MOONISWAP_LIQUIDITY_PROVIDER_BY_CHAIN_ID[this.chainId],
NULL_ADDRESS,
sellAmount,
minBuyAmount,
poolEncoder.encode([fillData.poolAddress]),
)
.getABIEncodedTransactionData(),
ethAmount: isFromETH ? sellAmount : ZERO_AMOUNT,
calldataHexString: callData,
ethAmount: ZERO_AMOUNT,
toAddress: this._exchangeProxy.address,
allowanceTarget: this.contractAddresses.exchangeProxy,
allowanceTarget: this._exchangeProxy.address,
gasOverhead: ZERO_AMOUNT,
};
}

View File

@@ -1,9 +1,9 @@
import { ChainId, getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { FastABI } from '@0x/fast-abi';
import { FillQuoteTransformerOrderType, LimitOrder } from '@0x/protocol-utils';
import { BigNumber, providerUtils } from '@0x/utils';
import Axios, { AxiosInstance } from 'axios';
import { BlockParamLiteral, MethodAbi, SupportedProvider, ZeroExProvider } from 'ethereum-types';
import { FastABI } from 'fast-abi';
import { Agent as HttpAgent } from 'http';
import { Agent as HttpsAgent } from 'https';
import * as _ from 'lodash';
@@ -25,6 +25,7 @@ import {
SwapQuoterRfqOpts,
} from './types';
import { assert } from './utils/assert';
import { IRfqClient } from './utils/irfq_client';
import { MarketOperationUtils } from './utils/market_operation_utils';
import { BancorService } from './utils/market_operation_utils/bancor_service';
import { SAMPLER_ADDRESS, SOURCE_FLAGS, ZERO_AMOUNT } from './utils/market_operation_utils/constants';
@@ -32,12 +33,9 @@ import { DexOrderSampler } from './utils/market_operation_utils/sampler';
import { SourceFilters } from './utils/market_operation_utils/source_filters';
import {
ERC20BridgeSource,
FeeSchedule,
FillData,
GasSchedule,
GetMarketOrdersOpts,
MarketDepth,
MarketDepthSide,
MarketSideLiquidity,
OptimizedMarketOrder,
OptimizerResultWithReport,
} from './utils/market_operation_utils/types';
@@ -111,7 +109,7 @@ export class SwapQuoter {
};
this._protocolFeeUtils = ProtocolFeeUtils.getInstance(
constants.PROTOCOL_FEE_UTILS_POLLING_INTERVAL_IN_MS,
options.ethGasStationUrl,
options.zeroExGasApiUrl,
);
// Allow the sampler bytecode to be overwritten using geths override functionality
const samplerBytecode = _.get(artifacts.ERC20BridgeSampler, 'compilerOutput.evm.deployedBytecode.object');
@@ -227,67 +225,6 @@ export class SwapQuoter {
return batchSwapQuotes.filter(x => x !== undefined) as MarketBuySwapQuote[];
}
/**
* Returns the bids and asks liquidity for the entire market.
* For certain sources (like AMM's) it is recommended to provide a practical maximum takerAssetAmount.
* @param makerTokenAddress The address of the maker asset
* @param takerTokenAddress The address of the taker asset
* @param takerAssetAmount The amount to sell and buy for the bids and asks.
*
* @return An object that conforms to MarketDepth that contains all of the samples and liquidity
* information for the source.
*/
public async getBidAskLiquidityForMakerTakerAssetPairAsync(
makerToken: string,
takerToken: string,
takerAssetAmount: BigNumber,
options: Partial<SwapQuoteRequestOpts> = {},
): Promise<MarketDepth> {
assert.isString('makerToken', makerToken);
assert.isString('takerToken', takerToken);
const sourceFilters = new SourceFilters([], options.excludedSources, options.includedSources);
let [sellOrders, buyOrders] = !sourceFilters.isAllowed(ERC20BridgeSource.Native)
? [[], []]
: await Promise.all([
this.orderbook.getOrdersAsync(makerToken, takerToken),
this.orderbook.getOrdersAsync(takerToken, makerToken),
]);
if (!sellOrders || sellOrders.length === 0) {
sellOrders = [createDummyOrder(makerToken, takerToken)];
}
if (!buyOrders || buyOrders.length === 0) {
buyOrders = [createDummyOrder(takerToken, makerToken)];
}
const getMarketDepthSide = (marketSideLiquidity: MarketSideLiquidity): MarketDepthSide => {
const { dexQuotes, nativeOrders } = marketSideLiquidity.quotes;
const { side } = marketSideLiquidity;
return [
...dexQuotes,
nativeOrders.map(o => {
return {
input: side === MarketOperation.Sell ? o.fillableTakerAmount : o.fillableMakerAmount,
output: side === MarketOperation.Sell ? o.fillableMakerAmount : o.fillableTakerAmount,
fillData: o,
source: ERC20BridgeSource.Native,
};
}),
];
};
const [bids, asks] = await Promise.all([
this._marketOperationUtils.getMarketBuyLiquidityAsync(buyOrders, takerAssetAmount, options),
this._marketOperationUtils.getMarketSellLiquidityAsync(sellOrders, takerAssetAmount, options),
]);
return {
bids: getMarketDepthSide(bids),
asks: getMarketDepthSide(asks),
makerTokenDecimals: asks.makerTokenDecimals,
takerTokenDecimals: asks.takerTokenDecimals,
};
}
/**
* Returns the recommended gas price for a fast transaction
*/
@@ -327,6 +264,7 @@ export class SwapQuoter {
assetFillAmount: BigNumber,
marketOperation: MarketOperation,
options: Partial<SwapQuoteRequestOpts>,
rfqClient?: IRfqClient | undefined,
): Promise<SwapQuote> {
assert.isETHAddressHex('makerToken', makerToken);
assert.isETHAddressHex('takerToken', takerToken);
@@ -364,9 +302,11 @@ export class SwapQuoter {
const calcOpts: GetMarketOrdersOpts = {
...cloneOpts,
gasPrice,
feeSchedule: _.mapValues(opts.feeSchedule, gasCost => (fillData: FillData) =>
gasCost === undefined ? 0 : gasPrice.times(gasCost(fillData)),
),
feeSchedule: _.mapValues(opts.gasSchedule, gasCost => (fillData: FillData) => {
const gas = gasCost ? gasCost(fillData) : 0;
const fee = gasPrice.times(gas);
return { gas, fee };
}),
exchangeProxyOverhead: flags => gasPrice.times(opts.exchangeProxyOverhead(flags)),
};
// pass the QuoteRequestor on if rfqt enabled
@@ -381,6 +321,7 @@ export class SwapQuoter {
this.expiryBufferMs,
rfqtOptions?.metricsProxy,
);
calcOpts.rfqt.rfqClient = rfqClient;
}
const result: OptimizerResultWithReport = await this._marketOperationUtils.getOptimizerResultAsync(
@@ -499,7 +440,7 @@ function createSwapQuote(
operation: MarketOperation,
assetFillAmount: BigNumber,
gasPrice: BigNumber,
gasSchedule: FeeSchedule,
gasSchedule: GasSchedule,
slippage: number,
): SwapQuote {
const {
@@ -519,7 +460,7 @@ function createSwapQuote(
: calculateQuoteInfo(optimizedOrders, operation, assetFillAmount, gasPrice, gasSchedule, slippage);
// Put together the swap quote
const { makerTokenDecimals, takerTokenDecimals } = optimizerResult.marketSideLiquidity;
const { makerTokenDecimals, takerTokenDecimals, blockNumber } = optimizerResult.marketSideLiquidity;
const swapQuote = {
makerToken,
takerToken,
@@ -536,6 +477,7 @@ function createSwapQuote(
extendedQuoteReportSources,
isTwoHop,
priceComparisonsReport,
blockNumber,
};
if (operation === MarketOperation.Buy) {
@@ -558,7 +500,7 @@ function calculateQuoteInfo(
operation: MarketOperation,
assetFillAmount: BigNumber,
gasPrice: BigNumber,
gasSchedule: FeeSchedule,
gasSchedule: GasSchedule,
slippage: number,
): { bestCaseQuoteInfo: SwapQuoteInfo; worstCaseQuoteInfo: SwapQuoteInfo; sourceBreakdown: SwapQuoteOrdersBreakdown } {
const bestCaseFillResult = simulateBestCaseFill({
@@ -587,25 +529,23 @@ function calculateQuoteInfo(
function calculateTwoHopQuoteInfo(
optimizedOrders: OptimizedMarketOrder[],
operation: MarketOperation,
gasSchedule: FeeSchedule,
gasSchedule: GasSchedule,
slippage: number,
): { bestCaseQuoteInfo: SwapQuoteInfo; worstCaseQuoteInfo: SwapQuoteInfo; sourceBreakdown: SwapQuoteOrdersBreakdown } {
const [firstHopOrder, secondHopOrder] = optimizedOrders;
const [firstHopFill] = firstHopOrder.fills;
const [secondHopFill] = secondHopOrder.fills;
const gas = new BigNumber(
gasSchedule[ERC20BridgeSource.MultiHop]!({
firstHopSource: _.pick(firstHopFill, 'source', 'fillData'),
secondHopSource: _.pick(secondHopFill, 'source', 'fillData'),
firstHopSource: _.pick(firstHopOrder, 'source', 'fillData'),
secondHopSource: _.pick(secondHopOrder, 'source', 'fillData'),
}),
).toNumber();
const isSell = operation === MarketOperation.Sell;
return {
bestCaseQuoteInfo: {
makerAmount: isSell ? secondHopFill.output : secondHopFill.input,
takerAmount: isSell ? firstHopFill.input : firstHopFill.output,
totalTakerAmount: isSell ? firstHopFill.input : firstHopFill.output,
makerAmount: isSell ? secondHopOrder.fill.output : secondHopOrder.fill.input,
takerAmount: isSell ? firstHopOrder.fill.input : firstHopOrder.fill.output,
totalTakerAmount: isSell ? firstHopOrder.fill.input : firstHopOrder.fill.output,
feeTakerTokenAmount: constants.ZERO_AMOUNT,
protocolFeeInWeiAmount: constants.ZERO_AMOUNT,
gas,
@@ -631,7 +571,7 @@ function calculateTwoHopQuoteInfo(
[ERC20BridgeSource.MultiHop]: {
proportion: new BigNumber(1),
intermediateToken: secondHopOrder.takerToken,
hops: [firstHopFill.source, secondHopFill.source],
hops: [firstHopOrder.source, secondHopOrder.source],
},
},
};

View File

@@ -17,11 +17,13 @@ import {
GetMarketOrdersOpts,
LiquidityProviderRegistry,
OptimizedMarketOrder,
TokenAdjacencyGraph,
} from './utils/market_operation_utils/types';
export { SamplerMetrics } from './utils/market_operation_utils/types';
import { ExtendedQuoteReportSources, PriceComparisonsReport, QuoteReport } from './utils/quote_report_generator';
import { MetricsProxy } from './utils/quote_requestor';
import { TokenAdjacencyGraph } from './utils/token_adjacency_graph';
export { SamplerMetrics } from './utils/market_operation_utils/types';
export type Address = string;
/**
* expiryBufferMs: The number of seconds to add when calculating whether an order is expired or not. Defaults to 300s (5m).
@@ -179,6 +181,7 @@ export interface SwapQuoteBase {
takerTokenDecimals: number;
takerAmountPerEth: BigNumber;
makerAmountPerEth: BigNumber;
blockNumber: number;
}
/**
@@ -334,7 +337,7 @@ export interface SwapQuoterOpts extends OrderPrunerOpts {
contractAddresses?: AssetSwapperContractAddresses;
samplerGasLimit?: number;
multiBridgeAddress?: string;
ethGasStationUrl?: string;
zeroExGasApiUrl?: string;
rfqt?: SwapQuoterRfqOpts;
samplerOverrides?: SamplerOverrides;
tokenAdjacencyGraph?: TokenAdjacencyGraph;

View File

@@ -17,7 +17,10 @@ import {
const SUCCESS_CODE = 201;
function getAltMarketInfo(
/**
* Returns the AltOffering if it exists for a given pair
*/
export function getAltMarketInfo(
offerings: AltOffering[],
buyTokenAddress: string,
sellTokenAddress: string,
@@ -101,11 +104,9 @@ function parseIndicativeQuoteResponseFromAltMM(
takerAmount,
// HACK: alt implementation does not return an expiration with indicative quotes
// return now + { IMPUTED EXPIRY SECONDS } to have it included after order checks
expiry:
// tslint:disable-next-line:custom-no-magic-numbers
new BigNumber(Date.now() / 1000)
.integerValue(BigNumber.ROUND_DOWN)
.plus(constants.ALT_MM_IMPUTED_INDICATIVE_EXPIRY_SECONDS),
expiry: new BigNumber(Date.now() / 1000)
.integerValue(BigNumber.ROUND_DOWN)
.plus(constants.ALT_MM_IMPUTED_INDICATIVE_EXPIRY_SECONDS),
};
}
@@ -240,7 +241,6 @@ export async function returnQuoteFromAltMMAsync<ResponseT>(
// empty response will get filtered out in validation
const emptyResponse = {};
// tslint:disable-next-line:custom-no-magic-numbers
if (response.status !== SUCCESS_CODE) {
const rejectedRequestInfo = {
status: response.status,

View File

@@ -0,0 +1,59 @@
import { RfqOrder, Signature } from '@0x/protocol-utils';
import { BigNumber } from '@0x/utils';
import { AltRfqMakerAssetOfferings } from '../types';
export interface RfqClientV1PriceRequest {
altRfqAssetOfferings: AltRfqMakerAssetOfferings | undefined;
assetFillAmount: BigNumber;
chainId: number;
comparisonPrice: BigNumber | undefined;
integratorId: string;
intentOnFilling: boolean;
makerToken: string;
marketOperation: 'Sell' | 'Buy';
takerAddress: string;
takerToken: string;
txOrigin: string;
}
export interface RfqClientV1QuoteRequest extends RfqClientV1PriceRequest {}
export interface RfqClientV1Price {
expiry: BigNumber;
kind: 'rfq' | 'otc';
makerAmount: BigNumber;
makerToken: string;
makerUri: string;
takerAmount: BigNumber;
takerToken: string;
}
export interface RfqClientV1PriceResponse {
prices: RfqClientV1Price[];
}
export interface RfqClientV1Quote {
makerUri: string;
order: RfqOrder;
signature: Signature;
}
export interface RfqClientV1QuoteResponse {
quotes: RfqClientV1Quote[];
}
/**
* IRfqClient is an interface that defines how to connect with an Rfq system.
*/
export interface IRfqClient {
/**
* Fetches a list of "indicative quotes" or prices from a remote Rfq server
*/
getV1PricesAsync(request: RfqClientV1PriceRequest): Promise<RfqClientV1PriceResponse>;
/**
* Fetches a list of "firm quotes" or signed quotes from a remote Rfq server.
*/
getV1QuotesAsync(request: RfqClientV1QuoteRequest): Promise<RfqClientV1QuoteResponse>;
}

View File

@@ -40,7 +40,6 @@ interface Cache {
[key: string]: AaveReserve[];
}
// tslint:disable-next-line:custom-no-magic-numbers
const RESERVES_REFRESH_INTERVAL_MS = 30 * constants.ONE_MINUTE_MS;
/**

View File

@@ -1,14 +1,13 @@
import { ChainId } from '@0x/contract-addresses';
import { BigNumber, NULL_BYTES } from '@0x/utils';
import { BigNumber } from '@0x/utils';
import {
ACRYPTOS_BSC_INFOS,
APESWAP_ROUTER_BY_CHAIN_ID,
BAKERYSWAP_ROUTER_BY_CHAIN_ID,
BELT_BSC_INFOS,
CAFESWAP_ROUTER_BY_CHAIN_ID,
BISWAP_ROUTER_BY_CHAIN_ID,
CHEESESWAP_ROUTER_BY_CHAIN_ID,
COMETHSWAP_ROUTER_BY_CHAIN_ID,
COMPONENT_POOLS_BY_CHAIN_ID,
CRYPTO_COM_ROUTER_BY_CHAIN_ID,
CURVE_AVALANCHE_INFOS,
@@ -25,31 +24,26 @@ import {
FIREBIRDONESWAP_BSC_INFOS,
FIREBIRDONESWAP_POLYGON_INFOS,
IRONSWAP_POLYGON_INFOS,
JETSWAP_ROUTER_BY_CHAIN_ID,
JULSWAP_ROUTER_BY_CHAIN_ID,
KYBER_BANNED_RESERVES,
KYBER_BRIDGED_LIQUIDITY_PREFIX,
KNIGHTSWAP_ROUTER_BY_CHAIN_ID,
MAX_DODOV2_POOLS_QUERIED,
MAX_KYBER_RESERVES_QUERIED,
MDEX_ROUTER_BY_CHAIN_ID,
MESHSWAP_ROUTER_BY_CHAIN_ID,
MOBIUSMONEY_CELO_INFOS,
MORPHEUSSWAP_ROUTER_BY_CHAIN_ID,
MSTABLE_POOLS_BY_CHAIN_ID,
NERVE_BSC_INFOS,
NULL_ADDRESS,
PANCAKESWAP_ROUTER_BY_CHAIN_ID,
PANCAKESWAPV2_ROUTER_BY_CHAIN_ID,
PANCAKESWAP_ROUTER_BY_CHAIN_ID,
PANGOLIN_ROUTER_BY_CHAIN_ID,
POLYDEX_ROUTER_BY_CHAIN_ID,
PLATYPUS_AVALANCHE_INFOS,
QUICKSWAP_ROUTER_BY_CHAIN_ID,
SADDLE_MAINNET_INFOS,
SHELL_POOLS_BY_CHAIN_ID,
SHIBASWAP_ROUTER_BY_CHAIN_ID,
SMOOTHY_BSC_INFOS,
SMOOTHY_MAINNET_INFOS,
SNOWSWAP_MAINNET_INFOS,
SPIRITSWAP_ROUTER_BY_CHAIN_ID,
SPOOKYSWAP_ROUTER_BY_CHAIN_ID,
SUSHISWAP_ROUTER_BY_CHAIN_ID,
SWERVE_MAINNET_INFOS,
SYNAPSE_AVALANCHE_INFOS,
SYNAPSE_BSC_INFOS,
SYNAPSE_FANTOM_INFOS,
@@ -61,35 +55,15 @@ import {
UNISWAPV2_ROUTER_BY_CHAIN_ID,
WAULTSWAP_ROUTER_BY_CHAIN_ID,
XSIGMA_MAINNET_INFOS,
YOSHI_ROUTER_BY_CHAIN_ID,
} from './constants';
import { CurveInfo, ERC20BridgeSource } from './types';
/**
* Filter Kyber reserves which should not be used (0xbb bridged reserves)
* @param reserveId Kyber reserveId
*/
export function isAllowedKyberReserveId(reserveId: string): boolean {
return (
reserveId !== NULL_BYTES &&
!reserveId.startsWith(KYBER_BRIDGED_LIQUIDITY_PREFIX) &&
!KYBER_BANNED_RESERVES.includes(reserveId)
);
}
import { CurveInfo, ERC20BridgeSource, PlatypusInfo } from './types';
// tslint:disable-next-line: completed-docs ban-types
export function isValidAddress(address: string | String): address is string {
return (typeof address === 'string' || address instanceof String) && address.toString() !== NULL_ADDRESS;
}
/**
* Returns the offsets to be used to discover Kyber reserves
*/
export function getKyberOffsets(): BigNumber[] {
return Array(MAX_KYBER_RESERVES_QUERIED)
.fill(0)
.map((_v, i) => new BigNumber(i));
}
// tslint:disable completed-docs
export function getDodoV2Offsets(): BigNumber[] {
return Array(MAX_DODOV2_POOLS_QUERIED)
@@ -224,32 +198,6 @@ export function getCurveV2InfosForPair(chainId: ChainId, takerToken: string, mak
}
}
export function getSwerveInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.Mainnet) {
return [];
}
return Object.values(SWERVE_MAINNET_INFOS).filter(c =>
[makerToken, takerToken].every(
t =>
(c.tokens.includes(t) && c.metaTokens === undefined) ||
(c.tokens.includes(t) && [makerToken, takerToken].filter(v => c.metaTokens?.includes(v)).length > 0),
),
);
}
export function getSnowSwapInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.Mainnet) {
return [];
}
return Object.values(SNOWSWAP_MAINNET_INFOS).filter(c =>
[makerToken, takerToken].every(
t =>
(c.tokens.includes(t) && c.metaTokens === undefined) ||
(c.tokens.includes(t) && [makerToken, takerToken].filter(v => c.metaTokens?.includes(v)).length > 0),
),
);
}
export function getNerveInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.BSC) {
return [];
@@ -374,30 +322,6 @@ export function getEllipsisInfosForPair(chainId: ChainId, takerToken: string, ma
);
}
export function getSmoothyInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId === ChainId.BSC) {
return Object.values(SMOOTHY_BSC_INFOS).filter(c =>
[makerToken, takerToken].every(
t =>
(c.tokens.includes(t) && c.metaTokens === undefined) ||
(c.tokens.includes(t) &&
[makerToken, takerToken].filter(v => c.metaTokens?.includes(v)).length > 0),
),
);
} else if (chainId === ChainId.Mainnet) {
return Object.values(SMOOTHY_MAINNET_INFOS).filter(c =>
[makerToken, takerToken].every(
t =>
(c.tokens.includes(t) && c.metaTokens === undefined) ||
(c.tokens.includes(t) &&
[makerToken, takerToken].filter(v => c.metaTokens?.includes(v)).length > 0),
),
);
} else {
return [];
}
}
export function getSaddleInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.Mainnet) {
return [];
@@ -449,6 +373,27 @@ export function getAcryptosInfosForPair(chainId: ChainId, takerToken: string, ma
),
);
}
export function getMobiusMoneyInfoForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.Celo) {
return [];
}
return Object.values(MOBIUSMONEY_CELO_INFOS).filter(c =>
[makerToken, takerToken].every(
t =>
(c.tokens.includes(t) && c.metaTokens === undefined) ||
(c.tokens.includes(t) && [makerToken, takerToken].filter(v => c.metaTokens?.includes(v)).length > 0),
),
);
}
export function getPlatypusInfoForPair(chainId: ChainId, takerToken: string, makerToken: string): PlatypusInfo[] {
if (chainId !== ChainId.Avalanche) {
return [];
}
return Object.values(PLATYPUS_AVALANCHE_INFOS).filter(c =>
[makerToken, takerToken].every(t => c.tokens.includes(t)),
);
}
export function getShellLikeInfosForPair(
chainId: ChainId,
@@ -480,18 +425,16 @@ export function getCurveLikeInfosForPair(
source:
| ERC20BridgeSource.Curve
| ERC20BridgeSource.CurveV2
| ERC20BridgeSource.Swerve
| ERC20BridgeSource.SnowSwap
| ERC20BridgeSource.Nerve
| ERC20BridgeSource.Synapse
| ERC20BridgeSource.Belt
| ERC20BridgeSource.Ellipsis
| ERC20BridgeSource.Smoothy
| ERC20BridgeSource.Saddle
| ERC20BridgeSource.IronSwap
| ERC20BridgeSource.XSigma
| ERC20BridgeSource.FirebirdOneSwap
| ERC20BridgeSource.ACryptos,
| ERC20BridgeSource.ACryptos
| ERC20BridgeSource.MobiusMoney,
): CurveDetailedInfo[] {
let pools: CurveInfo[] = [];
switch (source) {
@@ -501,12 +444,6 @@ export function getCurveLikeInfosForPair(
case ERC20BridgeSource.CurveV2:
pools = getCurveV2InfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Swerve:
pools = getSwerveInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.SnowSwap:
pools = getSnowSwapInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Nerve:
pools = getNerveInfosForPair(chainId, takerToken, makerToken);
break;
@@ -519,9 +456,6 @@ export function getCurveLikeInfosForPair(
case ERC20BridgeSource.Ellipsis:
pools = getEllipsisInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Smoothy:
pools = getSmoothyInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Saddle:
pools = getSaddleInfosForPair(chainId, takerToken, makerToken);
break;
@@ -537,6 +471,9 @@ export function getCurveLikeInfosForPair(
case ERC20BridgeSource.ACryptos:
pools = getAcryptosInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.MobiusMoney:
pools = getMobiusMoneyInfoForPair(chainId, takerToken, makerToken);
break;
default:
throw new Error(`Unknown Curve like source ${source}`);
}
@@ -557,22 +494,22 @@ export function uniswapV2LikeRouterAddress(
| ERC20BridgeSource.PancakeSwapV2
| ERC20BridgeSource.BakerySwap
| ERC20BridgeSource.ApeSwap
| ERC20BridgeSource.CafeSwap
| ERC20BridgeSource.CheeseSwap
| ERC20BridgeSource.JulSwap
| ERC20BridgeSource.QuickSwap
| ERC20BridgeSource.ComethSwap
| ERC20BridgeSource.Dfyn
| ERC20BridgeSource.WaultSwap
| ERC20BridgeSource.Polydex
| ERC20BridgeSource.ShibaSwap
| ERC20BridgeSource.JetSwap
| ERC20BridgeSource.TraderJoe
| ERC20BridgeSource.Pangolin
| ERC20BridgeSource.UbeSwap
| ERC20BridgeSource.MorpheusSwap
| ERC20BridgeSource.SpookySwap
| ERC20BridgeSource.SpiritSwap,
| ERC20BridgeSource.SpiritSwap
| ERC20BridgeSource.BiSwap
| ERC20BridgeSource.Yoshi
| ERC20BridgeSource.MDex
| ERC20BridgeSource.KnightSwap
| ERC20BridgeSource.MeshSwap,
): string {
switch (source) {
case ERC20BridgeSource.UniswapV2:
@@ -589,26 +526,16 @@ export function uniswapV2LikeRouterAddress(
return BAKERYSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.ApeSwap:
return APESWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.CafeSwap:
return CAFESWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.CheeseSwap:
return CHEESESWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.JulSwap:
return JULSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.QuickSwap:
return QUICKSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.ComethSwap:
return COMETHSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.Dfyn:
return DFYN_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.WaultSwap:
return WAULTSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.Polydex:
return POLYDEX_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.ShibaSwap:
return SHIBASWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.JetSwap:
return JETSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.Pangolin:
return PANGOLIN_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.TraderJoe:
@@ -621,6 +548,16 @@ export function uniswapV2LikeRouterAddress(
return SPOOKYSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.SpiritSwap:
return SPIRITSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.BiSwap:
return BISWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.Yoshi:
return YOSHI_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.MeshSwap:
return MESHSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.MDex:
return MDEX_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.KnightSwap:
return KNIGHTSWAP_ROUTER_BY_CHAIN_ID[chainId];
default:
throw new Error(`Unknown UniswapV2 like source ${source}`);
}

View File

@@ -48,7 +48,7 @@ export function getComparisonPrices(
} else {
try {
const fillFeeInEth = new BigNumber(
(feeSchedule[ERC20BridgeSource.Native] as FeeEstimate)({ type: FillQuoteTransformerOrderType.Rfq }),
(feeSchedule[ERC20BridgeSource.Native] as FeeEstimate)({ type: FillQuoteTransformerOrderType.Rfq }).fee,
);
const exchangeProxyOverheadInEth = new BigNumber(exchangeProxyOverhead(SOURCE_FLAGS.RfqOrder));
feeInEth = fillFeeInEth.plus(exchangeProxyOverheadInEth);

View File

@@ -19,7 +19,6 @@ interface Cache {
[key: string]: CToken;
}
// tslint:disable-next-line:custom-no-magic-numbers
const CTOKEN_REFRESH_INTERVAL_MS = 30 * constants.ONE_MINUTE_MS;
/**

View File

@@ -3,74 +3,17 @@ import { BigNumber, hexUtils } from '@0x/utils';
import { MarketOperation, NativeOrderWithFillableAmounts } from '../../types';
import { POSITIVE_INF, SOURCE_FLAGS, ZERO_AMOUNT } from './constants';
import { DEFAULT_FEE_ESTIMATE, POSITIVE_INF, SOURCE_FLAGS } from './constants';
import { DexSample, ERC20BridgeSource, FeeSchedule, Fill } from './types';
// tslint:disable: prefer-for-of no-bitwise completed-docs
/**
* Create `Fill` objects from orders and dex quotes.
* Converts the ETH value to an amount in output tokens.
*
* By default this prefers the outputAmountPerEth, but if this value
* is zero it will utilize the inputAmountPerEth and input.
*/
export function createFills(opts: {
side: MarketOperation;
orders?: NativeOrderWithFillableAmounts[];
dexQuotes?: DexSample[][];
targetInput?: BigNumber;
outputAmountPerEth?: BigNumber;
inputAmountPerEth?: BigNumber;
excludedSources?: ERC20BridgeSource[];
feeSchedule?: FeeSchedule;
}): Fill[][] {
const { side } = opts;
const excludedSources = opts.excludedSources || [];
const feeSchedule = opts.feeSchedule || {};
const orders = opts.orders || [];
const dexQuotes = opts.dexQuotes || [];
const outputAmountPerEth = opts.outputAmountPerEth || ZERO_AMOUNT;
const inputAmountPerEth = opts.inputAmountPerEth || ZERO_AMOUNT;
// Create native fills.
const nativeFills = nativeOrdersToFills(
side,
orders.filter(o => o.fillableTakerAmount.isGreaterThan(0)),
opts.targetInput,
outputAmountPerEth,
inputAmountPerEth,
feeSchedule,
);
// Create DEX fills.
const dexFills = dexQuotes.map(singleSourceSamples =>
dexSamplesToFills(side, singleSourceSamples, outputAmountPerEth, inputAmountPerEth, feeSchedule),
);
return [...dexFills, nativeFills]
.map(p => clipFillsToInput(p, opts.targetInput))
.filter(fills => hasLiquidity(fills) && !excludedSources.includes(fills[0].source));
}
function clipFillsToInput(fills: Fill[], targetInput: BigNumber = POSITIVE_INF): Fill[] {
const clipped: Fill[] = [];
let input = ZERO_AMOUNT;
for (const fill of fills) {
if (input.gte(targetInput)) {
break;
}
input = input.plus(fill.input);
clipped.push(fill);
}
return clipped;
}
function hasLiquidity(fills: Fill[]): boolean {
if (fills.length === 0) {
return false;
}
const totalInput = BigNumber.sum(...fills.map(fill => fill.input));
const totalOutput = BigNumber.sum(...fills.map(fill => fill.output));
if (totalInput.isZero() || totalOutput.isZero()) {
return false;
}
return true;
}
export function ethToOutputAmount({
input,
output,
@@ -85,122 +28,106 @@ export function ethToOutputAmount({
ethAmount: BigNumber | number;
}): BigNumber {
return !outputAmountPerEth.isZero()
? outputAmountPerEth.times(ethAmount)
? outputAmountPerEth.times(ethAmount).integerValue()
: inputAmountPerEth.times(ethAmount).times(output.dividedToIntegerBy(input));
}
export function nativeOrdersToFills(
export function nativeOrderToFill(
side: MarketOperation,
orders: NativeOrderWithFillableAmounts[],
order: NativeOrderWithFillableAmounts,
targetInput: BigNumber = POSITIVE_INF,
outputAmountPerEth: BigNumber,
inputAmountPerEth: BigNumber,
fees: FeeSchedule,
filterNegativeAdjustedRateOrders: boolean = true,
): Fill[] {
): Fill | undefined {
const sourcePathId = hexUtils.random();
// Create a single path from all orders.
let fills: Array<Fill & { adjustedRate: BigNumber }> = [];
for (const o of orders) {
const { fillableTakerAmount, fillableTakerFeeAmount, fillableMakerAmount, type } = o;
const makerAmount = fillableMakerAmount;
const takerAmount = fillableTakerAmount.plus(fillableTakerFeeAmount);
const input = side === MarketOperation.Sell ? takerAmount : makerAmount;
const output = side === MarketOperation.Sell ? makerAmount : takerAmount;
const fee = fees[ERC20BridgeSource.Native] === undefined ? 0 : fees[ERC20BridgeSource.Native]!(o);
const outputPenalty = ethToOutputAmount({
input,
output,
inputAmountPerEth,
outputAmountPerEth,
ethAmount: fee,
});
// targetInput can be less than the order size
// whilst the penalty is constant, it affects the adjusted output
// only up until the target has been exhausted.
// A large order and an order at the exact target should be penalized
// the same.
const clippedInput = BigNumber.min(targetInput, input);
// scale the clipped output inline with the input
const clippedOutput = clippedInput.dividedBy(input).times(output);
const adjustedOutput =
side === MarketOperation.Sell ? clippedOutput.minus(outputPenalty) : clippedOutput.plus(outputPenalty);
const adjustedRate =
side === MarketOperation.Sell ? adjustedOutput.div(clippedInput) : clippedInput.div(adjustedOutput);
// Optionally skip orders with rates that are <= 0.
if (filterNegativeAdjustedRateOrders && adjustedRate.lte(0)) {
continue;
}
fills.push({
sourcePathId,
adjustedRate,
adjustedOutput,
input: clippedInput,
output: clippedOutput,
flags: SOURCE_FLAGS[type === FillQuoteTransformerOrderType.Rfq ? 'RfqOrder' : 'LimitOrder'],
index: 0, // TBD
parent: undefined, // TBD
source: ERC20BridgeSource.Native,
type,
fillData: { ...o },
});
const { fillableTakerAmount, fillableTakerFeeAmount, fillableMakerAmount, type } = order;
const makerAmount = fillableMakerAmount;
const takerAmount = fillableTakerAmount.plus(fillableTakerFeeAmount);
const input = side === MarketOperation.Sell ? takerAmount : makerAmount;
const output = side === MarketOperation.Sell ? makerAmount : takerAmount;
const { fee, gas } =
fees[ERC20BridgeSource.Native] === undefined ? DEFAULT_FEE_ESTIMATE : fees[ERC20BridgeSource.Native]!(order);
const outputPenalty = ethToOutputAmount({
input,
output,
inputAmountPerEth,
outputAmountPerEth,
ethAmount: fee,
});
// targetInput can be less than the order size
// whilst the penalty is constant, it affects the adjusted output
// only up until the target has been exhausted.
// A large order and an order at the exact target should be penalized
// the same.
const clippedInput = BigNumber.min(targetInput, input);
// scale the clipped output inline with the input
const clippedOutput = clippedInput.dividedBy(input).times(output);
const adjustedOutput =
side === MarketOperation.Sell ? clippedOutput.minus(outputPenalty) : clippedOutput.plus(outputPenalty);
const adjustedRate =
side === MarketOperation.Sell ? adjustedOutput.div(clippedInput) : clippedInput.div(adjustedOutput);
// Optionally skip orders with rates that are <= 0.
if (filterNegativeAdjustedRateOrders && adjustedRate.lte(0)) {
return undefined;
}
// Sort by descending adjusted rate.
fills = fills.sort((a, b) => b.adjustedRate.comparedTo(a.adjustedRate));
// Re-index fills.
for (let i = 0; i < fills.length; ++i) {
fills[i].parent = i === 0 ? undefined : fills[i - 1];
fills[i].index = i;
}
return fills;
return {
sourcePathId,
adjustedOutput,
input: clippedInput,
output: clippedOutput,
flags: SOURCE_FLAGS[type === FillQuoteTransformerOrderType.Rfq ? 'RfqOrder' : 'LimitOrder'],
source: ERC20BridgeSource.Native,
type,
fillData: { ...order },
gas,
};
}
export function dexSamplesToFills(
export function dexSampleToFill(
side: MarketOperation,
samples: DexSample[],
sample: DexSample,
outputAmountPerEth: BigNumber,
inputAmountPerEth: BigNumber,
fees: FeeSchedule,
): Fill[] {
): Fill {
const sourcePathId = hexUtils.random();
const fills: Fill[] = [];
// Drop any non-zero entries. This can occur if the any fills on Kyber were UniswapReserves
// We need not worry about Kyber fills going to UniswapReserve as the input amount
// we fill is the same as we sampled. I.e we received [0,20,30] output from [1,2,3] input
// and we only fill [2,3] on Kyber (as 1 returns 0 output)
const nonzeroSamples = samples.filter(q => !q.output.isZero());
for (let i = 0; i < nonzeroSamples.length; i++) {
const sample = nonzeroSamples[i];
const prevSample = i === 0 ? undefined : nonzeroSamples[i - 1];
const { source, fillData } = sample;
const input = sample.input.minus(prevSample ? prevSample.input : 0);
const output = sample.output.minus(prevSample ? prevSample.output : 0);
let penalty = ZERO_AMOUNT;
if (i === 0) {
const fee = fees[source] === undefined ? 0 : fees[source]!(sample.fillData) || 0;
// Only the first fill in a DEX path incurs a penalty.
penalty = ethToOutputAmount({
input,
output,
inputAmountPerEth,
outputAmountPerEth,
ethAmount: fee,
});
}
const adjustedOutput = side === MarketOperation.Sell ? output.minus(penalty) : output.plus(penalty);
const { source, fillData } = sample;
const input = sample.input;
const output = sample.output;
const { fee, gas } =
fees[source] === undefined ? DEFAULT_FEE_ESTIMATE : fees[source]!(sample.fillData) || DEFAULT_FEE_ESTIMATE;
fills.push({
sourcePathId,
input,
output,
adjustedOutput,
source,
fillData,
type: FillQuoteTransformerOrderType.Bridge,
index: i,
parent: i !== 0 ? fills[fills.length - 1] : undefined,
flags: SOURCE_FLAGS[source],
});
}
return fills;
const penalty = ethToOutputAmount({
input,
output,
inputAmountPerEth,
outputAmountPerEth,
ethAmount: fee,
});
return {
sourcePathId,
input,
output,
adjustedOutput: adjustOutput(side, output, penalty),
source,
fillData,
type: FillQuoteTransformerOrderType.Bridge,
flags: SOURCE_FLAGS[source],
gas,
};
}
/**
* Adjusts the output depending on whether this is a buy or a sell.
*
* If it is a sell, than output is lowered by the adjustment.
* If it is a buy, than output is increased by adjustment.
*/
export function adjustOutput(side: MarketOperation, output: BigNumber, penalty: BigNumber): BigNumber {
return side === MarketOperation.Sell ? output.minus(penalty) : output.plus(penalty);
}

View File

@@ -0,0 +1,13 @@
import { BigNumber } from '@0x/utils';
import { MarketOperation } from '../../types';
import { Fill, FillAdjustor } from './types';
// tslint:disable:prefer-function-over-method
export class IdentityFillAdjustor implements FillAdjustor {
public adjustFills(side: MarketOperation, fills: Fill[], amount: BigNumber): Fill[] {
return fills;
}
}

View File

@@ -4,12 +4,15 @@ import * as _ from 'lodash';
import { DEFAULT_INFO_LOGGER, INVALID_SIGNATURE } from '../../constants';
import {
AltRfqMakerAssetOfferings,
AssetSwapperContractAddresses,
MarketOperation,
NativeOrderWithFillableAmounts,
SignedNativeOrder,
} from '../../types';
import { QuoteRequestor } from '../quote_requestor';
import { getAltMarketInfo } from '../alt_mm_implementation_utils';
import { QuoteRequestor, V4RFQIndicativeQuoteMM } from '../quote_requestor';
import { toSignedNativeOrder } from '../rfq_client_mappers';
import {
getNativeAdjustedFillableAmountsFromMakerAmount,
getNativeAdjustedFillableAmountsFromTakerAmount,
@@ -26,7 +29,6 @@ import {
PriceComparisonsReport,
QuoteReport,
} from './../quote_report_generator';
import { getComparisonPrices } from './comparison_price';
import {
BUY_SOURCE_FILTER_BY_CHAIN_ID,
@@ -38,19 +40,17 @@ import {
SOURCE_FLAGS,
ZERO_AMOUNT,
} from './constants';
import { createFills } from './fills';
import { IdentityFillAdjustor } from './identity_fill_adjustor';
import { getBestTwoHopQuote } from './multihop_utils';
import { createOrdersFromTwoHopSample } from './orders';
import { Path, PathPenaltyOpts } from './path';
import { findOptimalPathJSAsync, findOptimalRustPathFromSamples } from './path_optimizer';
import { findOptimalPathFromSamples } from './path_optimizer';
import { DexOrderSampler, getSampleAmounts } from './sampler';
import { SourceFilters } from './source_filters';
import {
AggregationError,
CollapsedFill,
DexSample,
ERC20BridgeSource,
Fill,
GenerateOptimizedOrdersOpts,
GetMarketOrdersOpts,
MarketSideLiquidity,
@@ -59,8 +59,6 @@ import {
OrderDomain,
} from './types';
const SHOULD_USE_RUST_ROUTER = process.env.RUST_ROUTER === 'true';
// tslint:disable:boolean-naming
export class MarketOperationUtils {
@@ -164,18 +162,20 @@ export class MarketOperationUtils {
// Get native order fillable amounts.
this._sampler.getLimitOrderFillableTakerAmounts(nativeOrders, this.contractAddresses.exchangeProxy),
// Get ETH -> maker token price.
this._sampler.getMedianSellRate(
this._sampler.getBestNativeTokenSellRate(
feeSourceFilters.sources,
makerToken,
this._nativeFeeToken,
this._nativeFeeTokenAmount,
_opts.feeSchedule,
),
// Get ETH -> taker token price.
this._sampler.getMedianSellRate(
this._sampler.getBestNativeTokenSellRate(
feeSourceFilters.sources,
takerToken,
this._nativeFeeToken,
this._nativeFeeTokenAmount,
_opts.feeSchedule,
),
// Get sell quotes for taker -> maker.
this._sampler.getSellQuotes(quoteSourceFilters.sources, makerToken, takerToken, sampleAmounts),
@@ -241,6 +241,7 @@ export class MarketOperationUtils {
dexQuotes,
},
isRfqSupported,
blockNumber: blockNumber.toNumber(),
};
}
@@ -269,22 +270,25 @@ export class MarketOperationUtils {
// Call the sampler contract.
const samplerPromise = this._sampler.executeAsync(
this._sampler.getBlockNumber(),
this._sampler.getTokenDecimals([makerToken, takerToken]),
// Get native order fillable amounts.
this._sampler.getLimitOrderFillableMakerAmounts(nativeOrders, this.contractAddresses.exchangeProxy),
// Get ETH -> makerToken token price.
this._sampler.getMedianSellRate(
this._sampler.getBestNativeTokenSellRate(
feeSourceFilters.sources,
makerToken,
this._nativeFeeToken,
this._nativeFeeTokenAmount,
_opts.feeSchedule,
),
// Get ETH -> taker token price.
this._sampler.getMedianSellRate(
this._sampler.getBestNativeTokenSellRate(
feeSourceFilters.sources,
takerToken,
this._nativeFeeToken,
this._nativeFeeTokenAmount,
_opts.feeSchedule,
),
// Get buy quotes for taker -> maker.
this._sampler.getBuyQuotes(quoteSourceFilters.sources, makerToken, takerToken, sampleAmounts),
@@ -302,6 +306,7 @@ export class MarketOperationUtils {
const [
[
blockNumber,
tokenDecimals,
orderFillableMakerAmounts,
ethToMakerAssetRate,
@@ -342,6 +347,7 @@ export class MarketOperationUtils {
dexQuotes,
},
isRfqSupported,
blockNumber: blockNumber.toNumber(),
};
}
@@ -372,15 +378,17 @@ export class MarketOperationUtils {
const feeSourceFilters = this._feeSources.exclude(_opts.excludedFeeSources);
const ops = [
this._sampler.getBlockNumber(),
...batchNativeOrders.map(orders =>
this._sampler.getLimitOrderFillableMakerAmounts(orders, this.contractAddresses.exchangeProxy),
),
...batchNativeOrders.map(orders =>
this._sampler.getMedianSellRate(
this._sampler.getBestNativeTokenSellRate(
feeSourceFilters.sources,
orders[0].order.takerToken,
this._nativeFeeToken,
this._nativeFeeTokenAmount,
_opts.feeSchedule,
),
),
...batchNativeOrders.map((orders, i) =>
@@ -396,13 +404,15 @@ export class MarketOperationUtils {
),
];
const executeResults = await this._sampler.executeBatchAsync(ops);
const [blockNumberRaw, ...executeResults] = await this._sampler.executeBatchAsync(ops);
const batchOrderFillableMakerAmounts = executeResults.splice(0, batchNativeOrders.length) as BigNumber[][];
const batchEthToTakerAssetRate = executeResults.splice(0, batchNativeOrders.length) as BigNumber[];
const batchDexQuotes = executeResults.splice(0, batchNativeOrders.length) as DexSample[][][];
const batchTokenDecimals = executeResults.splice(0, batchNativeOrders.length) as number[][];
const inputAmountPerEth = ZERO_AMOUNT;
const blockNumber: number = (blockNumberRaw as BigNumber).toNumber();
return Promise.all(
batchNativeOrders.map(async (nativeOrders, i) => {
if (nativeOrders.length === 0) {
@@ -435,6 +445,7 @@ export class MarketOperationUtils {
twoHopQuotes: [],
},
isRfqSupported: false,
blockNumber,
},
{
bridgeSlippage: _opts.bridgeSlippage,
@@ -444,6 +455,7 @@ export class MarketOperationUtils {
allowFallback: _opts.allowFallback,
gasPrice: _opts.gasPrice,
neonRouterNumSamples: _opts.neonRouterNumSamples,
fillAdjustor: _opts.fillAdjustor,
},
);
return optimizerResult;
@@ -505,60 +517,38 @@ export class MarketOperationUtils {
const takerAmountPerEth = side === MarketOperation.Sell ? inputAmountPerEth : outputAmountPerEth;
const makerAmountPerEth = side === MarketOperation.Sell ? outputAmountPerEth : inputAmountPerEth;
let fills: Fill[][];
// Find the optimal path using Rust router if enabled, otherwise fallback to JS Router
let optimalPath: Path | undefined;
if (SHOULD_USE_RUST_ROUTER) {
fills = [[]];
optimalPath = findOptimalRustPathFromSamples(
side,
dexQuotes,
[...nativeOrders, ...augmentedRfqtIndicativeQuotes],
inputAmount,
penaltyOpts,
opts.feeSchedule,
this._sampler.chainId,
opts.neonRouterNumSamples,
opts.samplerMetrics,
);
} else {
// Convert native orders and dex quotes into `Fill` objects.
fills = createFills({
side,
orders: [...nativeOrders, ...augmentedRfqtIndicativeQuotes],
dexQuotes,
targetInput: inputAmount,
outputAmountPerEth,
inputAmountPerEth,
excludedSources: opts.excludedSources,
feeSchedule: opts.feeSchedule,
});
optimalPath = findOptimalPathFromSamples(
side,
dexQuotes,
[...nativeOrders, ...augmentedRfqtIndicativeQuotes],
inputAmount,
penaltyOpts,
opts.feeSchedule,
this._sampler.chainId,
opts.neonRouterNumSamples,
opts.fillAdjustor,
opts.samplerMetrics,
);
optimalPath = await findOptimalPathJSAsync(
side,
fills,
inputAmount,
opts.runLimit,
opts.samplerMetrics,
penaltyOpts,
);
}
const optimalPathAdjustedRate = optimalPath ? optimalPath.adjustedRate() : ZERO_AMOUNT;
const optimalPathRate = optimalPath ? optimalPath.adjustedRate() : ZERO_AMOUNT;
const { adjustedRate: bestTwoHopRate, quote: bestTwoHopQuote } = getBestTwoHopQuote(
const { adjustedRate: bestTwoHopAdjustedRate, quote: bestTwoHopQuote } = getBestTwoHopQuote(
marketSideLiquidity,
opts.feeSchedule,
opts.exchangeProxyOverhead,
opts.fillAdjustor,
);
if (bestTwoHopQuote && bestTwoHopRate.isGreaterThan(optimalPathRate)) {
if (bestTwoHopQuote && bestTwoHopAdjustedRate.isGreaterThan(optimalPathAdjustedRate)) {
const twoHopOrders = createOrdersFromTwoHopSample(bestTwoHopQuote, orderOpts);
return {
optimizedOrders: twoHopOrders,
liquidityDelivered: bestTwoHopQuote,
sourceFlags: SOURCE_FLAGS[ERC20BridgeSource.MultiHop],
marketSideLiquidity,
adjustedRate: bestTwoHopRate,
adjustedRate: bestTwoHopAdjustedRate,
takerAmountPerEth,
makerAmountPerEth,
};
@@ -569,19 +559,14 @@ export class MarketOperationUtils {
throw new Error(AggregationError.NoOptimalPath);
}
// Generate a fallback path if required
// TODO(kimpers): Will experiment with disabling this and see how it affects revert rate
// to avoid yet another router roundtrip
// TODO: clean this up if we don't need it
// await this._addOptionalFallbackAsync(side, inputAmount, optimalPath, dexQuotes, fills, opts, penaltyOpts);
const collapsedPath = optimalPath.collapse(orderOpts);
const finalizedPath = optimalPath.finalize(orderOpts);
return {
optimizedOrders: collapsedPath.orders,
liquidityDelivered: collapsedPath.collapsedFills as CollapsedFill[],
sourceFlags: collapsedPath.sourceFlags,
optimizedOrders: finalizedPath.orders,
liquidityDelivered: finalizedPath.fills,
sourceFlags: finalizedPath.sourceFlags,
marketSideLiquidity,
adjustedRate: optimalPathRate,
adjustedRate: optimalPathAdjustedRate,
takerAmountPerEth,
makerAmountPerEth,
};
@@ -607,6 +592,7 @@ export class MarketOperationUtils {
gasPrice: _opts.gasPrice,
neonRouterNumSamples: _opts.neonRouterNumSamples,
samplerMetrics: _opts.samplerMetrics,
fillAdjustor: _opts.fillAdjustor,
};
if (nativeOrders.length === 0) {
@@ -619,9 +605,15 @@ export class MarketOperationUtils {
? this.getMarketSellLiquidityAsync.bind(this)
: this.getMarketBuyLiquidityAsync.bind(this);
const marketSideLiquidity: MarketSideLiquidity = await marketLiquidityFnAsync(nativeOrders, amount, _opts);
// Phase 1 Routing
// We find an optimized path for ALL the DEX and open-orderbook liquidity
let optimizerResult: OptimizerResult | undefined;
try {
optimizerResult = await this._generateOptimizedOrdersAsync(marketSideLiquidity, optimizerOpts);
optimizerResult = await this._generateOptimizedOrdersAsync(marketSideLiquidity, {
...optimizerOpts,
fillAdjustor: new IdentityFillAdjustor(),
});
} catch (e) {
// If no on-chain or off-chain Open Orderbook orders are present, a `NoOptimalPath` will be thrown.
// If this happens at this stage, there is still a chance that an RFQ order is fillable, therefore
@@ -645,6 +637,17 @@ export class MarketOperationUtils {
}
// If RFQ liquidity is enabled, make a request to check RFQ liquidity against the first optimizer result
// Phase 2 Routing
// Mix in any off-chain RFQ quotes
// Apply any fill adjustments i
const phaseTwoOptimizerOpts = {
...optimizerOpts,
// Pass in the FillAdjustor for Phase 2 adjustment, in the future we may perform this adjustment
// in Phase 1.
fillAdjustor: _opts.fillAdjustor,
};
const { rfqt } = _opts;
if (
marketSideLiquidity.isRfqSupported &&
@@ -655,17 +658,49 @@ export class MarketOperationUtils {
// Timing of RFQT lifecycle
const timeStart = new Date().getTime();
const { makerToken, takerToken } = nativeOrders[0].order;
// Filter Alt Rfq Maker Asset Offerings to the current pair
const filteredOfferings: AltRfqMakerAssetOfferings = {};
if (rfqt.altRfqAssetOfferings) {
const endpoints = Object.keys(rfqt.altRfqAssetOfferings);
for (const endpoint of endpoints) {
// Get the current pair if being offered
const offering = getAltMarketInfo(rfqt.altRfqAssetOfferings[endpoint], makerToken, takerToken);
if (offering) {
filteredOfferings[endpoint] = [offering];
}
}
}
if (rfqt.isIndicative) {
// An indicative quote is being requested, and indicative quotes price-aware enabled
// Make the RFQT request and then re-run the sampler if new orders come back.
const indicativeQuotes = await rfqt.quoteRequestor.requestRfqtIndicativeQuotesAsync(
makerToken,
takerToken,
amount,
side,
wholeOrderPrice,
rfqt,
);
const indicativeQuotes =
rfqt.rfqClient !== undefined
? ((
await rfqt.rfqClient.getV1PricesAsync({
altRfqAssetOfferings: filteredOfferings,
assetFillAmount: amount,
chainId: this._sampler.chainId,
comparisonPrice: wholeOrderPrice,
integratorId: rfqt.integrator.integratorId,
intentOnFilling: rfqt.intentOnFilling,
makerToken,
marketOperation: side,
takerAddress: rfqt.takerAddress,
takerToken,
txOrigin: rfqt.txOrigin,
})
).prices as V4RFQIndicativeQuoteMM[])
: await rfqt.quoteRequestor.requestRfqtIndicativeQuotesAsync(
makerToken,
takerToken,
amount,
side,
wholeOrderPrice,
rfqt,
);
const deltaTime = new Date().getTime() - timeStart;
DEFAULT_INFO_LOGGER({
rfqQuoteType: 'indicative',
@@ -673,20 +708,57 @@ export class MarketOperationUtils {
});
// Re-run optimizer with the new indicative quote
if (indicativeQuotes.length > 0) {
// Attach the indicative quotes to the market side liquidity
marketSideLiquidity.quotes.rfqtIndicativeQuotes = indicativeQuotes;
optimizerResult = await this._generateOptimizedOrdersAsync(marketSideLiquidity, optimizerOpts);
// Phase 2 Routing
const phase1OptimalSources = optimizerResult
? optimizerResult.optimizedOrders.map(o => o.source)
: [];
const phase2MarketSideLiquidity: MarketSideLiquidity = {
...marketSideLiquidity,
quotes: {
...marketSideLiquidity.quotes,
// Select only the quotes that were chosen in Phase 1
dexQuotes: marketSideLiquidity.quotes.dexQuotes.filter(
q => q.length > 0 && phase1OptimalSources.includes(q[0].source),
),
},
};
optimizerResult = await this._generateOptimizedOrdersAsync(
phase2MarketSideLiquidity,
phaseTwoOptimizerOpts,
);
}
} else {
// A firm quote is being requested, and firm quotes price-aware enabled.
// Ensure that `intentOnFilling` is enabled and make the request.
const firmQuotes = await rfqt.quoteRequestor.requestRfqtFirmQuotesAsync(
makerToken,
takerToken,
amount,
side,
wholeOrderPrice,
rfqt,
);
const firmQuotes =
rfqt.rfqClient !== undefined
? (
await rfqt.rfqClient.getV1QuotesAsync({
altRfqAssetOfferings: filteredOfferings,
assetFillAmount: amount,
chainId: this._sampler.chainId,
comparisonPrice: wholeOrderPrice,
integratorId: rfqt.integrator.integratorId,
intentOnFilling: rfqt.intentOnFilling,
makerToken,
marketOperation: side,
takerAddress: rfqt.takerAddress,
takerToken,
txOrigin: rfqt.txOrigin,
})
).quotes.map(toSignedNativeOrder)
: await rfqt.quoteRequestor.requestRfqtFirmQuotesAsync(
makerToken,
takerToken,
amount,
side,
wholeOrderPrice,
rfqt,
);
const deltaTime = new Date().getTime() - timeStart;
DEFAULT_INFO_LOGGER({
rfqQuoteType: 'firm',
@@ -715,6 +787,8 @@ export class MarketOperationUtils {
fillableTakerFeeAmount: ZERO_AMOUNT,
}),
);
// Attach the firm RFQt quotes to the market side liquidity
marketSideLiquidity.quotes.nativeOrders = [
...quotesWithOrderFillableAmounts,
...marketSideLiquidity.quotes.nativeOrders,
@@ -723,7 +797,27 @@ export class MarketOperationUtils {
// Re-run optimizer with the new firm quote. This is the second and last time
// we run the optimized in a block of code. In this case, we don't catch a potential `NoOptimalPath` exception
// and we let it bubble up if it happens.
optimizerResult = await this._generateOptimizedOrdersAsync(marketSideLiquidity, optimizerOpts);
// Phase 2 Routing
// Optimization: Filter by what is already currently in the Phase1 output as it doesn't
// seem possible that inclusion of RFQT could impact the sources chosen from Phase 1.
const phase1OptimalSources = optimizerResult
? optimizerResult.optimizedOrders.map(o => o.source)
: [];
const phase2MarketSideLiquidity: MarketSideLiquidity = {
...marketSideLiquidity,
quotes: {
...marketSideLiquidity.quotes,
// Select only the quotes that were chosen in Phase 1
dexQuotes: marketSideLiquidity.quotes.dexQuotes.filter(
q => q.length > 0 && phase1OptimalSources.includes(q[0].source),
),
},
};
optimizerResult = await this._generateOptimizedOrdersAsync(
phase2MarketSideLiquidity,
phaseTwoOptimizerOpts,
);
}
}
}
@@ -767,84 +861,10 @@ export class MarketOperationUtils {
}
private async _refreshPoolCacheIfRequiredAsync(takerToken: string, makerToken: string): Promise<void> {
void Promise.all(
Object.values(this._sampler.poolsCaches).map(async cache => {
if (cache.isFresh(takerToken, makerToken)) {
return Promise.resolve([]);
}
return cache.getFreshPoolsForPairAsync(takerToken, makerToken);
}),
);
_.values(this._sampler.poolsCaches)
.filter(cache => cache !== undefined && !cache.isFresh(takerToken, makerToken))
.forEach(cache => cache?.getFreshPoolsForPairAsync(takerToken, makerToken));
}
/*
* TODO(kimpers): Remove this when we know that it's safe to drop the fallbacks on native orders
// tslint:disable-next-line: prefer-function-over-method
private async _addOptionalFallbackAsync(
side: MarketOperation,
inputAmount: BigNumber,
optimalPath: Path,
dexQuotes: DexSample[][],
fills: Fill[][],
opts: GenerateOptimizedOrdersOpts,
penaltyOpts: PathPenaltyOpts,
): Promise<void> {
const maxFallbackSlippage = opts.maxFallbackSlippage || 0;
const optimalPathRate = optimalPath ? optimalPath.adjustedRate() : ZERO_AMOUNT;
// Generate a fallback path if sources requiring a fallback (fragile) are in the optimal path.
// Native is relatively fragile (limit order collision, expiry, or lack of available maker balance)
// LiquidityProvider is relatively fragile (collision)
const fragileSources = [ERC20BridgeSource.Native, ERC20BridgeSource.LiquidityProvider];
const fragileFills = optimalPath.fills.filter(f => fragileSources.includes(f.source));
if (opts.allowFallback && fragileFills.length !== 0) {
// We create a fallback path that is exclusive of Native liquidity
// This is the optimal on-chain path for the entire input amount
const sturdyPenaltyOpts = {
...penaltyOpts,
exchangeProxyOverhead: (sourceFlags: bigint) =>
// tslint:disable-next-line: no-bitwise
penaltyOpts.exchangeProxyOverhead(sourceFlags | optimalPath.sourceFlags),
};
let sturdyOptimalPath: Path | undefined;
if (SHOULD_USE_RUST_ROUTER) {
const sturdySamples = dexQuotes.filter(
samples => samples.length > 0 && !fragileSources.includes(samples[0].source),
);
sturdyOptimalPath = findOptimalRustPathFromSamples(
side,
sturdySamples,
[],
inputAmount,
sturdyPenaltyOpts,
opts.feeSchedule,
this._sampler.chainId,
opts.neonRouterNumSamples,
undefined, // hack: set sampler metrics to undefined to avoid fallback timings
);
} else {
const sturdyFills = fills.filter(p => p.length > 0 && !fragileSources.includes(p[0].source));
sturdyOptimalPath = await findOptimalPathJSAsync(
side,
sturdyFills,
inputAmount,
opts.runLimit,
undefined, // hack: set sampler metrics to undefined to avoid fallback timings
sturdyPenaltyOpts,
);
}
// Calculate the slippage of on-chain sources compared to the most optimal path
// if within an acceptable threshold we enable a fallback to prevent reverts
if (
sturdyOptimalPath !== undefined &&
(fragileFills.length === optimalPath.fills.length ||
sturdyOptimalPath.adjustedSlippage(optimalPathRate) <= maxFallbackSlippage)
) {
optimalPath.addFallback(sturdyOptimalPath);
}
}
}
*/
}
// tslint:disable: max-file-line-count

View File

@@ -9,28 +9,11 @@ import {
DexSample,
ExchangeProxyOverhead,
FeeSchedule,
FillAdjustor,
MarketSideLiquidity,
MultiHopFillData,
TokenAdjacencyGraph,
} from './types';
/**
* Given a token pair, returns the intermediate tokens to consider for two-hop routes.
*/
export function getIntermediateTokens(
makerToken: string,
takerToken: string,
tokenAdjacencyGraph: TokenAdjacencyGraph,
): string[] {
const intermediateTokens = _.union(
_.get(tokenAdjacencyGraph, takerToken, tokenAdjacencyGraph.default),
_.get(tokenAdjacencyGraph, makerToken, tokenAdjacencyGraph.default),
);
return _.uniqBy(intermediateTokens, a => a.toLowerCase()).filter(
token => token.toLowerCase() !== makerToken.toLowerCase() && token.toLowerCase() !== takerToken.toLowerCase(),
);
}
/**
* Returns the best two-hop quote and the fee-adjusted rate of that quote.
*/
@@ -38,6 +21,7 @@ export function getBestTwoHopQuote(
marketSideLiquidity: Omit<MarketSideLiquidity, 'makerTokenDecimals' | 'takerTokenDecimals'>,
feeSchedule?: FeeSchedule,
exchangeProxyOverhead?: ExchangeProxyOverhead,
fillAdjustor?: FillAdjustor,
): { quote: DexSample<MultiHopFillData> | undefined; adjustedRate: BigNumber } {
const { side, inputAmount, outputAmountPerEth, quotes } = marketSideLiquidity;
const { twoHopQuotes } = quotes;
@@ -57,7 +41,15 @@ export function getBestTwoHopQuote(
}
const best = filteredQuotes
.map(quote =>
getTwoHopAdjustedRate(side, quote, inputAmount, outputAmountPerEth, feeSchedule, exchangeProxyOverhead),
getTwoHopAdjustedRate(
side,
quote,
inputAmount,
outputAmountPerEth,
feeSchedule,
exchangeProxyOverhead,
fillAdjustor,
),
)
.reduce(
(prev, curr, i) =>
@@ -70,6 +62,7 @@ export function getBestTwoHopQuote(
outputAmountPerEth,
feeSchedule,
exchangeProxyOverhead,
fillAdjustor,
),
quote: filteredQuotes[0],
},

Some files were not shown because too many files have changed in this diff Show More