@@ -96,7 +96,8 @@ export const msToRent: Readable<number> = derived(activeBlockchain, ($activeBloc
96
96
return 1
97
97
} )
98
98
99
- export const powerupPrice = derived (
99
+ //price per ms
100
+ export const cpuPowerupPrice = derived (
100
101
[ msToRent , sampleUsage , statePowerUp , info ] ,
101
102
( [ $msToRent , $sampleUsage , $statePowerUp , $info ] ) => {
102
103
if ( $msToRent && $sampleUsage && $statePowerUp ) {
@@ -109,7 +110,20 @@ export const powerupPrice = derived(
109
110
}
110
111
)
111
112
112
- export const stakingPrice = derived (
113
+ // price per kb
114
+ export const netPowerupPrice = derived (
115
+ [ msToRent , sampleUsage , statePowerUp , info ] ,
116
+ ( [ $msToRent , $sampleUsage , $statePowerUp , $info ] ) => {
117
+ if ( $msToRent && $sampleUsage && $statePowerUp ) {
118
+ const price = $statePowerUp . net . price_per_kb ( $sampleUsage , $msToRent , $info )
119
+ return Asset . from ( price , '4,EOS' )
120
+ }
121
+ return Asset . from ( 0 , '4,EOS' )
122
+ }
123
+ )
124
+
125
+ //price per ms
126
+ export const cpuStakingPrice = derived (
113
127
[ activeBlockchain , msToRent , sampleUsage ] ,
114
128
( [ $activeBlockchain , $msToRent , $sampleUsage ] ) => {
115
129
if ( $msToRent && $sampleUsage ) {
@@ -120,7 +134,22 @@ export const stakingPrice = derived(
120
134
if ( $activeBlockchain . resourceSampleMilliseconds ) {
121
135
price *= $activeBlockchain . resourceSampleMilliseconds
122
136
}
123
- return Asset . fromUnits ( price , $activeBlockchain . coreTokenSymbol )
137
+ return Asset . fromUnits ( price * 1000 , $activeBlockchain . coreTokenSymbol )
138
+ }
139
+ return Asset . from ( 0 , $activeBlockchain . coreTokenSymbol )
140
+ }
141
+ )
142
+
143
+ // price per kb
144
+ export const netStakingPrice = derived (
145
+ [ activeBlockchain , msToRent , sampleUsage ] ,
146
+ ( [ $activeBlockchain , $msToRent , $sampleUsage ] ) => {
147
+ if ( $msToRent && $sampleUsage ) {
148
+ const { account} = $sampleUsage
149
+ const net_weight = Number ( account . total_resources . net_weight . units )
150
+ const net_limit = Number ( account . net_limit . max . value )
151
+ let price = net_weight / net_limit
152
+ return Asset . fromUnits ( price * 1000 , $activeBlockchain . coreTokenSymbol )
124
153
}
125
154
return Asset . from ( 0 , $activeBlockchain . coreTokenSymbol )
126
155
}
0 commit comments