feat: asset-swapper Fake Taker contract (#151)

This commit is contained in:
Jacob Evans 2021-02-22 08:32:53 +10:00 committed by GitHub
parent 297342092b
commit fa78d1092a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 42 additions and 3 deletions

View File

@ -29,6 +29,10 @@
{ {
"note": "Special case BNB in uni v1 sampler", "note": "Special case BNB in uni v1 sampler",
"pr": 147 "pr": 147
},
{
"note": "Create `FakeTaker` contract to get result data and gas used",
"pr": 151
} }
] ]
}, },

View File

@ -0,0 +1,27 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
contract FakeTaker {
struct Result {
bool success;
bytes resultData;
uint256 gasUsed;
}
receive() payable external {}
function execute(address payable to, bytes calldata data)
public
payable
returns (Result memory result)
{
uint256 gasBefore = gasleft();
(
result.success,
result.resultData
) = to.call{ value: msg.value }(data);
result.gasUsed = gasBefore - gasleft();
}
}

View File

@ -36,9 +36,9 @@
"publish:private": "yarn build && gitpkg publish" "publish:private": "yarn build && gitpkg publish"
}, },
"config": { "config": {
"publicInterfaceContracts": "ERC20BridgeSampler,BalanceChecker", "publicInterfaceContracts": "ERC20BridgeSampler,BalanceChecker,FakeTaker",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BancorSampler|CurveSampler|DODOSampler|DeploymentConstants|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|IBalancer|IBancor|ICurve|IEth2Dai|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|IUniswapExchangeQuotes|IUniswapV2Router01|KyberSampler|LiquidityProviderSampler|MStableSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SushiSwapSampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UtilitySampler).json", "abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BancorSampler|CurveSampler|DODOSampler|DeploymentConstants|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|FakeTaker|IBalancer|IBancor|ICurve|IEth2Dai|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|IUniswapExchangeQuotes|IUniswapV2Router01|KyberSampler|LiquidityProviderSampler|MStableSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SushiSwapSampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UtilitySampler).json",
"postpublish": { "postpublish": {
"assets": [] "assets": []
} }

View File

@ -7,7 +7,9 @@ import { ContractArtifact } from 'ethereum-types';
import * as BalanceChecker from '../generated-artifacts/BalanceChecker.json'; import * as BalanceChecker from '../generated-artifacts/BalanceChecker.json';
import * as ERC20BridgeSampler from '../generated-artifacts/ERC20BridgeSampler.json'; import * as ERC20BridgeSampler from '../generated-artifacts/ERC20BridgeSampler.json';
import * as FakeTaker from '../generated-artifacts/FakeTaker.json';
export const artifacts = { export const artifacts = {
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact, ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
BalanceChecker: BalanceChecker as ContractArtifact, BalanceChecker: BalanceChecker as ContractArtifact,
FakeTaker: FakeTaker as ContractArtifact,
}; };

View File

@ -162,7 +162,7 @@ export {
QuoteReportEntry, QuoteReportEntry,
} from './utils/quote_report_generator'; } from './utils/quote_report_generator';
export { QuoteRequestor } from './utils/quote_requestor'; export { QuoteRequestor } from './utils/quote_requestor';
export { ERC20BridgeSamplerContract, BalanceCheckerContract } from './wrappers'; export { ERC20BridgeSamplerContract, BalanceCheckerContract, FakeTakerContract } from './wrappers';
import { ERC20BridgeSource } from './utils/market_operation_utils/types'; import { ERC20BridgeSource } from './utils/market_operation_utils/types';
export type Native = ERC20BridgeSource.Native; export type Native = ERC20BridgeSource.Native;
export type MultiHop = ERC20BridgeSource.MultiHop; export type MultiHop = ERC20BridgeSource.MultiHop;

View File

@ -5,3 +5,4 @@
*/ */
export * from '../generated-wrappers/balance_checker'; export * from '../generated-wrappers/balance_checker';
export * from '../generated-wrappers/erc20_bridge_sampler'; export * from '../generated-wrappers/erc20_bridge_sampler';
export * from '../generated-wrappers/fake_taker';

View File

