boost
This commit is contained in:
@@ -25,6 +25,7 @@ import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinBalancer.sol";
|
||||
import "./mixins/MixinBalancerV2.sol";
|
||||
import "./mixins/MixinBancor.sol";
|
||||
import "./mixins/MixinBooster.sol";
|
||||
import "./mixins/MixinCoFiX.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
@@ -50,6 +51,7 @@ contract BridgeAdapter is
|
||||
MixinBalancer,
|
||||
MixinBalancerV2,
|
||||
MixinBancor,
|
||||
MixinBooster,
|
||||
MixinCoFiX,
|
||||
MixinCurve,
|
||||
MixinCurveV2,
|
||||
@@ -75,6 +77,7 @@ contract BridgeAdapter is
|
||||
MixinBalancer()
|
||||
MixinBalancerV2()
|
||||
MixinBancor(weth)
|
||||
MixinBooster()
|
||||
MixinCoFiX()
|
||||
MixinCurve(weth)
|
||||
MixinCurveV2()
|
||||
@@ -245,6 +248,13 @@ contract BridgeAdapter is
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.BOOSTER) {
|
||||
boughtAmount = _tradeBooster(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else {
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
|
||||
@@ -49,4 +49,5 @@ library BridgeProtocols {
|
||||
uint128 internal constant KYBERDMM = 19;
|
||||
uint128 internal constant CURVEV2 = 20;
|
||||
uint128 internal constant LIDO = 21;
|
||||
uint128 internal constant BOOSTER = 22;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// 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 IBooster {
|
||||
function swap(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
address recipient
|
||||
)
|
||||
external
|
||||
returns (uint256);
|
||||
}
|
||||
|
||||
contract MixinBooster {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
function _tradeBooster(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
// Decode the bridge data.
|
||||
(IBooster pool) = abi.decode(bridgeData, (IBooster));
|
||||
// Grant the pool an allowance.
|
||||
sellToken.approveIfBelow(address(pool), sellAmount);
|
||||
|
||||
// Convert the tokens
|
||||
boughtAmount = pool.swap(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
address(this)
|
||||
);
|
||||
|
||||
return boughtAmount;
|
||||
}
|
||||
}
|
||||
@@ -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,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinBooster|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -82,6 +82,7 @@ import * as MetaTransactionsFeature from '../test/generated-artifacts/MetaTransa
|
||||
import * as MixinBalancer from '../test/generated-artifacts/MixinBalancer.json';
|
||||
import * as MixinBalancerV2 from '../test/generated-artifacts/MixinBalancerV2.json';
|
||||
import * as MixinBancor from '../test/generated-artifacts/MixinBancor.json';
|
||||
import * as MixinBooster from '../test/generated-artifacts/MixinBooster.json';
|
||||
import * as MixinCoFiX from '../test/generated-artifacts/MixinCoFiX.json';
|
||||
import * as MixinCryptoCom from '../test/generated-artifacts/MixinCryptoCom.json';
|
||||
import * as MixinCurve from '../test/generated-artifacts/MixinCurve.json';
|
||||
@@ -257,6 +258,7 @@ export const artifacts = {
|
||||
MixinBalancer: MixinBalancer as ContractArtifact,
|
||||
MixinBalancerV2: MixinBalancerV2 as ContractArtifact,
|
||||
MixinBancor: MixinBancor as ContractArtifact,
|
||||
MixinBooster: MixinBooster as ContractArtifact,
|
||||
MixinCoFiX: MixinCoFiX as ContractArtifact,
|
||||
MixinCryptoCom: MixinCryptoCom as ContractArtifact,
|
||||
MixinCurve: MixinCurve as ContractArtifact,
|
||||
|
||||
@@ -80,6 +80,7 @@ export * from '../test/generated-wrappers/meta_transactions_feature';
|
||||
export * from '../test/generated-wrappers/mixin_balancer';
|
||||
export * from '../test/generated-wrappers/mixin_balancer_v2';
|
||||
export * from '../test/generated-wrappers/mixin_bancor';
|
||||
export * from '../test/generated-wrappers/mixin_booster';
|
||||
export * from '../test/generated-wrappers/mixin_co_fi_x';
|
||||
export * from '../test/generated-wrappers/mixin_crypto_com';
|
||||
export * from '../test/generated-wrappers/mixin_curve';
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
"test/generated-artifacts/MixinBalancer.json",
|
||||
"test/generated-artifacts/MixinBalancerV2.json",
|
||||
"test/generated-artifacts/MixinBancor.json",
|
||||
"test/generated-artifacts/MixinBooster.json",
|
||||
"test/generated-artifacts/MixinCoFiX.json",
|
||||
"test/generated-artifacts/MixinCryptoCom.json",
|
||||
"test/generated-artifacts/MixinCurve.json",
|
||||
|
||||
104
packages/asset-swapper/contracts/src/BoosterSampler.sol
Normal file
104
packages/asset-swapper/contracts/src/BoosterSampler.sol
Normal file
@@ -0,0 +1,104 @@
|
||||
// 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 "@0x/contracts-zero-ex/contracts/src/transformers/bridges/mixins/MixinBooster.sol";
|
||||
import "./SwapRevertSampler.sol";
|
||||
|
||||
contract BoosterSampler is
|
||||
MixinBooster,
|
||||
SwapRevertSampler
|
||||
{
|
||||
|
||||
function sampleSwapFromBooster(
|
||||
address sellToken,
|
||||
address buyToken,
|
||||
bytes memory bridgeData,
|
||||
uint256 takerTokenAmount
|
||||
)
|
||||
external
|
||||
returns (uint256)
|
||||
{
|
||||
return _tradeBooster(
|
||||
IERC20TokenV06(sellToken),
|
||||
IERC20TokenV06(buyToken),
|
||||
takerTokenAmount,
|
||||
bridgeData
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Sample sell quotes from Booster.
|
||||
/// @param pool Address of the Booster Pool.
|
||||
/// @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 gasUsed gas consumed in each sample sell
|
||||
/// @return makerTokenAmounts Maker amounts bought at each taker token
|
||||
/// amount.
|
||||
function sampleSellsFromBooster(
|
||||
address pool,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
returns (uint256[] memory gasUsed, uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
(gasUsed, makerTokenAmounts) = _sampleSwapQuotesRevert(
|
||||
SwapRevertSamplerQuoteOpts({
|
||||
sellToken: takerToken,
|
||||
buyToken: makerToken,
|
||||
bridgeData: abi.encode(pool),
|
||||
getSwapQuoteCallback: this.sampleSwapFromBooster
|
||||
}),
|
||||
takerTokenAmounts
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Sample buy quotes from Booster.
|
||||
/// @param pool Address of the Booster pool.
|
||||
/// @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.
|
||||
/// @return gasUsed gas consumed in each sample sell
|
||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||
/// amount.
|
||||
function sampleBuysFromBooster(
|
||||
address pool,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
returns (uint256[] memory gasUsed, uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
(gasUsed, takerTokenAmounts) = _sampleSwapApproximateBuys(
|
||||
SwapRevertSamplerBuyQuoteOpts({
|
||||
sellToken: takerToken,
|
||||
buyToken: makerToken,
|
||||
sellTokenData: abi.encode(pool),
|
||||
buyTokenData: abi.encode(pool),
|
||||
getSwapQuoteCallback: this.sampleSwapFromBooster
|
||||
}),
|
||||
makerTokenAmounts
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ pragma experimental ABIEncoderV2;
|
||||
import "./BalancerSampler.sol";
|
||||
import "./BalancerV2Sampler.sol";
|
||||
import "./BancorSampler.sol";
|
||||
import "./BoosterSampler.sol";
|
||||
import "./CurveSampler.sol";
|
||||
import "./CurveV2Sampler.sol";
|
||||
import "./DODOSampler.sol";
|
||||
@@ -49,6 +50,7 @@ contract ERC20BridgeSampler is
|
||||
BalancerSampler,
|
||||
BalancerV2Sampler,
|
||||
BancorSampler,
|
||||
BoosterSampler,
|
||||
CurveSampler,
|
||||
CurveV2Sampler,
|
||||
DODOSampler,
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"config": {
|
||||
"publicInterfaceContracts": "ERC20BridgeSampler,BalanceChecker,DelegateHackedERC20,FakeTaker,HackedERC20,GasOverhead",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./test/generated-artifacts/@(BalanceChecker|BalancerSampler|BalancerV2Sampler|BancorSampler|CurveSampler|CurveV2Sampler|DODOSampler|DODOV2Sampler|DelegateHackedERC20|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|FakeTaker|GasOverhead|HackedERC20|IEth2Dai|IKyberNetwork|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|KyberSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|NativeOrderSampler|ShellSampler|SwapRevertSampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler).json",
|
||||
"abis": "./test/generated-artifacts/@(BalanceChecker|BalancerSampler|BalancerV2Sampler|BancorSampler|BoosterSampler|CurveSampler|CurveV2Sampler|DODOSampler|DODOV2Sampler|DelegateHackedERC20|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|FakeTaker|GasOverhead|HackedERC20|IEth2Dai|IKyberNetwork|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|KyberSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|NativeOrderSampler|ShellSampler|SwapRevertSampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler).json",
|
||||
"postpublish": {
|
||||
"assets": []
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Polydex,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.FirebirdOneSwap,
|
||||
ERC20BridgeSource.Booster,
|
||||
]),
|
||||
},
|
||||
new SourceFilters([]),
|
||||
@@ -226,6 +227,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Polydex,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.FirebirdOneSwap,
|
||||
ERC20BridgeSource.Booster,
|
||||
]),
|
||||
},
|
||||
new SourceFilters([]),
|
||||
@@ -476,6 +478,22 @@ export const FIREBIRDONESWAP_POLYGON_POOLS = {
|
||||
oneswap: '0x01c9475dbd36e46d1961572c8de24b74616bae9e',
|
||||
};
|
||||
|
||||
export const BOOSTER_POLYGON_POOLS = valueByChainId<Array<{ poolAddress: string; tokens: string[] }>>(
|
||||
{
|
||||
[ChainId.Polygon]: [
|
||||
{
|
||||
poolAddress: '0x7f01a853e857db87aad498ee2b640b5dbcda4fb9',
|
||||
tokens: [POLYGON_TOKENS.USDC, POLYGON_TOKENS.WETH],
|
||||
},
|
||||
{
|
||||
poolAddress: '0x43a8e6954384521d6a6d482f7dce7f849fd95cdc',
|
||||
tokens: [POLYGON_TOKENS.WMATIC, POLYGON_TOKENS.WETH],
|
||||
},
|
||||
],
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
|
||||
{
|
||||
[ChainId.Mainnet]: [
|
||||
@@ -500,16 +518,16 @@ export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
|
||||
'0x07865c6e87b9f70255377e024ace6630c1eaa37f', // USDC
|
||||
],
|
||||
[ChainId.Polygon]: [
|
||||
POLYGON_TOKENS.WMATIC,
|
||||
POLYGON_TOKENS.WETH,
|
||||
POLYGON_TOKENS.USDC,
|
||||
POLYGON_TOKENS.DAI,
|
||||
POLYGON_TOKENS.USDT,
|
||||
POLYGON_TOKENS.WBTC,
|
||||
POLYGON_TOKENS.QUICK,
|
||||
POLYGON_TOKENS.DFYN,
|
||||
POLYGON_TOKENS.BANANA,
|
||||
POLYGON_TOKENS.WEXPOLY,
|
||||
// POLYGON_TOKENS.WMATIC,
|
||||
// POLYGON_TOKENS.WETH,
|
||||
// POLYGON_TOKENS.USDC,
|
||||
// POLYGON_TOKENS.DAI,
|
||||
// POLYGON_TOKENS.USDT,
|
||||
// POLYGON_TOKENS.WBTC,
|
||||
// POLYGON_TOKENS.QUICK,
|
||||
// POLYGON_TOKENS.DFYN,
|
||||
// POLYGON_TOKENS.BANANA,
|
||||
// POLYGON_TOKENS.WEXPOLY,
|
||||
],
|
||||
},
|
||||
[],
|
||||
|
||||
@@ -209,6 +209,14 @@ export class MarketOperationUtils {
|
||||
q && q.fillData && q.fillData.firstHopSource && q.fillData.secondHopSource,
|
||||
);
|
||||
|
||||
console.log({
|
||||
tokenDecimals,
|
||||
outputAmountPerEth,
|
||||
inputAmountPerEth,
|
||||
dexQuotes,
|
||||
rawTwoHopQuotes,
|
||||
});
|
||||
|
||||
const [makerTokenDecimals, takerTokenDecimals] = tokenDecimals;
|
||||
|
||||
const isRfqSupported = !!(_opts.rfqt && !isTxOriginContract);
|
||||
@@ -814,6 +822,7 @@ export class MarketOperationUtils {
|
||||
// Specify the original implementation at a new address (+1)
|
||||
overrides[tokenImplAddress] = { code: tokenCodes[i] };
|
||||
});
|
||||
console.log({ overrides });
|
||||
|
||||
return { overrides };
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ export class MeasuredSamplerContractOperation<
|
||||
this._params = opts.params;
|
||||
this._callback = opts.callback;
|
||||
this._deregisterable = opts.deregisterable || false;
|
||||
this._log = opts.log || false;
|
||||
this._log = opts.log || true;
|
||||
if (this._deregisterable) {
|
||||
this._deregisterKey = PathDeregister.createKey(this._params.slice(0, this._params.length - 1));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
BalancerFillData,
|
||||
BalancerV2FillData,
|
||||
BancorFillData,
|
||||
BoosterFillData,
|
||||
CollapsedFill,
|
||||
CurveFillData,
|
||||
DexSample,
|
||||
@@ -174,6 +175,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
|
||||
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'FirebirdOneSwap');
|
||||
case ERC20BridgeSource.Lido:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Lido, 'Lido');
|
||||
case ERC20BridgeSource.Booster:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Booster, 'Booster');
|
||||
default:
|
||||
throw new Error(AggregationError.NoBridgeForSource);
|
||||
}
|
||||
@@ -308,6 +311,10 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
|
||||
const lidoFillData = (order as OptimizedMarketBridgeOrder<LidoFillData>).fillData;
|
||||
bridgeData = encoder.encode([lidoFillData.stEthTokenAddress]);
|
||||
break;
|
||||
case ERC20BridgeSource.Booster:
|
||||
const boosterFillData = (order as OptimizedMarketBridgeOrder<BoosterFillData>).fillData;
|
||||
bridgeData = encoder.encode([boosterFillData.poolAddress]);
|
||||
break;
|
||||
default:
|
||||
throw new Error(AggregationError.NoBridgeForSource);
|
||||
}
|
||||
@@ -462,6 +469,7 @@ export const BRIDGE_ENCODERS: {
|
||||
]),
|
||||
[ERC20BridgeSource.KyberDmm]: AbiEncoder.create('(address,address[],address[])'),
|
||||
[ERC20BridgeSource.Lido]: AbiEncoder.create('(address)'),
|
||||
[ERC20BridgeSource.Booster]: poolEncoder,
|
||||
};
|
||||
|
||||
function getFillTokenAmounts(fill: CollapsedFill, side: MarketOperation): [BigNumber, BigNumber] {
|
||||
|
||||
@@ -154,9 +154,16 @@ export class DexOrderSampler extends SamplerOperations {
|
||||
return callDatas.map((_callData, i) => ops[i].handleCallResults(NULL_BYTES));
|
||||
}
|
||||
// Execute all non-empty calldatas.
|
||||
const rawCallResults = await this._samplerContract
|
||||
.batchCall(callDatas.filter(cd => cd !== NULL_BYTES))
|
||||
.callAsync({ overrides }, block);
|
||||
let rawCallResults: any;
|
||||
try {
|
||||
rawCallResults = await this._samplerContract
|
||||
.batchCall(callDatas.filter(cd => cd !== NULL_BYTES))
|
||||
.callAsync({ overrides }, block);
|
||||
console.log({ rawCallResults, ops: ops.map(o => (o as any).fillData) });
|
||||
} catch (e) {
|
||||
console.log('error', e);
|
||||
throw e;
|
||||
}
|
||||
// Return the parsed results.
|
||||
let rawCallResultsIdx = 0;
|
||||
const results = callDatas.map((callData, i) => {
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
import {
|
||||
BALANCER_V2_VAULT_ADDRESS_BY_CHAIN,
|
||||
BANCOR_REGISTRY_BY_CHAIN_ID,
|
||||
BOOSTER_POLYGON_POOLS,
|
||||
DODOV1_CONFIG_BY_CHAIN_ID,
|
||||
DODOV2_FACTORIES_BY_CHAIN_ID,
|
||||
KYBER_CONFIG_BY_CHAIN_ID,
|
||||
@@ -52,6 +53,7 @@ import {
|
||||
BalancerV2PoolInfo,
|
||||
BancorFillData,
|
||||
BatchedOperation,
|
||||
BoosterFillData,
|
||||
CurveFillData,
|
||||
DexSample,
|
||||
DODOFillData,
|
||||
@@ -1125,6 +1127,23 @@ export class SamplerOperations {
|
||||
});
|
||||
}
|
||||
|
||||
public getBoosterSellQuotes(
|
||||
poolAddress: string,
|
||||
makerToken: string,
|
||||
takerToken: string,
|
||||
takerFillAmounts: BigNumber[],
|
||||
): MeasuredSourceQuoteOperation<BoosterFillData> {
|
||||
return new MeasuredSamplerContractOperation({
|
||||
source: ERC20BridgeSource.Booster,
|
||||
fillData: {
|
||||
poolAddress,
|
||||
},
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleSellsFromBooster,
|
||||
params: [poolAddress, takerToken, makerToken, takerFillAmounts],
|
||||
});
|
||||
}
|
||||
|
||||
public getLidoBuyQuotes(
|
||||
lidoInfo: LidoInfo,
|
||||
makerToken: string,
|
||||
@@ -1483,6 +1502,18 @@ export class SamplerOperations {
|
||||
|
||||
return this.getLidoSellQuotes(lidoInfo, makerToken, takerToken, takerFillAmounts);
|
||||
}
|
||||
case ERC20BridgeSource.Booster: {
|
||||
console.log(BOOSTER_POLYGON_POOLS[this.chainId], makerToken, takerToken);
|
||||
const pools = BOOSTER_POLYGON_POOLS[this.chainId].filter(
|
||||
pool =>
|
||||
pool.tokens.includes(takerToken.toLowerCase()) &&
|
||||
pool.tokens.includes(makerToken.toLowerCase()),
|
||||
);
|
||||
console.log({ pools });
|
||||
return pools.map(pool =>
|
||||
this.getBoosterSellQuotes(pool.poolAddress, makerToken, takerToken, takerFillAmounts),
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported sell sample source: ${source}`);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ export enum ERC20BridgeSource {
|
||||
WaultSwap = 'WaultSwap',
|
||||
Polydex = 'Polydex',
|
||||
FirebirdOneSwap = 'FirebirdOneSwap',
|
||||
Booster = 'Booster',
|
||||
}
|
||||
export type SourcesWithPoolsCache = ERC20BridgeSource.Balancer | ERC20BridgeSource.BalancerV2 | ERC20BridgeSource.Cream;
|
||||
|
||||
@@ -252,6 +253,10 @@ export interface LidoFillData extends FillData {
|
||||
takerToken: string;
|
||||
}
|
||||
|
||||
export interface BoosterFillData extends FillData {
|
||||
poolAddress: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a node on a fill path.
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as BalanceChecker from '../test/generated-artifacts/BalanceChecker.json
|
||||
import * as BalancerSampler from '../test/generated-artifacts/BalancerSampler.json';
|
||||
import * as BalancerV2Sampler from '../test/generated-artifacts/BalancerV2Sampler.json';
|
||||
import * as BancorSampler from '../test/generated-artifacts/BancorSampler.json';
|
||||
import * as BoosterSampler from '../test/generated-artifacts/BoosterSampler.json';
|
||||
import * as CurveSampler from '../test/generated-artifacts/CurveSampler.json';
|
||||
import * as CurveV2Sampler from '../test/generated-artifacts/CurveV2Sampler.json';
|
||||
import * as DelegateHackedERC20 from '../test/generated-artifacts/DelegateHackedERC20.json';
|
||||
@@ -46,6 +47,7 @@ export const artifacts = {
|
||||
BalancerSampler: BalancerSampler as ContractArtifact,
|
||||
BalancerV2Sampler: BalancerV2Sampler as ContractArtifact,
|
||||
BancorSampler: BancorSampler as ContractArtifact,
|
||||
BoosterSampler: BoosterSampler as ContractArtifact,
|
||||
CurveSampler: CurveSampler as ContractArtifact,
|
||||
CurveV2Sampler: CurveV2Sampler as ContractArtifact,
|
||||
DODOSampler: DODOSampler as ContractArtifact,
|
||||
|
||||
@@ -7,6 +7,7 @@ export * from '../test/generated-wrappers/balance_checker';
|
||||
export * from '../test/generated-wrappers/balancer_sampler';
|
||||
export * from '../test/generated-wrappers/balancer_v2_sampler';
|
||||
export * from '../test/generated-wrappers/bancor_sampler';
|
||||
export * from '../test/generated-wrappers/booster_sampler';
|
||||
export * from '../test/generated-wrappers/curve_sampler';
|
||||
export * from '../test/generated-wrappers/curve_v2_sampler';
|
||||
export * from '../test/generated-wrappers/d_o_d_o_sampler';
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"test/generated-artifacts/BalancerSampler.json",
|
||||
"test/generated-artifacts/BalancerV2Sampler.json",
|
||||
"test/generated-artifacts/BancorSampler.json",
|
||||
"test/generated-artifacts/BoosterSampler.json",
|
||||
"test/generated-artifacts/CurveSampler.json",
|
||||
"test/generated-artifacts/CurveV2Sampler.json",
|
||||
"test/generated-artifacts/DODOSampler.json",
|
||||
|
||||
@@ -131,6 +131,7 @@ export enum BridgeProtocol {
|
||||
KyberDmm,
|
||||
CurveV2,
|
||||
Lido,
|
||||
Booster,
|
||||
}
|
||||
// tslint:enable: enum-naming
|
||||
|
||||
|
||||
Reference in New Issue
Block a user