Adding Nerve Mixin to Arbitrum Bridge Adapter [TKR-554] (#579)

* adding Nerve Mixin to Arbitrum Bridge Adapter

* refactor bridgeAdapter to include currently deployed changes

* remove duplicate DODOV2

* removing DODO V1 from Arbitrum Bridge Adapter

* updating imports

* fixing CI: ganache tests

* Invalid caching configuration

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
Co-authored-by: Marcin Wolny <marcin@0xproject.com>
This commit is contained in:
Savarn Dontamsetti (Sav) 2022-09-20 10:54:50 -04:00 committed by GitHub
parent 1fa093be64
commit 09419a7909
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 25 deletions

View File

@ -3,7 +3,7 @@ version: 2.1
parameters:
cache_version:
type: string
default: v4
default: v5
jobs:
build:
@ -18,7 +18,7 @@ jobs:
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-feat/NerveMixinArbitrum
- restore_cache:
keys:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
@ -33,46 +33,46 @@ jobs:
- save_cache:
key: cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
paths:
- ~/project/contracts/erc20/node_modules
- ~/project/contracts/test-utils/node_modules
- ~/project/contracts/treasury/node_modules
- ~/project/contracts/utils/node_modules
- ~/project/contracts/zero-ex/node_modules
- ~/project/node_modules
- ~/project/packages/asset-swapper/node_modules
- ~/project/packages/contract-addresses/node_modules
- ~/project/packages/contract-artifacts/node_modules
- ~/project/packages/contract-wrappers/node_modules
- ~/project/packages/protocol-utils/node_modules
- ~/.cache/yarn
- save_cache:
key: lib-{{ .Environment.CIRCLE_BRANCH }}
key: lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
paths:
- ~/project/contracts/erc20/generated-artifacts/
- ~/project/contracts/erc20/generated-wrappers/
- ~/project/contracts/erc20/lib/
- ~/project/contracts/erc20/node_modules
- ~/project/contracts/erc20/test/generated-artifacts/
- ~/project/contracts/erc20/test/generated-wrappers/
- ~/project/contracts/test-utils/lib/
- ~/project/contracts/test-utils/node_modules
- ~/project/contracts/treasury/generated-artifacts/
- ~/project/contracts/treasury/generated-wrappers/
- ~/project/contracts/treasury/lib/
- ~/project/contracts/treasury/node_modules
- ~/project/contracts/treasury/test/generated-artifacts/
- ~/project/contracts/treasury/test/generated-wrappers/
- ~/project/contracts/utils/generated-artifacts/
- ~/project/contracts/utils/generated-wrappers/
- ~/project/contracts/utils/lib/
- ~/project/contracts/utils/node_modules
- ~/project/contracts/utils/test/generated-artifacts/
- ~/project/contracts/utils/test/generated-wrappers/
- ~/project/contracts/zero-ex/generated-artifacts/
- ~/project/contracts/zero-ex/generated-wrappers/
- ~/project/contracts/zero-ex/lib/
- ~/project/contracts/zero-ex/node_modules
- ~/project/contracts/zero-ex/test/generated-artifacts/
- ~/project/contracts/zero-ex/test/generated-wrappers/
- ~/project/packages/asset-swapper/node_modules
- ~/project/packages/contract-addresses/lib/
- ~/project/packages/contract-addresses/node_modules
- ~/project/packages/contract-artifacts/lib/
- ~/project/packages/contract-artifacts/node_modules
- ~/project/packages/contract-wrappers/lib/
- ~/project/packages/contract-wrappers/node_modules
- ~/project/packages/protocol-utils/lib/
- ~/project/packages/protocol-utils/node_modules
- store_artifacts:
path: ~/repo/packages/abi-gen/test-cli/output
- store_artifacts:
@ -88,7 +88,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run: yarn wsrun -p @0x/contracts-exchange -m --serial -c test:circleci
test-integrations-ganache:
resource_class: xlarge
@ -101,7 +101,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run: yarn wsrun -p @0x/contracts-integrations -m --serial -c test:circleci
test-contracts-staking-ganache:
resource_class: xlarge
@ -112,7 +112,7 @@ jobs:
- restore_cache:
keys:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run: yarn wsrun -p @0x/contracts-staking -m --serial -c test:circleci
test-contracts-extra-ganache:
resource_class: xlarge
@ -125,7 +125,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run: yarn wsrun -p @0x/contracts-exchange-forwarder -p @0x/contracts-coordinator -m --serial -c test:circleci
test-contracts-rest-ganache:
resource_class: xlarge
@ -143,7 +143,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run: |
yarn wsrun \
-p @0x/contracts-multisig \
@ -173,7 +173,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run: git submodule update --init --recursive
- run:
command: forge test
@ -198,7 +198,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run:
command: yarn test:publish:circleci
no_output_timeout: 1800
@ -214,7 +214,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run:
command: yarn test:generate_docs:circleci
no_output_timeout: 1200
@ -230,7 +230,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run: yarn wsrun -p @0x/contracts-test-utils -m --serial -c test:circleci
- run: yarn wsrun -p @0x/contract-addresses -m --serial -c test:circleci
- run: yarn wsrun -p @0x/contract-artifacts -m --serial -c test:circleci
@ -257,7 +257,10 @@ jobs:
- restore_cache:
keys:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- run:
command: yarn lerna run lint
- run:
@ -275,7 +278,7 @@ jobs:
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- lib-{{ .Environment.CIRCLE_BRANCH }}
- lib-{{ .Environment.CIRCLE_BRANCH }}-<< pipeline.parameters.cache_version >>
- restore_cache:
keys:
- coverage-contract-wrappers-test-{{ checksum "yarn.lock" }}

View File

@ -23,19 +23,29 @@ pragma experimental ABIEncoderV2;
import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinBalancerV2.sol";
import "./mixins/MixinBalancerV2Batch.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinDodoV2.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinGMX.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinUniswapV3.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinZeroExBridge.sol";
contract ArbitrumBridgeAdapter is
AbstractBridgeAdapter(42161, "Arbitrum"),
MixinBalancerV2,
MixinBalancerV2Batch,
MixinCurve,
MixinCurveV2,
MixinDodoV2,
MixinKyberDmm,
MixinGMX,
MixinNerve,
MixinUniswapV3,
MixinUniswapV2,
MixinZeroExBridge
{
constructor(IEtherTokenV06 weth)
@ -63,6 +73,12 @@ contract ArbitrumBridgeAdapter is
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.BALANCERV2BATCH) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeBalancerV2Batch(
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CURVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurve(
@ -71,6 +87,14 @@ contract ArbitrumBridgeAdapter is
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.CURVEV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeCurveV2(
sellToken,
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.DODOV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeDodoV2(
@ -78,6 +102,13 @@ contract ArbitrumBridgeAdapter is
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.KYBERDMM) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeKyberDmm(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV3(
@ -85,9 +116,23 @@ contract ArbitrumBridgeAdapter is
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeUniswapV2(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.GMX) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeGMX(
buyToken,
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.NERVE) {
if (dryRun) { return (0, true); }
boughtAmount = _tradeNerve(
sellToken,
sellAmount,
order.bridgeData

View File

@ -105,8 +105,8 @@ export enum FillQuoteTransformerSide {
export enum FillQuoteTransformerOrderType {
Bridge,
Limit,
Otc,
Rfq,
Otc,
}
/**