@ -15,6 +15,7 @@ import * as DODOSampler from '../test/generated-artifacts/DODOSampler.json';
import * as DummyLiquidityProvider from '../test/generated-artifacts/DummyLiquidityProvider.json'; import * as DummyLiquidityProvider from '../test/generated-artifacts/DummyLiquidityProvider.json';
import * as ERC20BridgeSampler from '../test/generated-artifacts/ERC20BridgeSampler.json'; import * as ERC20BridgeSampler from '../test/generated-artifacts/ERC20BridgeSampler.json';
import * as Eth2DaiSampler from '../test/generated-artifacts/Eth2DaiSampler.json'; import * as Eth2DaiSampler from '../test/generated-artifacts/Eth2DaiSampler.json';
import * as FakeTaker from '../test/generated-artifacts/FakeTaker.json';
import * as IBalancer from '../test/generated-artifacts/IBalancer.json'; import * as IBalancer from '../test/generated-artifacts/IBalancer.json';
import * as IBancor from '../test/generated-artifacts/IBancor.json'; import * as IBancor from '../test/generated-artifacts/IBancor.json';
import * as ICurve from '../test/generated-artifacts/ICurve.json'; import * as ICurve from '../test/generated-artifacts/ICurve.json';
@ -51,6 +52,7 @@ export const artifacts = {
DeploymentConstants: DeploymentConstants as ContractArtifact, DeploymentConstants: DeploymentConstants as ContractArtifact,
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact, ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
Eth2DaiSampler: Eth2DaiSampler as ContractArtifact, Eth2DaiSampler: Eth2DaiSampler as ContractArtifact,
FakeTaker: FakeTaker as ContractArtifact,
KyberSampler: KyberSampler as ContractArtifact, KyberSampler: KyberSampler as ContractArtifact,
LiquidityProviderSampler: LiquidityProviderSampler as ContractArtifact, LiquidityProviderSampler: LiquidityProviderSampler as ContractArtifact,
MStableSampler: MStableSampler as ContractArtifact, MStableSampler: MStableSampler as ContractArtifact,

View File

@ -13,6 +13,7 @@ export * from '../test/generated-wrappers/deployment_constants';
export * from '../test/generated-wrappers/dummy_liquidity_provider'; export * from '../test/generated-wrappers/dummy_liquidity_provider';
export * from '../test/generated-wrappers/erc20_bridge_sampler'; export * from '../test/generated-wrappers/erc20_bridge_sampler';
export * from '../test/generated-wrappers/eth2_dai_sampler'; export * from '../test/generated-wrappers/eth2_dai_sampler';
export * from '../test/generated-wrappers/fake_taker';
export * from '../test/generated-wrappers/i_balancer'; export * from '../test/generated-wrappers/i_balancer';
export * from '../test/generated-wrappers/i_bancor'; export * from '../test/generated-wrappers/i_bancor';
export * from '../test/generated-wrappers/i_curve'; export * from '../test/generated-wrappers/i_curve';

View File

@ -5,6 +5,7 @@
"files": [ "files": [
"generated-artifacts/BalanceChecker.json", "generated-artifacts/BalanceChecker.json",
"generated-artifacts/ERC20BridgeSampler.json", "generated-artifacts/ERC20BridgeSampler.json",
"generated-artifacts/FakeTaker.json",
"test/generated-artifacts/ApproximateBuys.json", "test/generated-artifacts/ApproximateBuys.json",
"test/generated-artifacts/BalanceChecker.json", "test/generated-artifacts/BalanceChecker.json",
"test/generated-artifacts/BalancerSampler.json", "test/generated-artifacts/BalancerSampler.json",
@ -15,6 +16,7 @@
"test/generated-artifacts/DummyLiquidityProvider.json", "test/generated-artifacts/DummyLiquidityProvider.json",
"test/generated-artifacts/ERC20BridgeSampler.json", "test/generated-artifacts/ERC20BridgeSampler.json",
"test/generated-artifacts/Eth2DaiSampler.json", "test/generated-artifacts/Eth2DaiSampler.json",
"test/generated-artifacts/FakeTaker.json",
"test/generated-artifacts/IBalancer.json", "test/generated-artifacts/IBalancer.json",
"test/generated-artifacts/IBancor.json", "test/generated-artifacts/IBancor.json",
"test/generated-artifacts/ICurve.json", "test/generated-artifacts/ICurve.json",