* Add WooFI interface for sampling
* WooFi Sampler
* Add mixin
* Update bridge adapters
* fix some bugs
* update transformer_utils
* Add BSC support
* yarn prettier
* Capitalize WOOFI in bridge adapters
* Put rebateAddress in a constant, fixed some other stylistic errors
* bug fixes
* Updated CHANGELOGS & MD docs
* Publish
- @0x/contracts-erc20@3.3.33
- @0x/contracts-test-utils@5.4.24
- @0x/contracts-treasury@1.4.16
- @0x/contracts-utils@4.8.14
- @0x/contracts-zero-ex@0.36.0
- @0x/asset-swapper@16.64.0
- @0x/contract-addresses@6.17.0
- @0x/contract-wrappers@13.20.5
- @0x/protocol-utils@11.16.0
* Update reference.mdx (#531)
Align with `DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE` value from c74e31c219/src/constants.ts (L26)
* code cleanup
* remove deusdc curve pool from this pr
* Refactor PoolsCache (part 1) [TKR-500] (#525)
* Make _refreshPoolCacheIfRequiredAsync type-safe and remove Promise.all
* Factor out PoolsCache key logic into a function
* Use Map instead of object in PoolsCache and increase the default timeout
* Clean up PoolsCache and simplify its public interface
* Refactor PoolsCache (part 2) [TKR-500] (#526)
* Introduce NoOpPoolsCache and use it in unsupported chains for BeethovenX
* Use `NoOpPoolsCache` for `CreamPoolsCache` and `BalancerPoolsCache` on unsupported chains
* Remove `getBidAskLiquidityForMakerTakerAssetPairAsync` (#528)
* Add transfer approval for quote token for multi-hops and fix buy sampler typo
* Use 0x gas api instead of eth gas station api [TKR-502] (#532)
* Use 0x gas api instead of eth gas station api
* Add integration test for `ProtocolFeeUtils`
* Update CHANGELOG.json
* Add polygon, fantom, avalanche support
* yarn prettier
* Updated CHANGELOGS & MD docs
* Publish
- @0x/asset-swapper@16.65.0
* Remove references to `custom-no-magic-numbers` ts lint rule [TKR-484] (#533)
* Remove references to `custom-no-magic-numbers ts` lint rule
* Run prettier
* resolve Kyu's comments
* remove fqt change
* Add WooFI interface for sampling
* WooFi Sampler
* Add mixin
* Update bridge adapters
* fix some bugs
* update transformer_utils
* Add BSC support
* yarn prettier
* Capitalize WOOFI in bridge adapters
* Put rebateAddress in a constant, fixed some other stylistic errors
* bug fixes
* code cleanup
* remove deusdc curve pool from this pr
* Add transfer approval for quote token for multi-hops and fix buy sampler typo
* Add polygon, fantom, avalanche support
* yarn prettier
* resolve Kyu's comments
* remove fqt change
* merge types.ts
* WOOFi -> WOOFI
* fix lerna run lint
* Changelog
* nit changes
Co-authored-by: Github Actions <github-actions@github.com>
Co-authored-by: Pavel <51318041+pavel-bc@users.noreply.github.com>
Co-authored-by: Kyu <kyuhyun217@gmail.com>
189 lines
5.8 KiB
Solidity
189 lines
5.8 KiB
Solidity
// SPDX-License-Identifier: Apache-2.0
|
|
/*
|
|
|
|
Copyright 2022 ZeroEx Intl.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
pragma solidity ^0.6.5;
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
import "./AbstractBridgeAdapter.sol";
|
|
import "./BridgeProtocols.sol";
|
|
import "./mixins/MixinAaveV2.sol";
|
|
import "./mixins/MixinBalancerV2.sol";
|
|
import "./mixins/MixinBalancerV2Batch.sol";
|
|
import "./mixins/MixinCurve.sol";
|
|
import "./mixins/MixinCurveV2.sol";
|
|
import "./mixins/MixinDodo.sol";
|
|
import "./mixins/MixinDodoV2.sol";
|
|
import "./mixins/MixinKyberDmm.sol";
|
|
import "./mixins/MixinMStable.sol";
|
|
import "./mixins/MixinNerve.sol";
|
|
import "./mixins/MixinUniswapV2.sol";
|
|
import "./mixins/MixinUniswapV3.sol";
|
|
import "./mixins/MixinWOOFi.sol";
|
|
import "./mixins/MixinZeroExBridge.sol";
|
|
|
|
contract PolygonBridgeAdapter is
|
|
AbstractBridgeAdapter(137, "Polygon"),
|
|
MixinAaveV2,
|
|
MixinBalancerV2,
|
|
MixinBalancerV2Batch,
|
|
MixinCurve,
|
|
MixinCurveV2,
|
|
MixinDodo,
|
|
MixinDodoV2,
|
|
MixinKyberDmm,
|
|
MixinMStable,
|
|
MixinNerve,
|
|
MixinUniswapV2,
|
|
MixinUniswapV3,
|
|
MixinWOOFi,
|
|
MixinZeroExBridge
|
|
{
|
|
constructor(IEtherTokenV06 weth)
|
|
public
|
|
MixinCurve(weth)
|
|
{}
|
|
|
|
function _trade(
|
|
BridgeOrder memory order,
|
|
IERC20TokenV06 sellToken,
|
|
IERC20TokenV06 buyToken,
|
|
uint256 sellAmount,
|
|
bool dryRun
|
|
)
|
|
internal
|
|
override
|
|
returns (uint256 boughtAmount, bool supportedSource)
|
|
{
|
|
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
|
if (protocolId == BridgeProtocols.CURVE) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeCurve(
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.CURVEV2) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeCurveV2(
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeUniswapV3(
|
|
sellToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeUniswapV2(
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.BALANCERV2) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeBalancerV2(
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.BALANCERV2BATCH) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeBalancerV2Batch(
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.MSTABLE) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeMStable(
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.DODO) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeDodo(
|
|
sellToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.DODOV2) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeDodoV2(
|
|
sellToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.NERVE) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeNerve(
|
|
sellToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.KYBERDMM) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeKyberDmm(
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.AAVEV2) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeAaveV2(
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.WOOFI) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeWOOFi(
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
|
if (dryRun) { return (0, true); }
|
|
boughtAmount = _tradeZeroExBridge(
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
order.bridgeData
|
|
);
|
|
}
|
|
|
|
emit BridgeFill(
|
|
order.source,
|
|
sellToken,
|
|
buyToken,
|
|
sellAmount,
|
|
boughtAmount
|
|
);
|
|
}
|
|
}
|