fix: get current price from chain state (#286)
* fix: get current price from chain state * refactor: do not allow optional currentPrice
This commit is contained in:
+5
-2
@@ -1,3 +1,4 @@
|
||||
import { NumberString } from '@ethersphere/bee-js'
|
||||
import { BigNumber } from 'bignumber.js'
|
||||
|
||||
/**
|
||||
@@ -186,6 +187,8 @@ export function convertAmountToSeconds(amount: number): number {
|
||||
return amount / 10 / 1
|
||||
}
|
||||
|
||||
export function calculateStampPrice(depth: number, amount: number): number {
|
||||
return (amount * 2 ** (depth - 16) * 2) / 1e16
|
||||
export function calculateStampPrice(depth: number, amount: number, currentPrice: NumberString): number {
|
||||
const price = parseInt(currentPrice, 10)
|
||||
|
||||
return (amount * 2 ** (depth - 16) * price) / 1e16
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user