aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-06 08:54:29 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-06 08:54:29 +0800
commit7d0bec9b2a9960390b0b3b19e5ed4d84a679669b (patch)
treef735749dda11c468cc7b1061fef609fa4511fb40
parent8382161f7553539ed6f436be88df8672b00bf35e (diff)
downloaddexon-sol-tools-7d0bec9b2a9960390b0b3b19e5ed4d84a679669b.tar
dexon-sol-tools-7d0bec9b2a9960390b0b3b19e5ed4d84a679669b.tar.gz
dexon-sol-tools-7d0bec9b2a9960390b0b3b19e5ed4d84a679669b.tar.bz2
dexon-sol-tools-7d0bec9b2a9960390b0b3b19e5ed4d84a679669b.tar.lz
dexon-sol-tools-7d0bec9b2a9960390b0b3b19e5ed4d84a679669b.tar.xz
dexon-sol-tools-7d0bec9b2a9960390b0b3b19e5ed4d84a679669b.tar.zst
dexon-sol-tools-7d0bec9b2a9960390b0b3b19e5ed4d84a679669b.zip
Add some test cases that stress slippageBufferAmount param
-rw-r--r--packages/order-utils/test/market_utils_test.ts21
1 files changed, 15 insertions, 6 deletions
diff --git a/packages/order-utils/test/market_utils_test.ts b/packages/order-utils/test/market_utils_test.ts
index 03f86c581..21c0a4802 100644
--- a/packages/order-utils/test/market_utils_test.ts
+++ b/packages/order-utils/test/market_utils_test.ts
@@ -37,34 +37,43 @@ describe('marketUtils', () => {
// generate remainingFillableMakerAssetAmounts that equal the makerAssetAmount
const remainingFillableMakerAssetAmounts = [makerAssetAmount, makerAssetAmount, makerAssetAmount];
it('returns input orders and zero remainingFillAmount when input exactly matches requested fill amount', async () => {
- // try to fill 30 units of makerAsset
- const fillAmount = new BigNumber(30);
+ // try to fill 20 units of makerAsset
+ // include 10 units of slippageBufferAmount
+ const fillAmount = new BigNumber(20);
+ const slippageBufferAmount = new BigNumber(10);
const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
inputOrders,
remainingFillableMakerAssetAmounts,
fillAmount,
+ slippageBufferAmount,
);
expect(resultOrders).to.be.deep.equal(inputOrders);
expect(remainingFillAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
});
it('returns input orders and zero remainingFillAmount when input has more than requested fill amount', async () => {
- // try to fill 25 units of makerAsset
- const fillAmount = new BigNumber(25);
+ // try to fill 15 units of makerAsset
+ // include 10 units of slippageBufferAmount
+ const fillAmount = new BigNumber(15);
+ const slippageBufferAmount = new BigNumber(10);
const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
inputOrders,
remainingFillableMakerAssetAmounts,
fillAmount,
+ slippageBufferAmount,
);
expect(resultOrders).to.be.deep.equal(inputOrders);
expect(remainingFillAmount).to.be.bignumber.equal(constants.ZERO_AMOUNT);
});
it('returns input orders and non-zero remainingFillAmount when input has less than requested fill amount', async () => {
- // try to fill 35 units of makerAsset
- const fillAmount = new BigNumber(35);
+ // try to fill 30 units of makerAsset
+ // include 5 units of slippageBufferAmount
+ const fillAmount = new BigNumber(30);
+ const slippageBufferAmount = new BigNumber(5);
const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount(
inputOrders,
remainingFillableMakerAssetAmounts,
fillAmount,
+ slippageBufferAmount,
);
expect(resultOrders).to.be.deep.equal(inputOrders);
expect(remainingFillAmount).to.be.bignumber.equal(new BigNumber(5));