feat: Add Barter support to EthereumBridgeAdapter [LIT-981] (#703)
This commit is contained in:
parent
57ca2c07bb
commit
5cc53597de
1
.gitignore
vendored
1
.gitignore
vendored
@ -99,6 +99,7 @@ foundry-artifacts/
|
|||||||
|
|
||||||
# foundry cache
|
# foundry cache
|
||||||
cache/
|
cache/
|
||||||
|
foundry-cache/
|
||||||
|
|
||||||
#foundry output artifacts
|
#foundry output artifacts
|
||||||
out/
|
out/
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "0.40.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add Barter support on Ethereum"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "0.39.2",
|
"version": "0.39.2",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -55,4 +55,5 @@ library BridgeProtocols {
|
|||||||
uint128 internal constant WOOFI = 31;
|
uint128 internal constant WOOFI = 31;
|
||||||
uint128 internal constant AAVEV3 = 32;
|
uint128 internal constant AAVEV3 = 32;
|
||||||
uint128 internal constant KYBERELASTIC = 33;
|
uint128 internal constant KYBERELASTIC = 33;
|
||||||
|
uint128 internal constant BARTER = 34;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import "./mixins/MixinBalancer.sol";
|
|||||||
import "./mixins/MixinBalancerV2Batch.sol";
|
import "./mixins/MixinBalancerV2Batch.sol";
|
||||||
import "./mixins/MixinBancor.sol";
|
import "./mixins/MixinBancor.sol";
|
||||||
import "./mixins/MixinBancorV3.sol";
|
import "./mixins/MixinBancorV3.sol";
|
||||||
|
import "./mixins/MixinBarter.sol";
|
||||||
import "./mixins/MixinCompound.sol";
|
import "./mixins/MixinCompound.sol";
|
||||||
import "./mixins/MixinCurve.sol";
|
import "./mixins/MixinCurve.sol";
|
||||||
import "./mixins/MixinCurveV2.sol";
|
import "./mixins/MixinCurveV2.sol";
|
||||||
@ -48,6 +49,7 @@ contract EthereumBridgeAdapter is
|
|||||||
MixinBalancerV2Batch,
|
MixinBalancerV2Batch,
|
||||||
MixinBancor,
|
MixinBancor,
|
||||||
MixinBancorV3,
|
MixinBancorV3,
|
||||||
|
MixinBarter,
|
||||||
MixinCompound,
|
MixinCompound,
|
||||||
MixinCurve,
|
MixinCurve,
|
||||||
MixinCurveV2,
|
MixinCurveV2,
|
||||||
@ -197,6 +199,11 @@ contract EthereumBridgeAdapter is
|
|||||||
return (0, true);
|
return (0, true);
|
||||||
}
|
}
|
||||||
boughtAmount = _tradeSynthetix(sellAmount, order.bridgeData);
|
boughtAmount = _tradeSynthetix(sellAmount, order.bridgeData);
|
||||||
|
} else if (protocolId == BridgeProtocols.BARTER) {
|
||||||
|
if (dryRun) {
|
||||||
|
return (0, true);
|
||||||
|
}
|
||||||
|
boughtAmount = _tradeBarter(sellToken, sellAmount, order.bridgeData);
|
||||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
return (0, true);
|
return (0, true);
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
// 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";
|
||||||
|
import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
|
||||||
|
|
||||||
|
contract MixinBarter {
|
||||||
|
using LibERC20TokenV06 for IERC20Token;
|
||||||
|
using LibRichErrorsV06 for bytes;
|
||||||
|
|
||||||
|
function _tradeBarter(
|
||||||
|
IERC20Token sellToken,
|
||||||
|
uint256 sellAmount,
|
||||||
|
bytes memory bridgeData
|
||||||
|
) internal returns (uint256 boughtAmount) {
|
||||||
|
(address barterRouter, bytes memory data) = abi.decode(bridgeData, (address, bytes));
|
||||||
|
sellToken.approveIfBelow(barterRouter, sellAmount);
|
||||||
|
|
||||||
|
(bool success, bytes memory resultData) = barterRouter.call(data);
|
||||||
|
if (!success) {
|
||||||
|
resultData.rrevert();
|
||||||
|
}
|
||||||
|
|
||||||
|
return abi.decode(resultData, (uint256));
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,12 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "11.19.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add Barter support"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "11.18.2",
|
"version": "11.18.2",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -164,6 +164,7 @@ export enum BridgeProtocol {
|
|||||||
WOOFi,
|
WOOFi,
|
||||||
AaveV3,
|
AaveV3,
|
||||||
KyberElastic,
|
KyberElastic,
|
||||||
|
Barter,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user