diff options
Diffstat (limited to 'packages/website/md/docs/asset_buyer')
-rw-r--r-- | packages/website/md/docs/asset_buyer/installation.md | 17 | ||||
-rw-r--r-- | packages/website/md/docs/asset_buyer/introduction.md | 1 | ||||
-rw-r--r-- | packages/website/md/docs/asset_buyer/usage.md | 39 |
3 files changed, 0 insertions, 57 deletions
diff --git a/packages/website/md/docs/asset_buyer/installation.md b/packages/website/md/docs/asset_buyer/installation.md deleted file mode 100644 index 3c0c95068..000000000 --- a/packages/website/md/docs/asset_buyer/installation.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Install - -```bash -yarn add @0x/asset-buyer -``` - -#### Import - -```javascript -import { AssetBuyer } from '@0x/asset-buyer'; -``` - -or - -```javascript -var AssetBuyer = require('@0x/asset-buyer').AssetBuyer; -``` diff --git a/packages/website/md/docs/asset_buyer/introduction.md b/packages/website/md/docs/asset_buyer/introduction.md deleted file mode 100644 index bac81c760..000000000 --- a/packages/website/md/docs/asset_buyer/introduction.md +++ /dev/null @@ -1 +0,0 @@ -Welcome to the [asset-buyer](https://github.com/0xProject/0x-monorepo/tree/development/packages/asset-buyer) documentation! AssetBuyer is a library that provides an easy way to buy any asset with ETH in one click, leveraging 0x liquidity and the [Forwarder contract](https://0x.org/docs/contracts#Forwarder). diff --git a/packages/website/md/docs/asset_buyer/usage.md b/packages/website/md/docs/asset_buyer/usage.md deleted file mode 100644 index 209c15062..000000000 --- a/packages/website/md/docs/asset_buyer/usage.md +++ /dev/null @@ -1,39 +0,0 @@ -#### Construction - -Connecting to a standard relayer API compliant url: - -```typescript -const provider = web3.currentProvider; -const apiUrl = 'https://api.relayer.com/v2'; -const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, apiUrl); -``` - -Providing your own orders: - -```typescript -const provider = web3.currentProvider; -const orders = []; // get these from your own API, a relayer, a friend, from anywhere -const assetBuyer = AssetBuyer.getAssetBuyerForProvidedOrders(provider, orders); -``` - -#### Get a quote - -A [BuyQuote](#types-BuyQuote) object contains enough information to display buy information to an end user - -```typescript -const erc20TokenAddress = '0x5fa3c....'; -const amountToBuy = new BigNumber(50000000000000000000); -const buyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(erc20TokenAddress, amountToBuy); -const quoteInfo = buyQuote.worstCaseQuoteInfo; -console.log(quoteInfo.ethAmount); // the total amount the user needs to pay to buy the desired amount (including ZRX fees) -console.log(quoteInfo.feeAmount); // a portion of the total ethAmount above that was used to buy affiliate fees -console.log(quoteInfo.ethPerAssetPrice); // the rate that this quote provides (e.g. 0.0035ETH / REP) -``` - -#### Perform a buy - -Pass the [BuyQuote](#types-BuyQuote) object from above back to the assetBuyer in order to initiate the buy transaction - -```typescript -const txHash = await assetBuyer.executeBuyQuoteAsync(buyQuote); // the hash of the transaction submitted to the Ethereum network -``` |