changes on affiliate fee and other changes
bumped version to 7 and added changelog updated package.json revert change to package.json trying this package.json config
This commit is contained in:
parent
ed02f4ca88
commit
11d5fec59b
@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "7.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add support for ERC<>ERC market buy support for asset-buyer and renamed to swap-quoter",
|
||||||
|
"pr": 1845
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1558712885,
|
"timestamp": 1558712885,
|
||||||
"version": "6.1.5",
|
"version": "6.1.5",
|
||||||
|
@ -81,6 +81,14 @@ export class SwapQuoter {
|
|||||||
const swapQuoter = new SwapQuoter(provider, orderProvider, options);
|
const swapQuoter = new SwapQuoter(provider, orderProvider, options);
|
||||||
return swapQuoter;
|
return swapQuoter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* get the key for _orderEntryMap for maker + taker asset pair
|
||||||
|
*/
|
||||||
|
private static _getOrdersEntryMapKey(makerAssetData: string, takerAssetData: string): string {
|
||||||
|
return `${makerAssetData}_${takerAssetData}`;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Instantiates a new SwapQuoter instance
|
* Instantiates a new SwapQuoter instance
|
||||||
* @param supportedProvider The Provider instance you would like to use for interacting with the Ethereum network.
|
* @param supportedProvider The Provider instance you would like to use for interacting with the Ethereum network.
|
||||||
@ -284,7 +292,7 @@ export class SwapQuoter {
|
|||||||
assetDataUtils.decodeAssetDataOrThrow(makerAssetData);
|
assetDataUtils.decodeAssetDataOrThrow(makerAssetData);
|
||||||
assetDataUtils.decodeAssetDataOrThrow(takerAssetData);
|
assetDataUtils.decodeAssetDataOrThrow(takerAssetData);
|
||||||
// try to get ordersEntry from the map
|
// try to get ordersEntry from the map
|
||||||
const ordersEntryIfExists = this._ordersEntryMap[this._getOrdersEntryMapKey(makerAssetData, takerAssetData)];
|
const ordersEntryIfExists = this._ordersEntryMap[SwapQuoter._getOrdersEntryMapKey(makerAssetData, takerAssetData)];
|
||||||
// we should refresh if:
|
// we should refresh if:
|
||||||
// we do not have any orders OR
|
// we do not have any orders OR
|
||||||
// we are forced to OR
|
// we are forced to OR
|
||||||
@ -324,19 +332,10 @@ export class SwapQuoter {
|
|||||||
ordersAndFillableAmounts,
|
ordersAndFillableAmounts,
|
||||||
lastRefreshTime,
|
lastRefreshTime,
|
||||||
};
|
};
|
||||||
this._ordersEntryMap[this._getOrdersEntryMapKey(makerAssetData, takerAssetData)] = updatedOrdersEntry;
|
this._ordersEntryMap[SwapQuoter._getOrdersEntryMapKey(makerAssetData, takerAssetData)] = updatedOrdersEntry;
|
||||||
return ordersAndFillableAmounts;
|
return ordersAndFillableAmounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* get the key for _orderEntryMap for maker + taker asset pair
|
|
||||||
*/
|
|
||||||
// tslint:disable-next-line: prefer-function-over-method
|
|
||||||
private _getOrdersEntryMapKey(makerAssetData: string, takerAssetData: string): string {
|
|
||||||
return `${makerAssetData}_${takerAssetData}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the assetData that represents the ZRX token.
|
* Get the assetData that represents the ZRX token.
|
||||||
* Will throw if ZRX does not exist for the current network.
|
* Will throw if ZRX does not exist for the current network.
|
||||||
|
@ -156,6 +156,10 @@ export interface SwapQuote {
|
|||||||
worstCaseQuoteInfo: SwapQuoteInfo;
|
worstCaseQuoteInfo: SwapQuoteInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SwapQuoteWithAffiliateFee extends SwapQuote {
|
||||||
|
feePercentage: number;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* assetEthAmount: The amount of eth required to pay for the requested asset.
|
* assetEthAmount: The amount of eth required to pay for the requested asset.
|
||||||
* feeEthAmount: The amount of eth required to pay any fee concerned with completing the swap.
|
* feeEthAmount: The amount of eth required to pay any fee concerned with completing the swap.
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { SwapQuote, SwapQuoteInfo } from '../types';
|
import { SwapQuote, SwapQuoteInfo, SwapQuoteWithAffiliateFee } from '../types';
|
||||||
|
|
||||||
export const affiliateFeeUtils = {
|
export const affiliateFeeUtils = {
|
||||||
getSwapQuoteWithAffiliateFee(quote: SwapQuote, feePercentage: number): SwapQuote {
|
getSwapQuoteWithAffiliateFee(quote: SwapQuote, feePercentage: number): SwapQuoteWithAffiliateFee {
|
||||||
const newQuote = _.clone(quote);
|
const newQuote = _.clone(quote);
|
||||||
newQuote.bestCaseQuoteInfo = getSwapQuoteInfoWithAffiliateFee(newQuote.bestCaseQuoteInfo, feePercentage);
|
newQuote.bestCaseQuoteInfo = getSwapQuoteInfoWithAffiliateFee(newQuote.bestCaseQuoteInfo, feePercentage);
|
||||||
newQuote.worstCaseQuoteInfo = getSwapQuoteInfoWithAffiliateFee(newQuote.worstCaseQuoteInfo, feePercentage);
|
newQuote.worstCaseQuoteInfo = getSwapQuoteInfoWithAffiliateFee(newQuote.worstCaseQuoteInfo, feePercentage);
|
||||||
return newQuote;
|
return { ...newQuote, ...{ feePercentage } };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/assert": "^2.0.10",
|
"@0x/assert": "^2.0.10",
|
||||||
"@0x/asset-buyer": "6.1.5",
|
"@0x/asset-buyer": "6.1.4",
|
||||||
"@0x/json-schemas": "^3.0.10",
|
"@0x/json-schemas": "^3.0.10",
|
||||||
"@0x/order-utils": "^8.1.1",
|
"@0x/order-utils": "^8.1.1",
|
||||||
"@0x/subproviders": "^4.1.0",
|
"@0x/subproviders": "^4.1.0",
|
||||||
|
18
yarn.lock
18
yarn.lock
@ -478,6 +478,24 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@0x/base-contract" "^4.0.3"
|
"@0x/base-contract" "^4.0.3"
|
||||||
|
|
||||||
|
"@0x/asset-buyer@6.1.5", "@0x/asset-buyer@^6.1.5":
|
||||||
|
version "6.1.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@0x/asset-buyer/-/asset-buyer-6.1.5.tgz#bf2056ccd9e749034d993c4de259d2f1b572421e"
|
||||||
|
integrity sha512-8e2OTSEacyWnWiYtchKHeQ3mYq912dd8OL46Wekt7DMNYx85R1ExTHaTgoKEQAe4EDsETW41yBPT6DLXwMI/Tw==
|
||||||
|
dependencies:
|
||||||
|
"@0x/assert" "^2.0.10"
|
||||||
|
"@0x/connect" "^5.0.10"
|
||||||
|
"@0x/contract-wrappers" "^9.1.4"
|
||||||
|
"@0x/json-schemas" "^3.0.10"
|
||||||
|
"@0x/order-utils" "^8.1.1"
|
||||||
|
"@0x/subproviders" "^4.1.0"
|
||||||
|
"@0x/types" "^2.2.2"
|
||||||
|
"@0x/typescript-typings" "^4.2.2"
|
||||||
|
"@0x/utils" "^4.3.3"
|
||||||
|
"@0x/web3-wrapper" "^6.0.6"
|
||||||
|
ethereum-types "^2.1.2"
|
||||||
|
lodash "^4.17.11"
|
||||||
|
|
||||||
"@0x/base-contract@^4.0.1", "@0x/base-contract@^4.0.3":
|
"@0x/base-contract@^4.0.1", "@0x/base-contract@^4.0.3":
|
||||||
version "4.0.3"
|
version "4.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/base-contract/-/base-contract-4.0.3.tgz#ea5e3640824ee096813350e55546d98455a57805"
|
resolved "https://registry.yarnpkg.com/@0x/base-contract/-/base-contract-4.0.3.tgz#ea5e3640824ee096813350e55546d98455a57805"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user