Skip to content

Commit

Permalink
[Bridge] update calculateMaxLimit method (#1500)
Browse files Browse the repository at this point in the history
* update calculateMaxLimit method

* remove log
  • Loading branch information
Nikita-Polyakov authored Aug 19, 2024
1 parent e20bc86 commit b21f1d5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/store/bridge/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,17 @@ function calculateMaxLimit(
if (outgoingLimitUSD.isZero() || limitAsset === referenceAsset) return outgoingLimitUSD;

try {
// We should calculate the asset price in reference asset
// For this purpose is used the reduced asset amount (amount should be greater than any order book tick size)
const assetAmount = FPNumber.ONE;
const multiplier = new FPNumber(1000);
const quoteAmount = assetAmount.div(multiplier);

const {
result: { amount },
} = quote(limitAsset, referenceAsset, 1, false, [], false);

const assetPriceUSD = FPNumber.fromCodecValue(amount);
} = quote(limitAsset, referenceAsset, quoteAmount.toString(), false, [], false);
// result amount multiplied by a multiplier to get asset price
const assetPriceUSD = FPNumber.fromCodecValue(amount).mul(multiplier);

if (!assetPriceUSD.isFinity() || assetPriceUSD.isZero()) return FPNumber.ZERO;

Expand Down

0 comments on commit b21f1d5

Please sign in to comment.