Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge branch 'development' into fix/dev-tools-pages/finalTouches
Browse files Browse the repository at this point in the history
* development: (49 commits)
  upgrade to ddex api v3 (#1507)
  Add new deployment related instructions to pipeline README (#1499)
  feature: implement logging and friendly wallet name for Opera
  Fix prettier
  Add missing dependencies
  Remove second yarn call
  Add .gitkeep
  Rename sol-trace-based-tools-common to sol-tracing-utils
  Update packages/sol-trace/README.md
  Update packages/sol-trace/CHANGELOG.json
  Update packages/sol-trace-based-tools-common/src/source_maps.ts
  Update packages/sol-trace-based-tools-common/CHANGELOG.json
  Update packages/sol-profiler/CHANGELOG.json
  Update packages/sol-coverage/CHANGELOG.json
  Update packages/monorepo-scripts/src/test_installation.ts
  chore: changelog update
  fix: account for undefined errors in promisify, not only null
  Clean up docs before publish
  In README's, don't mention non-existent tests (#1497)
  fix: use getBackendBaseUrl instead of hardcoded string
  ...
  • Loading branch information
fabioberger committed Jan 10, 2019
2 parents a516b00 + a5b7a35 commit 583e690
Show file tree
Hide file tree
Showing 167 changed files with 1,631 additions and 722 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
command: sudo npm install --global [email protected]
- run:
name: yarn
command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install
command: yarn --frozen-lockfile --ignore-engines install
- run: yarn build:ci:no_website
- run: yarn build:ts
- save_cache:
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
- run: yarn wsrun test:circleci @0x/order-utils
- run: yarn wsrun test:circleci @0x/order-watcher
- run: yarn wsrun test:circleci @0x/sol-compiler
- run: yarn wsrun test:circleci @0x/sol-cov
- run: yarn wsrun test:circleci @0x/sol-tracing-utils
- run: yarn wsrun test:circleci @0x/sol-doc
- run: yarn wsrun test:circleci @0x/subproviders
- run: yarn wsrun test:circleci @0x/web3-wrapper
Expand Down Expand Up @@ -169,9 +169,9 @@ jobs:
paths:
- ~/repo/packages/sol-compiler/coverage/lcov.info
- save_cache:
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
key: coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-cov/coverage/lcov.info
- ~/repo/packages/sol-tracing-utils/coverage/lcov.info
- save_cache:
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
paths:
Expand Down Expand Up @@ -335,7 +335,7 @@ jobs:
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
- coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
Expand Down
5 changes: 4 additions & 1 deletion .github/autolabeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ instant: ['packages/instant']
abi-gen-templates: ['packages/abi-gen-templates']
abi-gen: ['packages/abi-gen']
website: ['packages/website']
sol-cov: ['packages/sol-cov']
sol-coverage: ['packages/sol-coverage']
sol-profiler: ['packages/sol-profiler']
sol-trace: ['packages/sol-trace']
sol-tracing-utils: ['packages/sol-tracing-utils']
utils: ['packages/utils']
tslint-config: ['packages/tslint-config']
asset-buyer: ['packages/asset-buyer']
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contracts/interfaces/generated-artifacts/
contracts/tokens/generated-artifacts/
contracts/examples/generated-artifacts/
contracts/extensions/generated-artifacts/
packages/sol-cov/test/fixtures/artifacts/
packages/sol-tracing-utils/test/fixtures/artifacts/
packages/metacoin/artifacts/

# generated contract wrappers
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lib
/packages/dev-tools-pages/ts/**/data.json
package.json
scripts/postpublish_utils.js
packages/sol-cov/test/fixtures/artifacts
packages/sol-coverage/test/fixtures/artifacts
.pytest_cache
.mypy_cache
.tox
5 changes: 4 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ packages/metacoin/ @LogvinovLeon
packages/monorepo-scripts/ @fabioberger
packages/order-utils/ @fabioberger @LogvinovLeon
packages/sol-compiler/ @LogvinovLeon
packages/sol-cov/ @LogvinovLeon
packages/sol-coverage/ @LogvinovLeon
packages/sol-profiler/ @LogvinovLeon
packages/sol-trace/ @LogvinovLeon
packages/sol-tracing-utils/ @LogvinovLeon
packages/sol-resolver/ @LogvinovLeon
packages/subproviders/ @fabioberger @dekz
packages/verdaccio/ @albrow
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ Visit our [developer portal](https://0xproject.com/docs/order-utils) for a compr
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`@0x/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0x/web3-wrapper.svg)](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client |
| [`@0x/sol-compiler`](/packages/sol-compiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-compiler.svg)](https://www.npmjs.com/package/@0x/sol-compiler) | A wrapper around solc-js that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more. |
| [`@0x/sol-cov`](/packages/sol-cov) | [![npm](https://img.shields.io/npm/v/@0x/sol-cov.svg)](https://www.npmjs.com/package/@0x/sol-cov) | A solidity test coverage tool |
| [`@0x/sol-coverage`](/packages/sol-coverage) | [![npm](https://img.shields.io/npm/v/@0x/sol-coverage.svg)](https://www.npmjs.com/package/@0x/sol-coverage) | A solidity test coverage tool |
| [`@0x/sol-profiler`](/packages/sol-profiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-profiler.svg)](https://www.npmjs.com/package/@0x/sol-profiler) | A solidity gas cost profiler |
| [`@0x/sol-trace`](/packages/sol-trace) | [![npm](https://img.shields.io/npm/v/@0x/sol-trace.svg)](https://www.npmjs.com/package/@0x/sol-trace) | A solidity stack trace tool |
| [`@0x/sol-resolver`](/packages/sol-resolver) | [![npm](https://img.shields.io/npm/v/@0x/sol-resolver.svg)](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies |
| [`@0x/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0x/subproviders.svg)](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) |
| [`@0x/sol-doc`](/packages/sol-doc) | [![npm](https://img.shields.io/npm/v/@0x/sol-doc.svg)](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator |
Expand Down
2 changes: 1 addition & 1 deletion contracts/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST_PROVIDER=geth yarn test

## Code coverage

In order to see the Solidity code coverage output generated by `@0x/sol-cov`, run:
In order to see the Solidity code coverage output generated by `@0x/sol-coverage`, run:

```
yarn test:coverage
Expand Down
1 change: 0 additions & 1 deletion contracts/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@0x/contracts-test-utils": "^1.0.3",
"@0x/dev-utils": "^1.0.22",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"@0x/contracts-test-utils": "^1.0.3",
"@0x/dev-utils": "^1.0.22",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.3",
"@0x/dev-utils": "^1.0.22",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/multisig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.3",
"@0x/dev-utils": "^1.0.22",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@0x/abi-gen": "^1.0.20",
"@0x/dev-utils": "^1.0.22",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
4 changes: 3 additions & 1 deletion contracts/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/sol-coverage": "^1.0.0",
"@0x/sol-profiler": "^1.0.0",
"@0x/sol-trace": "^1.0.0",
"@0x/abi-gen": "^1.0.20",
"@0x/dev-utils": "^1.0.22",
"@0x/order-utils": "^3.1.0",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@0x/types": "^1.5.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/src/coverage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-coverage';
import * as _ from 'lodash';

let coverageSubprovider: CoverageSubprovider;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/src/profiler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-profiler';
import * as _ from 'lodash';

let profilerSubprovider: ProfilerSubprovider;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/src/revert_trace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { devConstants } from '@0x/dev-utils';
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-trace';
import * as _ from 'lodash';

let revertTraceSubprovider: RevertTraceSubprovider;
Expand Down
1 change: 0 additions & 1 deletion contracts/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.3",
"@0x/dev-utils": "^1.0.22",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
1 change: 0 additions & 1 deletion contracts/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@0x/contracts-test-utils": "^1.0.3",
"@0x/dev-utils": "^1.0.22",
"@0x/sol-compiler": "^2.0.0",
"@0x/sol-cov": "^2.1.17",
"@0x/subproviders": "^2.1.9",
"@0x/tslint-config": "^2.0.0",
"@types/bn.js": "^4.11.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"config": {
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
"packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types asset-buyer migrations"
"packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-coverage sol-profiler sol-trace ethereum-types asset-buyer migrations"
},
"bundlewatch": {
"files": [
Expand Down
9 changes: 9 additions & 0 deletions packages/asset-buyer/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "4.0.0",
"changes": [
{
"note": "Raise custom InsufficientAssetLiquidityError error with amountAvailableToFill attribute",
"pr": 1437
}
]
},
{
"timestamp": 1547040760,
"version": "3.0.5",
Expand Down
22 changes: 22 additions & 0 deletions packages/asset-buyer/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { BigNumber } from '@0x/utils';

import { AssetBuyerError } from './types';

/**
* Error class representing insufficient asset liquidity
*/
export class InsufficientAssetLiquidityError extends Error {
/**
* The amount availabe to fill (in base units) factoring in slippage.
*/
public amountAvailableToFill: BigNumber;
/**
* @param amountAvailableToFill The amount availabe to fill (in base units) factoring in slippage
*/
constructor(amountAvailableToFill: BigNumber) {
super(AssetBuyerError.InsufficientAssetLiquidity);
this.amountAvailableToFill = amountAvailableToFill;
// Setting prototype so instanceof works. See https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, InsufficientAssetLiquidityError.prototype);
}
}
1 change: 1 addition & 0 deletions packages/asset-buyer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { SignedOrder } from '@0x/types';
export { BigNumber } from '@0x/utils';

export { AssetBuyer } from './asset_buyer';
export { InsufficientAssetLiquidityError } from './errors';
export { BasicOrderProvider } from './order_providers/basic_order_provider';
export { StandardRelayerAPIOrderProvider } from './order_providers/standard_relayer_api_order_provider';
export {
Expand Down
2 changes: 1 addition & 1 deletion packages/asset-buyer/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export interface AssetBuyerOpts {
}

/**
* Possible errors thrown by an AssetBuyer instance or associated static methods.
* Possible error messages thrown by an AssetBuyer instance or associated static methods.
*/
export enum AssetBuyerError {
NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND',
Expand Down
14 changes: 13 additions & 1 deletion packages/asset-buyer/src/utils/buy_quote_calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';

import { constants } from '../constants';
import { InsufficientAssetLiquidityError } from '../errors';
import { AssetBuyerError, BuyQuote, BuyQuoteInfo, OrdersAndFillableAmounts } from '../types';

import { orderUtils } from './order_utils';
Expand Down Expand Up @@ -33,7 +34,18 @@ export const buyQuoteCalculator = {
});
// if we do not have enough orders to cover the desired assetBuyAmount, throw
if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) {
throw new Error(AssetBuyerError.InsufficientAssetLiquidity);
// We needed the amount they requested to buy, plus the amount for slippage
const totalAmountRequested = assetBuyAmount.plus(slippageBufferAmount);
const amountAbleToFill = totalAmountRequested.minus(remainingFillAmount);
// multiplierNeededWithSlippage represents what we need to multiply the assetBuyAmount by
// in order to get the total amount needed considering slippage
// i.e. if slippagePercent was 0.2 (20%), multiplierNeededWithSlippage would be 1.2
const multiplierNeededWithSlippage = new BigNumber(1).plus(slippagePercentage);
// Given amountAvailableToFillConsideringSlippage * multiplierNeededWithSlippage = amountAbleToFill
// We divide amountUnableToFill by multiplierNeededWithSlippage to determine amountAvailableToFillConsideringSlippage
const amountAvailableToFillConsideringSlippage = amountAbleToFill.div(multiplierNeededWithSlippage).floor();

throw new InsufficientAssetLiquidityError(amountAvailableToFillConsideringSlippage);
}
// if we are not buying ZRX:
// given the orders calculated above, find the fee-orders that cover the desired assetBuyAmount (with slippage)
Expand Down
Loading

0 comments on commit 583e690

Please sign in to comment.