Compare commits
15 Commits
@0x/asset-
...
@0x/asset-
Author | SHA1 | Date | |
---|---|---|---|
|
297c73abcc | ||
|
4c9e1b21ec | ||
|
41685d1545 | ||
|
b9c25112ed | ||
|
f0738fc122 | ||
|
42baf504b7 | ||
|
56038d122f | ||
|
c4446b6c0e | ||
|
eaed2958c3 | ||
|
a045a3afb8 | ||
|
1cc59ab1ab | ||
|
2c6a714b71 | ||
|
d8c97d6720 | ||
|
d6bc702550 | ||
|
2838cb9420 |
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "3.3.32",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "3.3.31",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.3.32 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.31 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-erc20",
|
||||
"version": "3.3.31",
|
||||
"version": "3.3.32",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -53,8 +53,8 @@
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-test-utils": "^5.4.22",
|
||||
"@0x/contracts-utils": "^4.8.12",
|
||||
"@0x/contracts-test-utils": "^5.4.23",
|
||||
"@0x/contracts-utils": "^4.8.13",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/ts-doc-gen": "^0.0.28",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "5.4.23",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "5.4.22",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v5.4.23 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.22 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-test-utils",
|
||||
"version": "5.4.22",
|
||||
"version": "5.4.23",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,7 +44,7 @@
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.34",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/contract-addresses": "^6.15.0",
|
||||
"@0x/contract-addresses": "^6.16.0",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/json-schemas": "^6.4.4",
|
||||
"@0x/order-utils": "^10.4.28",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "1.4.15",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "1.4.14",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.4.15 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.14 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-treasury",
|
||||
"version": "1.4.14",
|
||||
"version": "1.4.15",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -47,12 +47,12 @@
|
||||
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/treasury",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contract-addresses": "^6.15.0",
|
||||
"@0x/contract-addresses": "^6.16.0",
|
||||
"@0x/contracts-asset-proxy": "^3.7.19",
|
||||
"@0x/contracts-erc20": "^3.3.31",
|
||||
"@0x/contracts-erc20": "^3.3.32",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-staking": "^2.0.45",
|
||||
"@0x/contracts-test-utils": "^5.4.22",
|
||||
"@0x/contracts-test-utils": "^5.4.23",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/ts-doc-gen": "^0.0.28",
|
||||
"@0x/tslint-config": "^4.1.4",
|
||||
@@ -73,7 +73,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/protocol-utils": "^11.14.0",
|
||||
"@0x/protocol-utils": "^11.15.0",
|
||||
"@0x/subproviders": "^6.6.5",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "4.8.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "4.8.12",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v4.8.13 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.12 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-utils",
|
||||
"version": "4.8.12",
|
||||
"version": "4.8.13",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -52,7 +52,7 @@
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-test-utils": "^5.4.22",
|
||||
"@0x/contracts-test-utils": "^5.4.23",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/order-utils": "^10.4.28",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "0.35.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Adds support for Velodrome OptimismBridgeAdapter",
|
||||
"pr": 494
|
||||
}
|
||||
],
|
||||
"timestamp": 1655244958
|
||||
},
|
||||
{
|
||||
"version": "0.34.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.35.0 - _June 14, 2022_
|
||||
|
||||
* Adds support for Velodrome OptimismBridgeAdapter (#494)
|
||||
|
||||
## v0.34.0 - _June 3, 2022_
|
||||
|
||||
* Splits BridgeAdapter up by chain (#487)
|
||||
|
@@ -56,4 +56,5 @@ library BridgeProtocols {
|
||||
uint128 internal constant GMX = 26;
|
||||
uint128 internal constant PLATYPUS = 27;
|
||||
uint128 internal constant BANCORV3 = 28;
|
||||
uint128 internal constant VELODROME = 29;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinUniswapV3.sol";
|
||||
import "./mixins/MixinVelodrome.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract OptimismBridgeAdapter is
|
||||
@@ -34,6 +35,7 @@ contract OptimismBridgeAdapter is
|
||||
MixinCurveV2,
|
||||
MixinNerve,
|
||||
MixinUniswapV3,
|
||||
MixinVelodrome,
|
||||
MixinZeroExBridge
|
||||
{
|
||||
constructor(IEtherTokenV06 weth)
|
||||
@@ -83,6 +85,14 @@ contract OptimismBridgeAdapter is
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.VELODROME) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeVelodrome(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
|
@@ -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];
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-zero-ex",
|
||||
"version": "0.34.0",
|
||||
"version": "0.35.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -43,7 +43,7 @@
|
||||
"config": {
|
||||
"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/@(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|MixinUniswap|MixinUniswapV2|MixinUniswapV3|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"
|
||||
"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|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",
|
||||
@@ -56,10 +56,10 @@
|
||||
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/zero-ex",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contract-addresses": "^6.15.0",
|
||||
"@0x/contracts-erc20": "^3.3.31",
|
||||
"@0x/contract-addresses": "^6.16.0",
|
||||
"@0x/contracts-erc20": "^3.3.32",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-test-utils": "^5.4.22",
|
||||
"@0x/contracts-test-utils": "^5.4.23",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/order-utils": "^10.4.28",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
@@ -83,7 +83,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/protocol-utils": "^11.14.0",
|
||||
"@0x/protocol-utils": "^11.15.0",
|
||||
"@0x/subproviders": "^6.6.5",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
|
@@ -127,6 +127,7 @@ import * as MixinShell from '../test/generated-artifacts/MixinShell.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';
|
||||
@@ -349,6 +350,7 @@ export const artifacts = {
|
||||
MixinUniswap: MixinUniswap as ContractArtifact,
|
||||
MixinUniswapV2: MixinUniswapV2 as ContractArtifact,
|
||||
MixinUniswapV3: MixinUniswapV3 as ContractArtifact,
|
||||
MixinVelodrome: MixinVelodrome as ContractArtifact,
|
||||
MixinZeroExBridge: MixinZeroExBridge as ContractArtifact,
|
||||
IERC1155Token: IERC1155Token as ContractArtifact,
|
||||
IERC721Token: IERC721Token as ContractArtifact,
|
||||
|
@@ -125,6 +125,7 @@ export * from '../test/generated-wrappers/mixin_shell';
|
||||
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';
|
||||
|
@@ -164,6 +164,7 @@
|
||||
"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",
|
||||
|
@@ -1,4 +1,44 @@
|
||||
[
|
||||
{
|
||||
"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": [
|
||||
|
@@ -5,6 +5,19 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## 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)
|
||||
|
@@ -44,6 +44,7 @@ import "./TwoHopSampler.sol";
|
||||
import "./UniswapSampler.sol";
|
||||
import "./UniswapV2Sampler.sol";
|
||||
import "./UniswapV3Sampler.sol";
|
||||
import "./VelodromeSampler.sol";
|
||||
import "./UtilitySampler.sol";
|
||||
|
||||
|
||||
@@ -72,6 +73,7 @@ contract ERC20BridgeSampler is
|
||||
UniswapSampler,
|
||||
UniswapV2Sampler,
|
||||
UniswapV3Sampler,
|
||||
VelodromeSampler,
|
||||
UtilitySampler
|
||||
{
|
||||
|
||||
|
134
packages/asset-swapper/contracts/src/VelodromeSampler.sol
Normal file
134
packages/asset-swapper/contracts/src/VelodromeSampler.sol
Normal 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);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/asset-swapper",
|
||||
"version": "16.61.0",
|
||||
"version": "16.62.1",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -40,7 +40,7 @@
|
||||
"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|BalancerV2BatchSampler|BalancerV2Common|BalancerV2Sampler|BancorSampler|BancorV3Sampler|CompoundSampler|CurveSampler|DODOSampler|DODOV2Sampler|ERC20BridgeSampler|FakeTaker|GMXSampler|IBalancer|IBalancerV2Vault|IBancor|IBancorV3|ICurve|IGMX|IMStable|IMooniswap|IMultiBridge|IPlatypus|IShell|ISmoothy|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|NativeOrderSampler|PlatypusSampler|SamplerUtils|ShellSampler|SmoothySampler|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|ISmoothy|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|NativeOrderSampler|PlatypusSampler|SamplerUtils|ShellSampler|SmoothySampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler|VelodromeSampler).json",
|
||||
"postpublish": {
|
||||
"assets": []
|
||||
}
|
||||
@@ -61,14 +61,14 @@
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.34",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/contract-addresses": "^6.15.0",
|
||||
"@0x/contract-wrappers": "^13.20.3",
|
||||
"@0x/contracts-erc20": "^3.3.31",
|
||||
"@0x/contracts-zero-ex": "^0.34.0",
|
||||
"@0x/contract-addresses": "^6.16.0",
|
||||
"@0x/contract-wrappers": "^13.20.4",
|
||||
"@0x/contracts-erc20": "^3.3.32",
|
||||
"@0x/contracts-zero-ex": "^0.35.0",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/json-schemas": "^6.4.4",
|
||||
"@0x/neon-router": "^0.3.5",
|
||||
"@0x/protocol-utils": "^11.14.0",
|
||||
"@0x/protocol-utils": "^11.15.0",
|
||||
"@0x/quote-server": "^6.0.6",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
@@ -100,8 +100,8 @@
|
||||
"@0x/contracts-exchange": "^3.2.38",
|
||||
"@0x/contracts-exchange-libs": "^4.3.37",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-test-utils": "^5.4.22",
|
||||
"@0x/contracts-utils": "^4.8.12",
|
||||
"@0x/contracts-test-utils": "^5.4.23",
|
||||
"@0x/contracts-utils": "^4.8.13",
|
||||
"@0x/mesh-rpc-client": "^9.4.2",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/subproviders": "^6.6.5",
|
||||
|
@@ -75,9 +75,7 @@ const PANCAKE_SWAP_FORKS = [
|
||||
ERC20BridgeSource.BakerySwap,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.CafeSwap,
|
||||
ERC20BridgeSource.CheeseSwap,
|
||||
ERC20BridgeSource.JulSwap,
|
||||
];
|
||||
const FAKE_PROVIDER: any = {
|
||||
sendAsync(): void {
|
||||
@@ -222,9 +220,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
ERC20BridgeSource.BakerySwap,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.CafeSwap,
|
||||
ERC20BridgeSource.CheeseSwap,
|
||||
ERC20BridgeSource.JulSwap,
|
||||
])
|
||||
) {
|
||||
const source = slippedOrders[0].source;
|
||||
|
@@ -7,7 +7,6 @@ import {
|
||||
BAKERYSWAP_ROUTER_BY_CHAIN_ID,
|
||||
BELT_BSC_INFOS,
|
||||
BISWAP_ROUTER_BY_CHAIN_ID,
|
||||
CAFESWAP_ROUTER_BY_CHAIN_ID,
|
||||
CHEESESWAP_ROUTER_BY_CHAIN_ID,
|
||||
COMETHSWAP_ROUTER_BY_CHAIN_ID,
|
||||
COMPONENT_POOLS_BY_CHAIN_ID,
|
||||
@@ -26,9 +25,9 @@ import {
|
||||
FIREBIRDONESWAP_BSC_INFOS,
|
||||
FIREBIRDONESWAP_POLYGON_INFOS,
|
||||
IRONSWAP_POLYGON_INFOS,
|
||||
JETSWAP_ROUTER_BY_CHAIN_ID,
|
||||
JULSWAP_ROUTER_BY_CHAIN_ID,
|
||||
KNIGHTSWAP_ROUTER_BY_CHAIN_ID,
|
||||
MAX_DODOV2_POOLS_QUERIED,
|
||||
MDEX_ROUTER_BY_CHAIN_ID,
|
||||
MESHSWAP_ROUTER_BY_CHAIN_ID,
|
||||
MOBIUSMONEY_CELO_INFOS,
|
||||
MORPHEUSSWAP_ROUTER_BY_CHAIN_ID,
|
||||
@@ -39,7 +38,6 @@ import {
|
||||
PANCAKESWAPV2_ROUTER_BY_CHAIN_ID,
|
||||
PANGOLIN_ROUTER_BY_CHAIN_ID,
|
||||
PLATYPUS_AVALANCHE_INFOS,
|
||||
POLYDEX_ROUTER_BY_CHAIN_ID,
|
||||
QUICKSWAP_ROUTER_BY_CHAIN_ID,
|
||||
SADDLE_MAINNET_INFOS,
|
||||
SHELL_POOLS_BY_CHAIN_ID,
|
||||
@@ -527,16 +525,12 @@ 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
|
||||
@@ -545,6 +539,8 @@ export function uniswapV2LikeRouterAddress(
|
||||
| ERC20BridgeSource.SpiritSwap
|
||||
| ERC20BridgeSource.BiSwap
|
||||
| ERC20BridgeSource.Yoshi
|
||||
| ERC20BridgeSource.MDex
|
||||
| ERC20BridgeSource.KnightSwap
|
||||
| ERC20BridgeSource.MeshSwap,
|
||||
): string {
|
||||
switch (source) {
|
||||
@@ -562,12 +558,8 @@ 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:
|
||||
@@ -576,12 +568,8 @@ export function uniswapV2LikeRouterAddress(
|
||||
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:
|
||||
@@ -600,6 +588,10 @@ export function uniswapV2LikeRouterAddress(
|
||||
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}`);
|
||||
}
|
||||
|
@@ -137,16 +137,15 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.Smoothy,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.CafeSwap,
|
||||
ERC20BridgeSource.CheeseSwap,
|
||||
ERC20BridgeSource.JulSwap,
|
||||
ERC20BridgeSource.LiquidityProvider,
|
||||
ERC20BridgeSource.WaultSwap,
|
||||
ERC20BridgeSource.FirebirdOneSwap,
|
||||
ERC20BridgeSource.JetSwap,
|
||||
ERC20BridgeSource.ACryptos,
|
||||
ERC20BridgeSource.KyberDmm,
|
||||
ERC20BridgeSource.BiSwap,
|
||||
ERC20BridgeSource.MDex,
|
||||
ERC20BridgeSource.KnightSwap,
|
||||
]),
|
||||
[ChainId.Polygon]: new SourceFilters([
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
@@ -159,14 +158,12 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Dodo,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.WaultSwap,
|
||||
ERC20BridgeSource.Polydex,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.FirebirdOneSwap,
|
||||
ERC20BridgeSource.BalancerV2,
|
||||
ERC20BridgeSource.KyberDmm,
|
||||
ERC20BridgeSource.LiquidityProvider,
|
||||
ERC20BridgeSource.MultiHop,
|
||||
ERC20BridgeSource.JetSwap,
|
||||
ERC20BridgeSource.IronSwap,
|
||||
ERC20BridgeSource.AaveV2,
|
||||
ERC20BridgeSource.UniswapV3,
|
||||
@@ -192,7 +189,6 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Curve,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.Geist,
|
||||
ERC20BridgeSource.JetSwap,
|
||||
ERC20BridgeSource.MorpheusSwap,
|
||||
ERC20BridgeSource.SpiritSwap,
|
||||
ERC20BridgeSource.SpookySwap,
|
||||
@@ -212,6 +208,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Curve,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.MultiHop,
|
||||
ERC20BridgeSource.Velodrome,
|
||||
]),
|
||||
},
|
||||
new SourceFilters([]),
|
||||
@@ -283,16 +280,15 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.Smoothy,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.CafeSwap,
|
||||
ERC20BridgeSource.CheeseSwap,
|
||||
ERC20BridgeSource.JulSwap,
|
||||
ERC20BridgeSource.LiquidityProvider,
|
||||
ERC20BridgeSource.WaultSwap,
|
||||
ERC20BridgeSource.FirebirdOneSwap,
|
||||
ERC20BridgeSource.JetSwap,
|
||||
ERC20BridgeSource.ACryptos,
|
||||
ERC20BridgeSource.KyberDmm,
|
||||
ERC20BridgeSource.BiSwap,
|
||||
ERC20BridgeSource.MDex,
|
||||
ERC20BridgeSource.KnightSwap,
|
||||
]),
|
||||
[ChainId.Polygon]: new SourceFilters([
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
@@ -305,14 +301,12 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Dodo,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.WaultSwap,
|
||||
ERC20BridgeSource.Polydex,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.FirebirdOneSwap,
|
||||
ERC20BridgeSource.BalancerV2,
|
||||
ERC20BridgeSource.KyberDmm,
|
||||
ERC20BridgeSource.LiquidityProvider,
|
||||
ERC20BridgeSource.MultiHop,
|
||||
ERC20BridgeSource.JetSwap,
|
||||
ERC20BridgeSource.IronSwap,
|
||||
ERC20BridgeSource.AaveV2,
|
||||
ERC20BridgeSource.UniswapV3,
|
||||
@@ -338,7 +332,6 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Curve,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.Geist,
|
||||
ERC20BridgeSource.JetSwap,
|
||||
ERC20BridgeSource.MorpheusSwap,
|
||||
ERC20BridgeSource.SpiritSwap,
|
||||
ERC20BridgeSource.SpookySwap,
|
||||
@@ -358,6 +351,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Curve,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.MultiHop,
|
||||
ERC20BridgeSource.Velodrome,
|
||||
]),
|
||||
},
|
||||
new SourceFilters([]),
|
||||
@@ -873,7 +867,6 @@ export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
|
||||
POLYGON_TOKENS.DAI,
|
||||
POLYGON_TOKENS.USDT,
|
||||
POLYGON_TOKENS.WBTC,
|
||||
POLYGON_TOKENS.nUSD,
|
||||
],
|
||||
[ChainId.Avalanche]: [
|
||||
AVALANCHE_TOKENS.WAVAX,
|
||||
@@ -1973,6 +1966,20 @@ export const BISWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const MDEX_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.BSC]: '0x7dae51bd3e3376b8c7c4900e9107f12be3af1ba8',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const KNIGHTSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.BSC]: '0x05e61e0cdcd2170a76f9568a110cee3afdd6c46f',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const MOONISWAP_REGISTRIES_BY_CHAIN_ID = valueByChainId(
|
||||
{
|
||||
[ChainId.Mainnet]: ['0xbaf9a5d4b0052359326a6cdab54babaa3a3a9643'],
|
||||
@@ -2252,13 +2259,6 @@ export const APESWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const CAFESWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.BSC]: '0x933daea3a5995fb94b14a7696a5f3ffd7b1e385a',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const CHEESESWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.BSC]: '0x3047799262d8d2ef41ed2a222205968bc9b0d895',
|
||||
@@ -2266,13 +2266,6 @@ export const CHEESESWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const JULSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.BSC]: '0xbd67d157502a23309db761c41965600c2ec788b2',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
//
|
||||
// Polygon
|
||||
//
|
||||
@@ -2305,13 +2298,6 @@ export const WAULTSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const POLYDEX_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Polygon]: '0xe5c67ba380fb2f70a47b489e94bced486bb8fb74',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const MESHSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Polygon]: '0x10f4a785f458bc144e3706575924889954946639',
|
||||
@@ -2319,15 +2305,6 @@ export const MESHSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const JETSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.BSC]: '0xbe65b8f75b9f20f4c522e0067a3887fada714800',
|
||||
[ChainId.Polygon]: '0x5c6ec38fb0e2609672bdf628b1fd605a523e5923',
|
||||
[ChainId.Fantom]: '0x845e76a8691423fbc4ecb8dd77556cb61c09ee25',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const PANGOLIN_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Avalanche]: '0xe54ca86531e17ef3616d22ca28b0d458b6c89106',
|
||||
@@ -2405,6 +2382,13 @@ export const YOSHI_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const VELODROME_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Optimism]: '0xa132dab612db5cb9fc9ac426a0cc215a3423f9c9',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const VIP_ERC20_BRIDGE_SOURCES_BY_CHAIN_ID = valueByChainId<ERC20BridgeSource[]>(
|
||||
{
|
||||
[ChainId.Mainnet]: [
|
||||
@@ -2421,9 +2405,7 @@ export const VIP_ERC20_BRIDGE_SOURCES_BY_CHAIN_ID = valueByChainId<ERC20BridgeSo
|
||||
ERC20BridgeSource.BakerySwap,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.CafeSwap,
|
||||
ERC20BridgeSource.CheeseSwap,
|
||||
ERC20BridgeSource.JulSwap,
|
||||
ERC20BridgeSource.LiquidityProvider,
|
||||
ERC20BridgeSource.Native,
|
||||
],
|
||||
@@ -2480,6 +2462,8 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
|
||||
[ERC20BridgeSource.CryptoCom]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.ShibaSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.BiSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.MDex]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.KnightSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.Balancer]: () => 120e3,
|
||||
[ERC20BridgeSource.BalancerV2]: (fillData?: FillData) => {
|
||||
return 100e3 + ((fillData as BalancerV2BatchSwapFillData).swapSteps.length - 1) * 50e3;
|
||||
@@ -2597,9 +2581,7 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
|
||||
[ERC20BridgeSource.PancakeSwapV2]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.BakerySwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.ApeSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.CafeSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.CheeseSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.JulSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.WaultSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.ACryptos]: fillData => (fillData as CurveFillData).pool.gasSchedule,
|
||||
|
||||
@@ -2609,8 +2591,6 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
|
||||
[ERC20BridgeSource.QuickSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.ComethSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.Dfyn]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.Polydex]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.JetSwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.MeshSwap]: uniswapV2CloneGasSchedule,
|
||||
|
||||
//
|
||||
@@ -2634,6 +2614,11 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
|
||||
[ERC20BridgeSource.SpookySwap]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.Yoshi]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.Beethovenx]: () => 100e3,
|
||||
|
||||
//
|
||||
// Optimism
|
||||
//
|
||||
[ERC20BridgeSource.Velodrome]: () => 160e3,
|
||||
};
|
||||
|
||||
export const DEFAULT_FEE_SCHEDULE: Required<FeeSchedule> = { ...DEFAULT_GAS_SCHEDULE };
|
||||
|
@@ -40,6 +40,7 @@ import {
|
||||
UniswapV2FillData,
|
||||
UniswapV3FillData,
|
||||
UniswapV3PathAmount,
|
||||
VelodromeFillData,
|
||||
} from './types';
|
||||
|
||||
// tslint:disable completed-docs
|
||||
@@ -142,12 +143,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
|
||||
return encodeBridgeSourceId(BridgeProtocol.Curve, 'xSigma');
|
||||
case ERC20BridgeSource.ApeSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'ApeSwap');
|
||||
case ERC20BridgeSource.CafeSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'CafeSwap');
|
||||
case ERC20BridgeSource.CheeseSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'CheeseSwap');
|
||||
case ERC20BridgeSource.JulSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'JulSwap');
|
||||
case ERC20BridgeSource.UniswapV3:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV3, 'UniswapV3');
|
||||
case ERC20BridgeSource.KyberDmm:
|
||||
@@ -162,16 +159,12 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
|
||||
return encodeBridgeSourceId(BridgeProtocol.CurveV2, 'CurveV2');
|
||||
case ERC20BridgeSource.WaultSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'WaultSwap');
|
||||
case ERC20BridgeSource.Polydex:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'Polydex');
|
||||
case ERC20BridgeSource.FirebirdOneSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'FirebirdOneSwap');
|
||||
case ERC20BridgeSource.Lido:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Lido, 'Lido');
|
||||
case ERC20BridgeSource.ShibaSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'ShibaSwap');
|
||||
case ERC20BridgeSource.JetSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'JetSwap');
|
||||
case ERC20BridgeSource.IronSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'IronSwap');
|
||||
case ERC20BridgeSource.ACryptos:
|
||||
@@ -202,6 +195,10 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
|
||||
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'MobiusMoney');
|
||||
case ERC20BridgeSource.BiSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'BiSwap');
|
||||
case ERC20BridgeSource.MDex:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'MDex');
|
||||
case ERC20BridgeSource.KnightSwap:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'KnightSwap');
|
||||
case ERC20BridgeSource.GMX:
|
||||
return encodeBridgeSourceId(BridgeProtocol.GMX, 'GMX');
|
||||
case ERC20BridgeSource.Platypus:
|
||||
@@ -210,6 +207,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'MeshSwap');
|
||||
case ERC20BridgeSource.BancorV3:
|
||||
return encodeBridgeSourceId(BridgeProtocol.BancorV3, 'BancorV3');
|
||||
case ERC20BridgeSource.Velodrome:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Velodrome, 'Velodrome');
|
||||
default:
|
||||
throw new Error(AggregationError.NoBridgeForSource);
|
||||
}
|
||||
@@ -283,16 +282,12 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
|
||||
case ERC20BridgeSource.PancakeSwapV2:
|
||||
case ERC20BridgeSource.BakerySwap:
|
||||
case ERC20BridgeSource.ApeSwap:
|
||||
case ERC20BridgeSource.CafeSwap:
|
||||
case ERC20BridgeSource.CheeseSwap:
|
||||
case ERC20BridgeSource.JulSwap:
|
||||
case ERC20BridgeSource.QuickSwap:
|
||||
case ERC20BridgeSource.ComethSwap:
|
||||
case ERC20BridgeSource.Dfyn:
|
||||
case ERC20BridgeSource.WaultSwap:
|
||||
case ERC20BridgeSource.Polydex:
|
||||
case ERC20BridgeSource.ShibaSwap:
|
||||
case ERC20BridgeSource.JetSwap:
|
||||
case ERC20BridgeSource.Pangolin:
|
||||
case ERC20BridgeSource.TraderJoe:
|
||||
case ERC20BridgeSource.UbeSwap:
|
||||
@@ -300,6 +295,8 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
|
||||
case ERC20BridgeSource.SpookySwap:
|
||||
case ERC20BridgeSource.MorpheusSwap:
|
||||
case ERC20BridgeSource.BiSwap:
|
||||
case ERC20BridgeSource.MDex:
|
||||
case ERC20BridgeSource.KnightSwap:
|
||||
case ERC20BridgeSource.Yoshi:
|
||||
case ERC20BridgeSource.MeshSwap:
|
||||
const uniswapV2FillData = (order as OptimizedMarketBridgeOrder<UniswapV2FillData>).fillData;
|
||||
@@ -391,6 +388,10 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
|
||||
const bancorV3FillData = (order as OptimizedMarketBridgeOrder<BancorFillData>).fillData;
|
||||
bridgeData = encoder.encode([bancorV3FillData.networkAddress, bancorV3FillData.path]);
|
||||
break;
|
||||
case ERC20BridgeSource.Velodrome:
|
||||
const velodromeFillData = (order as OptimizedMarketBridgeOrder<VelodromeFillData>).fillData;
|
||||
bridgeData = encoder.encode([velodromeFillData.router, velodromeFillData.stable]);
|
||||
break;
|
||||
default:
|
||||
throw new Error(AggregationError.NoBridgeForSource);
|
||||
}
|
||||
@@ -525,6 +526,8 @@ export const BRIDGE_ENCODERS: {
|
||||
[ERC20BridgeSource.SpookySwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.MorpheusSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.BiSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.MDex]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.KnightSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.Yoshi]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.MeshSwap]: routerAddressPathEncoder,
|
||||
// Avalanche
|
||||
@@ -537,16 +540,12 @@ export const BRIDGE_ENCODERS: {
|
||||
[ERC20BridgeSource.PancakeSwapV2]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.BakerySwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.ApeSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.CafeSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.CheeseSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.JulSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.WaultSwap]: routerAddressPathEncoder,
|
||||
// Polygon
|
||||
[ERC20BridgeSource.QuickSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.ComethSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.Dfyn]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.Polydex]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.JetSwap]: routerAddressPathEncoder,
|
||||
// Generic pools
|
||||
[ERC20BridgeSource.Shell]: poolEncoder,
|
||||
[ERC20BridgeSource.Component]: poolEncoder,
|
||||
@@ -582,6 +581,7 @@ export const BRIDGE_ENCODERS: {
|
||||
[ERC20BridgeSource.AaveV2]: AbiEncoder.create('(address,address)'),
|
||||
[ERC20BridgeSource.Compound]: AbiEncoder.create('(address)'),
|
||||
[ERC20BridgeSource.Geist]: AbiEncoder.create('(address,address)'),
|
||||
[ERC20BridgeSource.Velodrome]: AbiEncoder.create('(address,bool)'),
|
||||
};
|
||||
|
||||
function getFillTokenAmounts(fill: CollapsedFill, side: MarketOperation): [BigNumber, BigNumber] {
|
||||
|
@@ -48,6 +48,7 @@ import {
|
||||
SELL_SOURCE_FILTER_BY_CHAIN_ID,
|
||||
UNISWAPV1_ROUTER_BY_CHAIN_ID,
|
||||
UNISWAPV3_CONFIG_BY_CHAIN_ID,
|
||||
VELODROME_ROUTER_BY_CHAIN_ID,
|
||||
ZERO_AMOUNT,
|
||||
} from './constants';
|
||||
import { getGeistInfoForPair } from './geist_utils';
|
||||
@@ -95,6 +96,7 @@ import {
|
||||
TokenAdjacencyGraph,
|
||||
UniswapV2FillData,
|
||||
UniswapV3FillData,
|
||||
VelodromeFillData,
|
||||
} from './types';
|
||||
|
||||
/**
|
||||
@@ -1301,6 +1303,7 @@ export class SamplerOperations {
|
||||
params: [pool[0], tokenAddressPath, takerFillAmounts],
|
||||
});
|
||||
}
|
||||
|
||||
public getPlatypusBuyQuotes(
|
||||
router: string,
|
||||
pool: string[],
|
||||
@@ -1316,6 +1319,52 @@ export class SamplerOperations {
|
||||
});
|
||||
}
|
||||
|
||||
public getVelodromeSellQuotes(
|
||||
router: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
takerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<VelodromeFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Velodrome,
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleSellsFromVelodrome,
|
||||
params: [router, takerToken, makerToken, takerFillAmounts],
|
||||
callback: (callResults: string, fillData: VelodromeFillData): BigNumber[] => {
|
||||
const [isStable, samples] = this._samplerContract.getABIDecodedReturnData<[boolean, BigNumber[]]>(
|
||||
'sampleSellsFromVelodrome',
|
||||
callResults,
|
||||
);
|
||||
fillData.router = router;
|
||||
fillData.stable = isStable;
|
||||
return samples;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public getVelodromeBuyQuotes(
|
||||
router: string,
|
||||
takerToken: string,
|
||||
makerToken: string,
|
||||
makerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<VelodromeFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Velodrome,
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleBuysFromVelodrome,
|
||||
params: [router, takerToken, makerToken, makerFillAmounts],
|
||||
callback: (callResults: string, fillData: VelodromeFillData): BigNumber[] => {
|
||||
const [isStable, samples] = this._samplerContract.getABIDecodedReturnData<[boolean, BigNumber[]]>(
|
||||
'sampleBuysFromVelodrome',
|
||||
callResults,
|
||||
);
|
||||
fillData.router = router;
|
||||
fillData.stable = isStable;
|
||||
return samples;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public getMedianSellRate(
|
||||
sources: ERC20BridgeSource[],
|
||||
makerToken: string,
|
||||
@@ -1430,16 +1479,12 @@ export class SamplerOperations {
|
||||
case ERC20BridgeSource.PancakeSwapV2:
|
||||
case ERC20BridgeSource.BakerySwap:
|
||||
case ERC20BridgeSource.ApeSwap:
|
||||
case ERC20BridgeSource.CafeSwap:
|
||||
case ERC20BridgeSource.CheeseSwap:
|
||||
case ERC20BridgeSource.JulSwap:
|
||||
case ERC20BridgeSource.QuickSwap:
|
||||
case ERC20BridgeSource.ComethSwap:
|
||||
case ERC20BridgeSource.Dfyn:
|
||||
case ERC20BridgeSource.WaultSwap:
|
||||
case ERC20BridgeSource.Polydex:
|
||||
case ERC20BridgeSource.ShibaSwap:
|
||||
case ERC20BridgeSource.JetSwap:
|
||||
case ERC20BridgeSource.Pangolin:
|
||||
case ERC20BridgeSource.TraderJoe:
|
||||
case ERC20BridgeSource.UbeSwap:
|
||||
@@ -1448,6 +1493,8 @@ export class SamplerOperations {
|
||||
case ERC20BridgeSource.Yoshi:
|
||||
case ERC20BridgeSource.MorpheusSwap:
|
||||
case ERC20BridgeSource.BiSwap:
|
||||
case ERC20BridgeSource.MDex:
|
||||
case ERC20BridgeSource.KnightSwap:
|
||||
case ERC20BridgeSource.MeshSwap:
|
||||
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
|
||||
if (!isValidAddress(uniLikeRouter)) {
|
||||
@@ -1717,6 +1764,14 @@ export class SamplerOperations {
|
||||
takerFillAmounts,
|
||||
);
|
||||
}
|
||||
case ERC20BridgeSource.Velodrome: {
|
||||
return this.getVelodromeSellQuotes(
|
||||
VELODROME_ROUTER_BY_CHAIN_ID[this.chainId],
|
||||
takerToken,
|
||||
makerToken,
|
||||
takerFillAmounts,
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported sell sample source: ${source}`);
|
||||
}
|
||||
@@ -1772,16 +1827,12 @@ export class SamplerOperations {
|
||||
case ERC20BridgeSource.PancakeSwapV2:
|
||||
case ERC20BridgeSource.BakerySwap:
|
||||
case ERC20BridgeSource.ApeSwap:
|
||||
case ERC20BridgeSource.CafeSwap:
|
||||
case ERC20BridgeSource.CheeseSwap:
|
||||
case ERC20BridgeSource.JulSwap:
|
||||
case ERC20BridgeSource.QuickSwap:
|
||||
case ERC20BridgeSource.ComethSwap:
|
||||
case ERC20BridgeSource.Dfyn:
|
||||
case ERC20BridgeSource.WaultSwap:
|
||||
case ERC20BridgeSource.Polydex:
|
||||
case ERC20BridgeSource.ShibaSwap:
|
||||
case ERC20BridgeSource.JetSwap:
|
||||
case ERC20BridgeSource.Pangolin:
|
||||
case ERC20BridgeSource.TraderJoe:
|
||||
case ERC20BridgeSource.UbeSwap:
|
||||
@@ -1790,6 +1841,8 @@ export class SamplerOperations {
|
||||
case ERC20BridgeSource.Yoshi:
|
||||
case ERC20BridgeSource.MorpheusSwap:
|
||||
case ERC20BridgeSource.BiSwap:
|
||||
case ERC20BridgeSource.MDex:
|
||||
case ERC20BridgeSource.KnightSwap:
|
||||
case ERC20BridgeSource.MeshSwap:
|
||||
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
|
||||
if (!isValidAddress(uniLikeRouter)) {
|
||||
@@ -2053,6 +2106,14 @@ export class SamplerOperations {
|
||||
makerFillAmounts,
|
||||
);
|
||||
}
|
||||
case ERC20BridgeSource.Velodrome: {
|
||||
return this.getVelodromeBuyQuotes(
|
||||
VELODROME_ROUTER_BY_CHAIN_ID[this.chainId],
|
||||
takerToken,
|
||||
makerToken,
|
||||
makerFillAmounts,
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported buy sample source: ${source}`);
|
||||
}
|
||||
|
@@ -71,23 +71,21 @@ export enum ERC20BridgeSource {
|
||||
PancakeSwap = 'PancakeSwap',
|
||||
PancakeSwapV2 = 'PancakeSwap_V2',
|
||||
BiSwap = 'BiSwap',
|
||||
MDex = 'MDex',
|
||||
KnightSwap = 'KnightSwap',
|
||||
BakerySwap = 'BakerySwap',
|
||||
Nerve = 'Nerve',
|
||||
Belt = 'Belt',
|
||||
Ellipsis = 'Ellipsis',
|
||||
ApeSwap = 'ApeSwap',
|
||||
CafeSwap = 'CafeSwap',
|
||||
CheeseSwap = 'CheeseSwap',
|
||||
JulSwap = 'JulSwap',
|
||||
ACryptos = 'ACryptoS',
|
||||
// Polygon only
|
||||
QuickSwap = 'QuickSwap',
|
||||
ComethSwap = 'ComethSwap',
|
||||
Dfyn = 'Dfyn',
|
||||
WaultSwap = 'WaultSwap',
|
||||
Polydex = 'Polydex',
|
||||
FirebirdOneSwap = 'FirebirdOneSwap',
|
||||
JetSwap = 'JetSwap',
|
||||
IronSwap = 'IronSwap',
|
||||
MeshSwap = 'MeshSwap',
|
||||
// Avalanche
|
||||
@@ -106,6 +104,8 @@ export enum ERC20BridgeSource {
|
||||
MorpheusSwap = 'MorpheusSwap',
|
||||
Yoshi = 'Yoshi',
|
||||
Geist = 'Geist',
|
||||
// Optimism
|
||||
Velodrome = 'Velodrome',
|
||||
}
|
||||
export type SourcesWithPoolsCache =
|
||||
| ERC20BridgeSource.Balancer
|
||||
@@ -376,6 +376,12 @@ export interface PlatypusFillData extends FillData {
|
||||
pool: string[];
|
||||
tokenAddressPath: string[];
|
||||
}
|
||||
|
||||
export interface VelodromeFillData extends FillData {
|
||||
router: string;
|
||||
stable: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a node on a fill path.
|
||||
*/
|
||||
|
@@ -207,7 +207,7 @@ export function generateExtendedQuoteReportSources(
|
||||
..._.flatten(
|
||||
quotes.dexQuotes.map(dex =>
|
||||
dex
|
||||
.filter(quote => isDexSampleForTotalAmount(quote, amount))
|
||||
.filter(quote => isDexSampleFilter(quote, amount))
|
||||
.map(quote => dexSampleToReportSource(quote, marketOperation)),
|
||||
),
|
||||
),
|
||||
@@ -306,8 +306,9 @@ export function dexSampleToReportSource(ds: DexSample, marketOperation: MarketOp
|
||||
* Checks if a DEX sample is the one that represents the whole amount requested by taker
|
||||
* NOTE: this is used for the QuoteReport to filter samples
|
||||
*/
|
||||
function isDexSampleForTotalAmount(ds: DexSample, amount: BigNumber): boolean {
|
||||
return ds.input.eq(amount);
|
||||
function isDexSampleFilter(ds: DexSample, amount: BigNumber): boolean {
|
||||
// The entry is for the total amont, not a sampler entry && there was liquidity in the source
|
||||
return ds.input.eq(amount) && ds.output.isGreaterThan(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -51,6 +51,7 @@ import * as UniswapSampler from '../test/generated-artifacts/UniswapSampler.json
|
||||
import * as UniswapV2Sampler from '../test/generated-artifacts/UniswapV2Sampler.json';
|
||||
import * as UniswapV3Sampler from '../test/generated-artifacts/UniswapV3Sampler.json';
|
||||
import * as UtilitySampler from '../test/generated-artifacts/UtilitySampler.json';
|
||||
import * as VelodromeSampler from '../test/generated-artifacts/VelodromeSampler.json';
|
||||
export const artifacts = {
|
||||
ApproximateBuys: ApproximateBuys as ContractArtifact,
|
||||
BalanceChecker: BalanceChecker as ContractArtifact,
|
||||
@@ -83,6 +84,7 @@ export const artifacts = {
|
||||
UniswapV2Sampler: UniswapV2Sampler as ContractArtifact,
|
||||
UniswapV3Sampler: UniswapV3Sampler as ContractArtifact,
|
||||
UtilitySampler: UtilitySampler as ContractArtifact,
|
||||
VelodromeSampler: VelodromeSampler as ContractArtifact,
|
||||
IBalancer: IBalancer as ContractArtifact,
|
||||
IBalancerV2Vault: IBalancerV2Vault as ContractArtifact,
|
||||
IBancor: IBancor as ContractArtifact,
|
||||
|
@@ -49,3 +49,4 @@ export * from '../test/generated-wrappers/uniswap_sampler';
|
||||
export * from '../test/generated-wrappers/uniswap_v2_sampler';
|
||||
export * from '../test/generated-wrappers/uniswap_v3_sampler';
|
||||
export * from '../test/generated-wrappers/utility_sampler';
|
||||
export * from '../test/generated-wrappers/velodrome_sampler';
|
||||
|
@@ -51,6 +51,7 @@
|
||||
"test/generated-artifacts/UniswapSampler.json",
|
||||
"test/generated-artifacts/UniswapV2Sampler.json",
|
||||
"test/generated-artifacts/UniswapV3Sampler.json",
|
||||
"test/generated-artifacts/UtilitySampler.json"
|
||||
"test/generated-artifacts/UtilitySampler.json",
|
||||
"test/generated-artifacts/VelodromeSampler.json"
|
||||
]
|
||||
}
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"version": "6.16.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Redeploy FQT on Mainnet and Optimism"
|
||||
}
|
||||
],
|
||||
"timestamp": 1655244958
|
||||
},
|
||||
{
|
||||
"version": "6.15.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v6.16.0 - _June 14, 2022_
|
||||
|
||||
* Redeploy FQT on Mainnet and Optimism
|
||||
|
||||
## v6.15.0 - _June 3, 2022_
|
||||
|
||||
* Redeploy FQT on Mainnet
|
||||
|
@@ -37,7 +37,7 @@
|
||||
"wethTransformer": "0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7",
|
||||
"payTakerTransformer": "0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e",
|
||||
"affiliateFeeTransformer": "0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f",
|
||||
"fillQuoteTransformer": "0xa651c18efcf50409f3d0f5cdbf615d3016b828c8",
|
||||
"fillQuoteTransformer": "0x26b2d9ea76f24206805d17565a5e0efcf787e0ae",
|
||||
"positiveSlippageFeeTransformer": "0xa9416ce1dbde8d331210c07b5c253d94ee4cc3fd"
|
||||
}
|
||||
},
|
||||
@@ -499,7 +499,7 @@
|
||||
"wethTransformer": "0x02ce7af6520e2862f961f5d7eda746642865179c",
|
||||
"payTakerTransformer": "0x085d10a34f14f6a631ea8ff7d016782ee3ffaa11",
|
||||
"affiliateFeeTransformer": "0x55cf1d7535250db75bf0190493f55781ee583553",
|
||||
"fillQuoteTransformer": "0x3543ef833d28b7e983c293856561f21a7f089f1d",
|
||||
"fillQuoteTransformer": "0xfae0ce3841afbf5625a15f0c73e03ba6660e575f",
|
||||
"positiveSlippageFeeTransformer": "0xb11e14565dfbeb702dea9bc0cb47f1a8b32f4783"
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contract-addresses",
|
||||
"version": "6.15.0",
|
||||
"version": "6.16.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "13.20.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "13.20.3",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v13.20.4 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v13.20.3 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contract-wrappers",
|
||||
"version": "13.20.3",
|
||||
"version": "13.20.4",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -57,7 +57,7 @@
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.34",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/contract-addresses": "^6.15.0",
|
||||
"@0x/contract-addresses": "^6.16.0",
|
||||
"@0x/json-schemas": "^6.4.4",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/utils": "^6.5.3",
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "11.15.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add Velodrome support",
|
||||
"pr": 494
|
||||
}
|
||||
],
|
||||
"timestamp": 1655244958
|
||||
},
|
||||
{
|
||||
"version": "11.14.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v11.15.0 - _June 14, 2022_
|
||||
|
||||
* Add Velodrome support (#494)
|
||||
|
||||
## v11.14.0 - _June 3, 2022_
|
||||
|
||||
* Adds Support for BancorV3 on Ethereum (#492)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/protocol-utils",
|
||||
"version": "11.14.0",
|
||||
"version": "11.15.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -63,8 +63,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.34",
|
||||
"@0x/contract-addresses": "^6.15.0",
|
||||
"@0x/contract-wrappers": "^13.20.3",
|
||||
"@0x/contract-addresses": "^6.16.0",
|
||||
"@0x/contract-wrappers": "^13.20.4",
|
||||
"@0x/json-schemas": "^6.4.4",
|
||||
"@0x/subproviders": "^6.6.5",
|
||||
"@0x/utils": "^6.5.3",
|
||||
|
@@ -139,6 +139,7 @@ export enum BridgeProtocol {
|
||||
GMX,
|
||||
Platypus,
|
||||
BancorV3,
|
||||
Velodrome,
|
||||
}
|
||||
// tslint:enable: enum-naming
|
||||
|
||||
|
Reference in New Issue
Block a user