<p><b>@sqrrm</b> requested changes on this pull request.</p>

<p>Please fix getAdjustedAmount function, either with explanation on what it does if current behavior is expected or rounding of return data for all cases to match expectation.</p><hr>

<p>In <a href="https://github.com/bisq-network/bisq-core/pull/158#discussion_r211085158">src/main/java/bisq/core/offer/OfferUtil.java</a>:</p>
<pre style='color:#555'>>          amount = price.getAmountByVolume(volume);
 
         // We want only 4 decimal places
         long rounded = Math.round((double) amount.value / 10000d) * 10000;
         if (rounded > maxTradeLimit) {
             // If we are above out trade limit we reduce the amount by the correlating 10 EUR volume
-            rounded = Math.min(maxTradeLimit, rounded - amountByVolumeRoundedToFactor.value);
+            long reduced = rounded - amountByVolumeRoundedToFactor.value;
+            if (reduced > Restrictions.getMinTradeAmount().value)
+                rounded = Math.min(maxTradeLimit, reduced);
</pre>
<p>If the amount is more than <code>factor</code> more than <code>maxTradeLimit</code> the returned value will be <code>maxTradeLimit</code> which is not rounded. This is later rounded down to factor when this function is called again from MutableOfferDataModel:702 so everything works in when running the code.</p>
<p>This is somewhat confusing while reading the code though, I expect <code>getAdjustedAmount</code> to return a rounded amount for every input value.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq-core/pull/158#discussion_r211085816">src/main/java/bisq/core/offer/OfferUtil.java</a>:</p>
<pre style='color:#555'>> @@ -167,20 +168,28 @@ public static Coin getAdjustedAmountForHalCash(Coin amount, Price price, long ma
     private static Coin getAdjustedAmount(Coin amount, Price price, long maxTradeLimit, String currencyCode, int factor) {
         // Amount must result in a volume of min factor units of the fiat currency, e.g. 1 EUR or 10 EUR in case of Halcash
         Volume volumeRoundedToFactor = Volume.parse(String.valueOf(factor), currencyCode);
+        if (volumeRoundedToFactor.getValue() <= 0)
+            return Coin.ZERO;
+
         Coin amountByVolumeRoundedToFactor = price.getAmountByVolume(volumeRoundedToFactor);
         // We set min amount so it has a volume of 10 EUR
         if (amount.compareTo(amountByVolumeRoundedToFactor) < 0)
             amount = amountByVolumeRoundedToFactor;
 
         // We adjust the amount so that the volume is a multiple of 10 EUR
</pre>
<p>Refers to a multiple of <code>factor</code></p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq-core/pull/158#discussion_r211085827">src/main/java/bisq/core/offer/OfferUtil.java</a>:</p>
<pre style='color:#555'>> @@ -167,20 +168,28 @@ public static Coin getAdjustedAmountForHalCash(Coin amount, Price price, long ma
     private static Coin getAdjustedAmount(Coin amount, Price price, long maxTradeLimit, String currencyCode, int factor) {
         // Amount must result in a volume of min factor units of the fiat currency, e.g. 1 EUR or 10 EUR in case of Halcash
         Volume volumeRoundedToFactor = Volume.parse(String.valueOf(factor), currencyCode);
+        if (volumeRoundedToFactor.getValue() <= 0)
+            return Coin.ZERO;
+
         Coin amountByVolumeRoundedToFactor = price.getAmountByVolume(volumeRoundedToFactor);
         // We set min amount so it has a volume of 10 EUR
</pre>
<p>These comments refer to a multiple of <code>factor</code></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq-core/pull/158#pullrequestreview-147440468">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AkpZtu97gUnI04mUSj0-H_bk4NgT9RDfks5uSIPJgaJpZM4WATGe">mute the thread</a>.<img src="https://github.com/notifications/beacon/AkpZttsQz0HEcklz2YY5-UCOCe7R1f_7ks5uSIPJgaJpZM4WATGe.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/bisq-network/bisq-core","title":"bisq-network/bisq-core","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/bisq-network/bisq-core"}},"updates":{"snippets":[{"icon":"PERSON","message":"@sqrrm requested changes on #158"}],"action":{"name":"View Pull Request","url":"https://github.com/bisq-network/bisq-core/pull/158#pullrequestreview-147440468"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq-core/pull/158#pullrequestreview-147440468",
"url": "https://github.com/bisq-network/bisq-core/pull/158#pullrequestreview-147440468",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "@sqrrm requested changes on 158",
"sections": [
{
"text": "Please fix getAdjustedAmount function, either with explanation on what it does if current behavior is expected or rounding of return data for all cases to match expectation.",
"activityTitle": "**sqrrm**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@sqrrm",
"facts": [

]
}
],
"potentialAction": [
{
"targets": [
{
"os": "default",
"uri": "https://github.com/bisq-network/bisq-core/pull/158#pullrequestreview-147440468"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 369176990\n}"
}
],
"themeColor": "26292E"
}
]</script>