feat/Add Maverick V1 Support (#741)

* Add Maverick V1 Support for Ethereum, BSC, and Base
This commit is contained in:
Savarn Dontamsetti (Sav) 2023-08-17 12:59:38 -04:00 committed by GitHub
parent e1f9e107e9
commit 7f324dd75d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 113 additions and 3 deletions

View File

@ -1,4 +1,12 @@
[
{
"version": "0.47.0",
"changes": [
{
"note": "Add MaverickV1 support on Ethereum, BSC, and Base"
}
]
},
{
"version": "0.46.0",
"changes": [

View File

@ -22,6 +22,7 @@ import "./mixins/MixinDodo.sol";
import "./mixins/MixinDodoV2.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinKyberElastic.sol";
import "./mixins/MixinMaverickV1.sol";
import "./mixins/MixinMooniswap.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinUniswapV2.sol";
@ -36,6 +37,7 @@ contract BSCBridgeAdapter is
MixinDodoV2,
MixinKyberDmm,
MixinKyberElastic,
MixinMaverickV1,
MixinMooniswap,
MixinNerve,
MixinUniswapV2,
@ -103,6 +105,11 @@ contract BSCBridgeAdapter is
return (0, true);
}
boughtAmount = _tradeWOOFi(sellToken, buyToken, sellAmount, order.bridgeData);
} else if (protocolId == BridgeProtocols.MAVERICK) {
if (dryRun) {
return (0, true);
}
boughtAmount = _tradeMaverickV1(sellToken, buyToken, sellAmount, order.bridgeData);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) {
return (0, true);

View File

@ -22,6 +22,7 @@ import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinBalancerV2Batch.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinMaverickV1.sol";
import "./mixins/MixinSolidly.sol";
contract BaseBridgeAdapter is
@ -31,6 +32,7 @@ contract BaseBridgeAdapter is
MixinBalancerV2Batch,
MixinCurve,
MixinCurveV2,
MixinMaverickV1,
MixinSolidly
{
constructor(IEtherToken weth) public MixinCurve(weth) {}
@ -73,6 +75,11 @@ contract BaseBridgeAdapter is
return (0, true);
}
boughtAmount = _tradeBalancerV2Batch(sellAmount, order.bridgeData);
} else if (protocolId == BridgeProtocols.MAVERICK) {
if (dryRun) {
return (0, true);
}
boughtAmount = _tradeMaverickV1(sellToken, buyToken, sellAmount, order.bridgeData);
}
emit BridgeFill(order.source, sellToken, buyToken, sellAmount, boughtAmount);
}

View File

@ -58,4 +58,5 @@ library BridgeProtocols {
uint128 internal constant BARTER = 34;
uint128 internal constant TRADERJOEV2 = 35;
uint128 internal constant VELODROMEV2 = 36;
uint128 internal constant MAVERICK = 37;
}

View File

@ -32,6 +32,7 @@ import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinKyberElastic.sol";
import "./mixins/MixinLido.sol";
import "./mixins/MixinMakerPSM.sol";
import "./mixins/MixinMaverickV1.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinSynthetix.sol";
import "./mixins/MixinUniswap.sol";
@ -56,6 +57,7 @@ contract EthereumBridgeAdapter is
MixinKyberElastic,
MixinLido,
MixinMakerPSM,
MixinMaverickV1,
MixinNerve,
MixinSynthetix,
MixinUniswap,
@ -175,6 +177,11 @@ contract EthereumBridgeAdapter is
return (0, true);
}
boughtAmount = _tradeBarter(sellToken, sellAmount, order.bridgeData);
} else if (protocolId == BridgeProtocols.MAVERICK) {
if (dryRun) {
return (0, true);
}
boughtAmount = _tradeMaverickV1(sellToken, buyToken, sellAmount, order.bridgeData);
} else if (protocolId == BridgeProtocols.UNKNOWN) {
if (dryRun) {
return (0, true);

View File

@ -0,0 +1,63 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2023 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/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/src/IERC20Token.sol";
interface IMaverickV1Router {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
address pool;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint256 sqrtPriceLimitD18;
}
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
}
contract MixinMaverickV1 {
using LibERC20TokenV06 for IERC20Token;
function _tradeMaverickV1(
IERC20Token sellToken,
IERC20Token buyToken,
uint256 sellAmount,
bytes memory bridgeData
) internal returns (uint256 boughtAmount) {
(IMaverickV1Router router, address pool) = abi.decode(bridgeData, (IMaverickV1Router, address));
// Grant the MaverickV1 router an allowance to sell the sellToken
sellToken.approveIfBelow(address(router), sellAmount);
boughtAmount = router.exactInputSingle(
IMaverickV1Router.ExactInputSingleParams({
tokenIn: address(sellToken),
tokenOut: address(buyToken),
pool: pool,
recipient: address(this),
deadline: block.timestamp,
amountIn: sellAmount,
amountOutMinimum: 1,
sqrtPriceLimitD18: 0
})
);
}
}

View File

@ -1,4 +1,12 @@
[
{
"version": "8.11.0",
"changes": [
{
"note": "Add MaverickV1 support on Ethereum, BSC, and Base"
}
]
},
{
"version": "8.10.0",
"changes": [

View File

@ -18,7 +18,7 @@
"wethTransformer": "0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7",
"payTakerTransformer": "0xea500d073652336a58846ada15c25f2c6d2d241f",
"affiliateFeeTransformer": "0x8146cbbe327364b13d0699f2ced39c637f92501a",
"fillQuoteTransformer": "0x21c3bee93fad436dedd29f971dc4fdf82f3e3a3a",
"fillQuoteTransformer": "0x2fd08c1f9fc8406c1d7e3a799a13883a7e7949f0",
"positiveSlippageFeeTransformer": "0x818a4a855bfeb16c305cb65e8d4fb239a308bc48"
}
},
@ -64,7 +64,7 @@
"wethTransformer": "0xac3d95668c092e895cd83a9cbafe9c7d9906471f",
"payTakerTransformer": "0x7e788f3a3e39cdd1944ba111fafc5fb7e59b5e90",
"affiliateFeeTransformer": "0x043300d113de0c64684ab89c56a45cd94c7ef54c",
"fillQuoteTransformer": "0xa9c57c539690d4e1439411f648ead5b121b34a23",
"fillQuoteTransformer": "0x6073f12fc63bcc64bd4fed5d44aa1035e37d68ee",
"positiveSlippageFeeTransformer": "0x6ff35e8cbaf56d8a8f6bf9963b902a4576243030"
}
},
@ -271,7 +271,7 @@
"wethTransformer": "0x63186ea36e78ecbf0128e448362f1b81e9bf7412",
"payTakerTransformer": "0x5cc22a0e06ea11097c612a962e63674b90e96099",
"affiliateFeeTransformer": "0x9e52d8b32d835206d09810c310593bcc77264066",
"fillQuoteTransformer": "0x98b159db76c820dc877782f199e287a97420b1d2",
"fillQuoteTransformer": "0xab93d03a3e7e51ec5edaef75d27f20917da4c18e",
"positiveSlippageFeeTransformer": "0xf98a130d3b4029c70e6d93098cb82a003421341e"
}
}

View File

@ -1,4 +1,12 @@
[
{
"version": "11.24.0",
"changes": [
{
"note": "Add MaverickV1 support on Ethereum, BSC, and Base"
}
]
},
{
"version": "11.23.0",
"changes": [

View File

@ -167,6 +167,7 @@ export enum BridgeProtocol {
Barter,
TraderJoeV2,
VelodromeV2,
MaverickV1,
}
/**