Merge pull request #2015 from 0xProject/feature/asset-swapper/bump-to-1.0.0
Version bump for asset-buyer and docs prep 1.0.0
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^2.1.1",
|
||||
"@0x/asset-swapper": "^0.0.5",
|
||||
"@0x/base-contract": "^5.1.2",
|
||||
"@0x/contract-wrappers": "^9.1.8",
|
||||
"@0x/order-utils": "^8.2.3",
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1563193019,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added optimization utils to consumer output",
|
||||
"pr": 1988
|
||||
},
|
||||
{
|
||||
"note": "Expanded test coverage",
|
||||
"pr": 1980
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1563957393,
|
||||
"version": "0.0.5",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/asset-swapper",
|
||||
"version": "0.0.5",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
|
||||
@@ -16,10 +16,10 @@ export {
|
||||
DataItem,
|
||||
StateMutability,
|
||||
EventParameter,
|
||||
TupleDataItem,
|
||||
ConstructorStateMutability,
|
||||
} from 'ethereum-types';
|
||||
|
||||
// TODO(dave4506): if this lives under the 0x.js library, then these type exports should be removed in favor of minimizing redundancy
|
||||
export { SignedOrder } from '@0x/types';
|
||||
export { BigNumber } from '@0x/utils';
|
||||
|
||||
@@ -36,6 +36,7 @@ export {
|
||||
SwapQuote,
|
||||
SwapQuoteConsumerOpts,
|
||||
CalldataInfo,
|
||||
ConsumerType,
|
||||
SwapQuoteGetOutputOpts,
|
||||
SwapQuoteExecutionOpts,
|
||||
SwapQuoteInfo,
|
||||
|
||||
@@ -77,7 +77,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase<Forward
|
||||
/**
|
||||
* Given a SwapQuote, returns 'SmartContractParamsInfo' for a forwarder extension call. See type definition of CalldataInfo for more information.
|
||||
* @param quote An object that conforms to SwapQuote. See type definition for more information.
|
||||
* @param opts Options for getting CalldataInfo. See type definition for more information.
|
||||
* @param opts Options for getting SmartContractParams. See type definition for more information.
|
||||
*/
|
||||
public async getSmartContractParamsOrThrowAsync(
|
||||
quote: SwapQuote,
|
||||
|
||||
@@ -44,6 +44,11 @@ export class SwapQuoteConsumer implements SwapQuoteConsumerBase<SmartContractPar
|
||||
this._forwarderConsumer = new ForwarderSwapQuoteConsumer(supportedProvider, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a SwapQuote, returns 'CalldataInfo' for a 0x exchange call. See type definition of CalldataInfo for more information.
|
||||
* @param quote An object that conforms to SwapQuote. See type definition for more information.
|
||||
* @param opts Options for getting SmartContractParams. See type definition for more information.
|
||||
*/
|
||||
public async getCalldataOrThrowAsync(
|
||||
quote: SwapQuote,
|
||||
opts: Partial<SwapQuoteGetOutputOpts>,
|
||||
@@ -53,6 +58,11 @@ export class SwapQuoteConsumer implements SwapQuoteConsumerBase<SmartContractPar
|
||||
return consumer.getCalldataOrThrowAsync(quote, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a SwapQuote, returns 'SmartContractParamsInfo' for a 0x exchange call. See type definition of SmartContractParamsInfo for more information.
|
||||
* @param quote An object that conforms to SwapQuote. See type definition for more information.
|
||||
* @param opts Options for getting SmartContractParams. See type definition for more information.
|
||||
*/
|
||||
public async getSmartContractParamsOrThrowAsync(
|
||||
quote: SwapQuote,
|
||||
opts: Partial<SwapQuoteGetOutputOpts>,
|
||||
@@ -62,6 +72,11 @@ export class SwapQuoteConsumer implements SwapQuoteConsumerBase<SmartContractPar
|
||||
return consumer.getSmartContractParamsOrThrowAsync(quote, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a SwapQuote and desired rate (in takerAsset), attempt to execute the swap.
|
||||
* @param quote An object that conforms to SwapQuote. See type definition for more information.
|
||||
* @param opts Options for getting CalldataInfo. See type definition for more information.
|
||||
*/
|
||||
public async executeSwapQuoteOrThrowAsync(
|
||||
quote: SwapQuote,
|
||||
opts: Partial<SwapQuoteExecutionOpts>,
|
||||
|
||||
@@ -373,6 +373,11 @@ export class SwapQuoter {
|
||||
return ordersAndFillableAmounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Util function to check if takerAddress's allowance is enough for 0x exchange contracts to conduct the swap specified by the swapQuote.
|
||||
* @param swapQuote The swapQuote in question to check enough allowance enabled for 0x exchange contracts to conduct the swap.
|
||||
* @param takerAddress The address of the taker of the provided swapQuote
|
||||
*/
|
||||
public async isTakerAddressAllowanceEnoughForBestAndWorstQuoteInfoAsync(
|
||||
swapQuote: SwapQuote,
|
||||
takerAddress: string,
|
||||
|
||||
@@ -25,6 +25,9 @@ export const docGenConfigs: DocGenConfigs = {
|
||||
'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ganache-core/index.d.ts#L8',
|
||||
'lightwallet.keystore':
|
||||
'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eth-lightwallet/index.d.ts#L36',
|
||||
// HACK: Asset-swapper specifies marketSell and marketBuy quotes with a descriminant MarketOperation Type to ignore the error, linking Buy and Sell to MarketOperation
|
||||
Buy: 'https://github.com/0xProject/0x-monorepo/blob/development/packages/types/src/index.ts',
|
||||
Sell: 'https://github.com/0xProject/0x-monorepo/blob/development/packages/types/src/index.ts',
|
||||
},
|
||||
// If a 0x package re-exports an external package, we should add a link to it's exported items here
|
||||
EXTERNAL_EXPORT_TO_LINK: {
|
||||
|
||||
18
packages/website/md/docs/asset_swapper/installation.md
Normal file
18
packages/website/md/docs/asset_swapper/installation.md
Normal file
@@ -0,0 +1,18 @@
|
||||
#### Install
|
||||
|
||||
```bash
|
||||
yarn add @0x/asset-swapper
|
||||
```
|
||||
|
||||
#### Import
|
||||
|
||||
```javascript
|
||||
import { SwapQuoter, SwapQuoteConsumer } from '@0x/asset-swapper';
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```javascript
|
||||
var SwapQuoter = require('@0x/asset-swapper').SwapQuoter;
|
||||
var SwapQuoteConsumer = require('@0x/asset-swapper').SwapQuoteConsumer;
|
||||
```
|
||||
1
packages/website/md/docs/asset_swapper/introduction.md
Normal file
1
packages/website/md/docs/asset_swapper/introduction.md
Normal file
@@ -0,0 +1 @@
|
||||
Welcome to the [asset-swapper](https://github.com/0xProject/0x-monorepo/tree/development/packages/asset-swapper) documentation! Asset-swapper is a library that provides an easy way to swap any ERC asset for another ERC asset for smart contract integrations, leveraging 0x liquidity.
|
||||
@@ -0,0 +1,42 @@
|
||||
import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs';
|
||||
import * as React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
|
||||
import { DocPackages } from 'ts/types';
|
||||
|
||||
import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container';
|
||||
|
||||
/* tslint:disable:no-var-requires */
|
||||
const IntroMarkdown = require('md/docs/asset_swapper/introduction');
|
||||
const InstallationMarkdown = require('md/docs/asset_swapper/installation');
|
||||
/* tslint:enable:no-var-requires */
|
||||
|
||||
const markdownSections = {
|
||||
introduction: 'introduction',
|
||||
installation: 'installation',
|
||||
};
|
||||
|
||||
const docsInfoConfig: DocsInfoConfig = {
|
||||
id: DocPackages.AssetSwapper,
|
||||
packageName: '@0x/asset-swapper',
|
||||
type: SupportedDocJson.TypeDoc,
|
||||
displayName: 'AssetSwapper',
|
||||
packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/asset-swapper',
|
||||
markdownMenu: {
|
||||
introduction: [markdownSections.introduction],
|
||||
install: [markdownSections.installation],
|
||||
},
|
||||
sectionNameToMarkdownByVersion: {
|
||||
'0.0.1': {
|
||||
[markdownSections.introduction]: IntroMarkdown,
|
||||
[markdownSections.installation]: InstallationMarkdown,
|
||||
},
|
||||
},
|
||||
markdownSections,
|
||||
};
|
||||
const mapStateToProps = getMapStateToProps(docsInfoConfig);
|
||||
|
||||
export const Documentation: React.ComponentClass<DocPageProps> = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(DocPageComponent);
|
||||
@@ -95,6 +95,9 @@ const LazyEthereumTypesDocumentation = createLazyComponent('Documentation', asyn
|
||||
const LazyAssetBuyerDocumentation = createLazyComponent('Documentation', async () =>
|
||||
import(/* webpackChunkName: "assetBuyerDocs" */ 'ts/containers/asset_buyer_documentation'),
|
||||
);
|
||||
const LazyAssetSwapperDocumentation = createLazyComponent('Documentation', async () =>
|
||||
import(/* webpackChunkName: "assetSwapperDocs" */ 'ts/containers/asset_swapper_documentation'),
|
||||
);
|
||||
|
||||
const DOCUMENT_TITLE = '0x: The Protocol for Trading Tokens';
|
||||
const DOCUMENT_DESCRIPTION = 'An Open Protocol For Decentralized Exchange On The Ethereum Blockchain';
|
||||
@@ -204,6 +207,10 @@ render(
|
||||
path={`${WebsitePaths.AssetBuyer}/:version?`}
|
||||
component={LazyAssetBuyerDocumentation}
|
||||
/>
|
||||
<Route
|
||||
path={`${WebsitePaths.AssetSwapper}/:version?`}
|
||||
component={LazyAssetSwapperDocumentation}
|
||||
/>
|
||||
<Route path={WebsitePaths.Docs} component={DocsHome as any} />
|
||||
{/* Legacy endpoints */}
|
||||
<Route
|
||||
|
||||
@@ -39,6 +39,7 @@ const docIdToSubpackageName: { [id: string]: string } = {
|
||||
[DocPackages.OrderWatcher]: 'order-watcher',
|
||||
[DocPackages.EthereumTypes]: 'ethereum-types',
|
||||
[DocPackages.AssetBuyer]: 'asset-buyer',
|
||||
[DocPackages.AssetSwapper]: 'asset-swapper',
|
||||
[DocPackages.Migrations]: 'migrations',
|
||||
};
|
||||
|
||||
|
||||
@@ -170,10 +170,17 @@ const CATEGORY_TO_PACKAGES: ObjectMap<Package[]> = {
|
||||
description:
|
||||
'Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute [Wrapped Ether](https://weth.io/) based 0x orders without having to set allowances, wrap Ether or own ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset.',
|
||||
link: {
|
||||
title: '@0x/asset-buyer',
|
||||
title: '@0x/asset-buyer [Deprecated]',
|
||||
to: WebsitePaths.AssetBuyer,
|
||||
},
|
||||
},
|
||||
{
|
||||
description: 'Convenience package for discovering and performing swaps for any ERC Assets',
|
||||
link: {
|
||||
title: '@0x/asset-swapper',
|
||||
to: WebsitePaths.AssetSwapper,
|
||||
},
|
||||
},
|
||||
],
|
||||
[Categories.ZeroExProtocolPython]: [
|
||||
{
|
||||
|
||||
@@ -472,6 +472,7 @@ export enum WebsitePaths {
|
||||
OrderUtils = '/docs/order-utils',
|
||||
EthereumTypes = '/docs/ethereum-types',
|
||||
AssetBuyer = '/docs/asset-buyer',
|
||||
AssetSwapper = '/docs/asset-swapper',
|
||||
Migrations = '/docs/migrations',
|
||||
Careers = '/careers',
|
||||
Credits = '/credits',
|
||||
@@ -496,6 +497,7 @@ export enum DocPackages {
|
||||
ContractWrappers = 'CONTRACT_WRAPPERS',
|
||||
OrderWatcher = 'ORDER_WATCHER',
|
||||
AssetBuyer = 'ASSET_BUYER',
|
||||
AssetSwapper = 'ASSET_SWAPPER',
|
||||
Migrations = 'MIGRATIONS',
|
||||
}
|
||||
|
||||
@@ -559,6 +561,7 @@ export enum Key {
|
||||
ContractWrappers = 'CONTRACT_WRAPPERS',
|
||||
OrderWatcher = 'ORDER_WATCHER',
|
||||
AssetBuyer = 'ASSET_BUYER',
|
||||
AssetSwapper = 'ASSET_SWAPPER',
|
||||
Blog = 'BLOG',
|
||||
Forum = 'FORUM',
|
||||
Connect = 'CONNECT',
|
||||
|
||||
46
yarn.lock
46
yarn.lock
@@ -672,6 +672,28 @@
|
||||
ethereum-types "^2.1.2"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/asset-swapper@^0.0.5":
|
||||
version "0.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@0x/asset-swapper/-/asset-swapper-0.0.5.tgz#8f0493f5496e7ad50d09173a6809c8f0ae3683c3"
|
||||
integrity sha512-Juah8/smjoTWIJlJ2iJkrfCJTKgdAOqGV4KvV4Uyd/+RADtgPyHXRHaz13h3v6BzRmDOPVWTunYXUR53AR8PZw==
|
||||
dependencies:
|
||||
"@0x/assert" "^2.1.1"
|
||||
"@0x/connect" "^5.0.14"
|
||||
"@0x/contract-addresses" "^3.0.2"
|
||||
"@0x/contract-wrappers" "^9.1.8"
|
||||
"@0x/dev-utils" "^2.2.5"
|
||||
"@0x/fill-scenarios" "^3.0.14"
|
||||
"@0x/json-schemas" "^3.1.11"
|
||||
"@0x/migrations" "^4.1.10"
|
||||
"@0x/order-utils" "^8.2.3"
|
||||
"@0x/subproviders" "^4.1.2"
|
||||
"@0x/types" "^2.4.1"
|
||||
"@0x/typescript-typings" "^4.2.4"
|
||||
"@0x/utils" "^4.4.1"
|
||||
"@0x/web3-wrapper" "^6.0.8"
|
||||
ethereum-types "^2.1.4"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/base-contract@^4.0.1", "@0x/base-contract@^4.0.3":
|
||||
version "4.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@0x/base-contract/-/base-contract-4.0.3.tgz#ea5e3640824ee096813350e55546d98455a57805"
|
||||
@@ -8416,10 +8438,27 @@ got@^6.7.1:
|
||||
unzip-response "^2.0.1"
|
||||
url-parse-lax "^1.0.0"
|
||||
|
||||
graceful-fs@4.1.15, graceful-fs@^3.0.0, graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@~1.2.0:
|
||||
graceful-fs@^3.0.0:
|
||||
version "3.0.11"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818"
|
||||
integrity sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=
|
||||
dependencies:
|
||||
natives "^1.1.0"
|
||||
|
||||
graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
|
||||
version "4.1.15"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
|
||||
|
||||
graceful-fs@^4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b"
|
||||
integrity sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==
|
||||
|
||||
graceful-fs@~1.2.0:
|
||||
version "1.2.3"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364"
|
||||
integrity sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=
|
||||
|
||||
"graceful-readlink@>= 1.0.0":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
|
||||
@@ -11901,6 +11940,11 @@ nanomatch@^1.2.9:
|
||||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
natives@^1.1.0:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb"
|
||||
integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==
|
||||
|
||||
natural-compare@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||
|
||||
Reference in New Issue
Block a user