Skip to content

Commit

Permalink
fix rex price
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwishing committed Sep 14, 2024
1 parent 72b64e2 commit 7ad533a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/pages/resources/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,18 @@ export const cpuStakingPrice = derived(
const { account } = $sampleUsage
const cpu_weight = Number(account.total_resources.cpu_weight.units)
const cpu_limit = Number(account.cpu_limit.max.value)
let price = cpu_weight / cpu_limit
if ($activeBlockchain.resourceSampleMilliseconds) {
price *= $activeBlockchain.resourceSampleMilliseconds
}
let price = (cpu_weight / cpu_limit) * $msToRent
return Asset.fromUnits(price * 1000, $activeBlockchain.coreTokenSymbol)
}
return Asset.from(0, $activeBlockchain.coreTokenSymbol)
}
)

// price per kb
// price per kb for staking
export const netStakingPrice = derived(
[activeBlockchain, msToRent, sampleUsage],
([$activeBlockchain, $msToRent, $sampleUsage]) => {
if ($msToRent && $sampleUsage) {
[activeBlockchain, sampleUsage],
([$activeBlockchain, $sampleUsage]) => {
if ($sampleUsage) {
const { account } = $sampleUsage
const net_weight = Number(account.total_resources.net_weight.units)
const net_limit = Number(account.net_limit.max.value)
Expand Down Expand Up @@ -188,7 +185,8 @@ export const rexPrice = derived(
[msToRent, sampleUsage, stateREX],
([$msToRent, $sampleUsage, $stateREX]) => {
if ($msToRent && $sampleUsage && $stateREX) {
return Asset.from($stateREX.price_per($sampleUsage, $msToRent * 30000), '4,EOS')
const price = $stateREX.price_per($sampleUsage);
return Asset.from(price * $msToRent, '4,EOS')
}
return Asset.from(0, '4,EOS')
}
Expand Down

0 comments on commit 7ad533a

Please sign in to comment.