diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-08-29 04:00:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 04:00:49 +0800 |
commit | 14fdb71a716cb95bc1f6933db9057d23f3c41909 (patch) | |
tree | 9690b583d128f419f292ef78f0a70be260e8babe /packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol | |
parent | 2eab0e30b753fb33729db53d141c8e22017cadec (diff) | |
download | dexon-sol-tools-14fdb71a716cb95bc1f6933db9057d23f3c41909.tar dexon-sol-tools-14fdb71a716cb95bc1f6933db9057d23f3c41909.tar.gz dexon-sol-tools-14fdb71a716cb95bc1f6933db9057d23f3c41909.tar.bz2 dexon-sol-tools-14fdb71a716cb95bc1f6933db9057d23f3c41909.tar.lz dexon-sol-tools-14fdb71a716cb95bc1f6933db9057d23f3c41909.tar.xz dexon-sol-tools-14fdb71a716cb95bc1f6933db9057d23f3c41909.tar.zst dexon-sol-tools-14fdb71a716cb95bc1f6933db9057d23f3c41909.zip |
safeGetPartialAmount (#1035)
* Added Test "Should transfer correct amounts when left order is fully filled and values pass isRoundingErrorCeil but fail isRoundingErrorFloor"
* Added RoundingError exception to reference function for getPartialAmount
* Added RoundingError exception to reference function for getPartialAmount
* Added isRoundingErrorCeil to getPartialAmountCeil reference funtion
* Computed new values for "Should give right maker a better buy price when correct price is not integral" that does not have a rounding error
* Almost all tests for match orders are passing after adding isRoundingErrorCeil check
* WIP commit: Added rounding error checks to getPartialAmount
* WIP commit: Added rounding error checks to getPartialAmount
* Use safe versions of getPartialAmount
* Update Exchange internals tests
* Run linter
* Found new values for "Should transfer correct amounts when right order fill amount deviates from amount derived by `Exchange.fillOrder`"
* Fixed merge conflicts
* Run all tests
* Cleaned up some comments on match Orders tests
* Fix tests for geth
Diffstat (limited to 'packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol')
-rw-r--r-- | packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol index 075a610b5..b4f6bdb26 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol @@ -177,13 +177,13 @@ contract MixinMatchOrders is { // Derive maker asset amounts for left & right orders, given store taker assert amounts uint256 leftTakerAssetAmountRemaining = safeSub(leftOrder.takerAssetAmount, leftOrderTakerAssetFilledAmount); - uint256 leftMakerAssetAmountRemaining = getPartialAmountFloor( + uint256 leftMakerAssetAmountRemaining = safeGetPartialAmountFloor( leftOrder.makerAssetAmount, leftOrder.takerAssetAmount, leftTakerAssetAmountRemaining ); uint256 rightTakerAssetAmountRemaining = safeSub(rightOrder.takerAssetAmount, rightOrderTakerAssetFilledAmount); - uint256 rightMakerAssetAmountRemaining = getPartialAmountFloor( + uint256 rightMakerAssetAmountRemaining = safeGetPartialAmountFloor( rightOrder.makerAssetAmount, rightOrder.takerAssetAmount, rightTakerAssetAmountRemaining @@ -205,7 +205,7 @@ contract MixinMatchOrders is matchedFillResults.left.takerAssetFilledAmount = matchedFillResults.right.makerAssetFilledAmount; // Round down to ensure the maker's exchange rate does not exceed the price specified by the order. // We favor the maker when the exchange rate must be rounded. - matchedFillResults.left.makerAssetFilledAmount = getPartialAmountFloor( + matchedFillResults.left.makerAssetFilledAmount = safeGetPartialAmountFloor( leftOrder.makerAssetAmount, leftOrder.takerAssetAmount, matchedFillResults.left.takerAssetFilledAmount @@ -217,7 +217,7 @@ contract MixinMatchOrders is matchedFillResults.right.makerAssetFilledAmount = matchedFillResults.left.takerAssetFilledAmount; // Round up to ensure the maker's exchange rate does not exceed the price specified by the order. // We favor the maker when the exchange rate must be rounded. - matchedFillResults.right.takerAssetFilledAmount = getPartialAmountCeil( + matchedFillResults.right.takerAssetFilledAmount = safeGetPartialAmountCeil( rightOrder.takerAssetAmount, rightOrder.makerAssetAmount, matchedFillResults.right.makerAssetFilledAmount @@ -231,24 +231,24 @@ contract MixinMatchOrders is ); // Compute fees for left order - matchedFillResults.left.makerFeePaid = getPartialAmountFloor( + matchedFillResults.left.makerFeePaid = safeGetPartialAmountFloor( matchedFillResults.left.makerAssetFilledAmount, leftOrder.makerAssetAmount, leftOrder.makerFee ); - matchedFillResults.left.takerFeePaid = getPartialAmountFloor( + matchedFillResults.left.takerFeePaid = safeGetPartialAmountFloor( matchedFillResults.left.takerAssetFilledAmount, leftOrder.takerAssetAmount, leftOrder.takerFee ); // Compute fees for right order - matchedFillResults.right.makerFeePaid = getPartialAmountFloor( + matchedFillResults.right.makerFeePaid = safeGetPartialAmountFloor( matchedFillResults.right.makerAssetFilledAmount, rightOrder.makerAssetAmount, rightOrder.makerFee ); - matchedFillResults.right.takerFeePaid = getPartialAmountFloor( + matchedFillResults.right.takerFeePaid = safeGetPartialAmountFloor( matchedFillResults.right.takerAssetFilledAmount, rightOrder.takerAssetAmount, rightOrder.takerFee |