Skip to content

Commit 7f324dd

Browse files
authored
feat/Add Maverick V1 Support (#741)
* Add Maverick V1 Support for Ethereum, BSC, and Base
1 parent e1f9e10 commit 7f324dd

10 files changed

Lines changed: 113 additions & 3 deletions

File tree

contracts/zero-ex/CHANGELOG.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"version": "0.47.0",
4+
"changes": [
5+
{
6+
"note": "Add MaverickV1 support on Ethereum, BSC, and Base"
7+
}
8+
]
9+
},
210
{
311
"version": "0.46.0",
412
"changes": [

contracts/zero-ex/contracts/src/transformers/bridges/BSCBridgeAdapter.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import "./mixins/MixinDodo.sol";
2222
import "./mixins/MixinDodoV2.sol";
2323
import "./mixins/MixinKyberDmm.sol";
2424
import "./mixins/MixinKyberElastic.sol";
25+
import "./mixins/MixinMaverickV1.sol";
2526
import "./mixins/MixinMooniswap.sol";
2627
import "./mixins/MixinNerve.sol";
2728
import "./mixins/MixinUniswapV2.sol";
@@ -36,6 +37,7 @@ contract BSCBridgeAdapter is
3637
MixinDodoV2,
3738
MixinKyberDmm,
3839
MixinKyberElastic,
40+
MixinMaverickV1,
3941
MixinMooniswap,
4042
MixinNerve,
4143
MixinUniswapV2,
@@ -103,6 +105,11 @@ contract BSCBridgeAdapter is
103105
return (0, true);
104106
}
105107
boughtAmount = _tradeWOOFi(sellToken, buyToken, sellAmount, order.bridgeData);
108+
} else if (protocolId == BridgeProtocols.MAVERICK) {
109+
if (dryRun) {
110+
return (0, true);
111+
}
112+
boughtAmount = _tradeMaverickV1(sellToken, buyToken, sellAmount, order.bridgeData);
106113
} else if (protocolId == BridgeProtocols.UNKNOWN) {
107114
if (dryRun) {
108115
return (0, true);

contracts/zero-ex/contracts/src/transformers/bridges/BaseBridgeAdapter.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import "./mixins/MixinUniswapV2.sol";
2222
import "./mixins/MixinBalancerV2Batch.sol";
2323
import "./mixins/MixinCurve.sol";
2424
import "./mixins/MixinCurveV2.sol";
25+
import "./mixins/MixinMaverickV1.sol";
2526
import "./mixins/MixinSolidly.sol";
2627

2728
contract BaseBridgeAdapter is
@@ -31,6 +32,7 @@ contract BaseBridgeAdapter is
3132
MixinBalancerV2Batch,
3233
MixinCurve,
3334
MixinCurveV2,
35+
MixinMaverickV1,
3436
MixinSolidly
3537
{
3638
constructor(IEtherToken weth) public MixinCurve(weth) {}
@@ -73,6 +75,11 @@ contract BaseBridgeAdapter is
7375
return (0, true);
7476
}
7577
boughtAmount = _tradeBalancerV2Batch(sellAmount, order.bridgeData);
78+
} else if (protocolId == BridgeProtocols.MAVERICK) {
79+
if (dryRun) {
80+
return (0, true);
81+
}
82+
boughtAmount = _tradeMaverickV1(sellToken, buyToken, sellAmount, order.bridgeData);
7683
}
7784
emit BridgeFill(order.source, sellToken, buyToken, sellAmount, boughtAmount);
7885
}

contracts/zero-ex/contracts/src/transformers/bridges/BridgeProtocols.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ library BridgeProtocols {
5858
uint128 internal constant BARTER = 34;
5959
uint128 internal constant TRADERJOEV2 = 35;
6060
uint128 internal constant VELODROMEV2 = 36;
61+
uint128 internal constant MAVERICK = 37;
6162
}

contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapter.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import "./mixins/MixinKyberDmm.sol";
3232
import "./mixins/MixinKyberElastic.sol";
3333
import "./mixins/MixinLido.sol";
3434
import "./mixins/MixinMakerPSM.sol";
35+
import "./mixins/MixinMaverickV1.sol";
3536
import "./mixins/MixinNerve.sol";
3637
import "./mixins/MixinSynthetix.sol";
3738
import "./mixins/MixinUniswap.sol";
@@ -56,6 +57,7 @@ contract EthereumBridgeAdapter is
5657
MixinKyberElastic,
5758
MixinLido,
5859
MixinMakerPSM,
60+
MixinMaverickV1,
5961
MixinNerve,
6062
MixinSynthetix,
6163
MixinUniswap,
@@ -175,6 +177,11 @@ contract EthereumBridgeAdapter is
175177
return (0, true);
176178
}
177179
boughtAmount = _tradeBarter(sellToken, sellAmount, order.bridgeData);
180+
} else if (protocolId == BridgeProtocols.MAVERICK) {
181+
if (dryRun) {
182+
return (0, true);
183+
}
184+
boughtAmount = _tradeMaverickV1(sellToken, buyToken, sellAmount, order.bridgeData);
178185
} else if (protocolId == BridgeProtocols.UNKNOWN) {
179186
if (dryRun) {
180187
return (0, true);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
/*
3+
Copyright 2023 ZeroEx Intl.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
pragma solidity ^0.6.5;
16+
pragma experimental ABIEncoderV2;
17+
18+
import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol";
19+
import "@0x/contracts-erc20/src/IERC20Token.sol";
20+
21+
interface IMaverickV1Router {
22+
struct ExactInputSingleParams {
23+
address tokenIn;
24+
address tokenOut;
25+
address pool;
26+
address recipient;
27+
uint256 deadline;
28+
uint256 amountIn;
29+
uint256 amountOutMinimum;
30+
uint256 sqrtPriceLimitD18;
31+
}
32+
33+
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
34+
}
35+
36+
contract MixinMaverickV1 {
37+
using LibERC20TokenV06 for IERC20Token;
38+
39+
function _tradeMaverickV1(
40+
IERC20Token sellToken,
41+
IERC20Token buyToken,
42+
uint256 sellAmount,
43+
bytes memory bridgeData
44+
) internal returns (uint256 boughtAmount) {
45+
(IMaverickV1Router router, address pool) = abi.decode(bridgeData, (IMaverickV1Router, address));
46+
47+
// Grant the MaverickV1 router an allowance to sell the sellToken
48+
sellToken.approveIfBelow(address(router), sellAmount);
49+
50+
boughtAmount = router.exactInputSingle(
51+
IMaverickV1Router.ExactInputSingleParams({
52+
tokenIn: address(sellToken),
53+
tokenOut: address(buyToken),
54+
pool: pool,
55+
recipient: address(this),
56+
deadline: block.timestamp,
57+
amountIn: sellAmount,
58+
amountOutMinimum: 1,
59+
sqrtPriceLimitD18: 0
60+
})
61+
);
62+
}
63+
}

packages/contract-addresses/CHANGELOG.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"version": "8.11.0",
4+
"changes": [
5+
{
6+
"note": "Add MaverickV1 support on Ethereum, BSC, and Base"
7+
}
8+
]
9+
},
210
{
311
"version": "8.10.0",
412
"changes": [

packages/contract-addresses/addresses.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"wethTransformer": "0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7",
1919
"payTakerTransformer": "0xea500d073652336a58846ada15c25f2c6d2d241f",
2020
"affiliateFeeTransformer": "0x8146cbbe327364b13d0699f2ced39c637f92501a",
21-
"fillQuoteTransformer": "0x21c3bee93fad436dedd29f971dc4fdf82f3e3a3a",
21+
"fillQuoteTransformer": "0x2fd08c1f9fc8406c1d7e3a799a13883a7e7949f0",
2222
"positiveSlippageFeeTransformer": "0x818a4a855bfeb16c305cb65e8d4fb239a308bc48"
2323
}
2424
},
@@ -64,7 +64,7 @@
6464
"wethTransformer": "0xac3d95668c092e895cd83a9cbafe9c7d9906471f",
6565
"payTakerTransformer": "0x7e788f3a3e39cdd1944ba111fafc5fb7e59b5e90",
6666
"affiliateFeeTransformer": "0x043300d113de0c64684ab89c56a45cd94c7ef54c",
67-
"fillQuoteTransformer": "0xa9c57c539690d4e1439411f648ead5b121b34a23",
67+
"fillQuoteTransformer": "0x6073f12fc63bcc64bd4fed5d44aa1035e37d68ee",
6868
"positiveSlippageFeeTransformer": "0x6ff35e8cbaf56d8a8f6bf9963b902a4576243030"
6969
}
7070
},
@@ -271,7 +271,7 @@
271271
"wethTransformer": "0x63186ea36e78ecbf0128e448362f1b81e9bf7412",
272272
"payTakerTransformer": "0x5cc22a0e06ea11097c612a962e63674b90e96099",
273273
"affiliateFeeTransformer": "0x9e52d8b32d835206d09810c310593bcc77264066",
274-
"fillQuoteTransformer": "0x98b159db76c820dc877782f199e287a97420b1d2",
274+
"fillQuoteTransformer": "0xab93d03a3e7e51ec5edaef75d27f20917da4c18e",
275275
"positiveSlippageFeeTransformer": "0xf98a130d3b4029c70e6d93098cb82a003421341e"
276276
}
277277
}

packages/protocol-utils/CHANGELOG.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"version": "11.24.0",
4+
"changes": [
5+
{
6+
"note": "Add MaverickV1 support on Ethereum, BSC, and Base"
7+
}
8+
]
9+
},
210
{
311
"version": "11.23.0",
412
"changes": [

packages/protocol-utils/src/transformer_utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export enum BridgeProtocol {
167167
Barter,
168168
TraderJoeV2,
169169
VelodromeV2,
170+
MaverickV1,
170171
}
171172

172173
/**

0 commit comments

Comments
 (0)