Skip to content

Commit

Permalink
Merge pull request #122 from CityOfZion/CU-86a5x0q43-2
Browse files Browse the repository at this point in the history
CU-86a5x0q43 - BS Swap - Bug - availableTokensToUse has tokens that d…
  • Loading branch information
thiagocbalducci authored Dec 14, 2024
2 parents 98231be + 0c4cb25 commit 8bfb821
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/bs-swap",
"comment": "Fix problem where the amountToUseMinMax is not being fixed",
"type": "patch"
}
],
"packageName": "@cityofzion/bs-swap"
}
11 changes: 10 additions & 1 deletion packages/bs-swap/src/services/SimpleSwapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,16 @@ export class SimpleSwapService<BSName extends string = string> implements SwapSe
let range: SwapServiceMinMaxAmount | null = this.#amountToUseMinMax.value

if (shouldRecalculateAmountToUseMinMax || range === null) {
range = await this.#api.getRange(this.#tokenToUse.value, this.#tokenToReceive.value!)
const apiRange = await this.#api.getRange(this.#tokenToUse.value, this.#tokenToReceive.value!)
range = {
min: this.#tokenToUse.value.decimals
? Number(apiRange.min).toFixed(this.#tokenToUse.value.decimals)
: apiRange.min,
max:
this.#tokenToUse.value.decimals && apiRange.max
? Number(apiRange.max).toFixed(this.#tokenToUse.value.decimals)
: apiRange.max,
}
}

this.#amountToUseMinMax = { value: range }
Expand Down

0 comments on commit 8bfb821

Please sign in to comment.