@@ -12,6 +12,33 @@ import (
1212 "sort"
1313)
1414
15+ var pricesMap = map [string ]math.LegacyDec {
16+ "SCRT" : math .LegacyMustNewDecFromStr ("0.1603" ),
17+ "KAVA" : math .LegacyMustNewDecFromStr ("0.1687" ),
18+ "WETH" : math .LegacyMustNewDecFromStr ("3797.49" ),
19+ "SAGA" : math .LegacyMustNewDecFromStr ("0.1268" ),
20+ "ATOM" : math .LegacyMustNewDecFromStr ("3.05" ),
21+ "NTRN" : math .LegacyMustNewDecFromStr ("0.05013" ),
22+ "XRP" : math .LegacyMustNewDecFromStr ("2.38" ),
23+ "FET" : math .LegacyMustNewDecFromStr ("0.3877" ),
24+ "INJ" : math .LegacyMustNewDecFromStr ("8.95" ),
25+ "ONDO" : math .LegacyMustNewDecFromStr ("0.7362" ),
26+ "TIA" : math .LegacyMustNewDecFromStr ("0.9503" ),
27+ "USDT" : math .LegacyMustNewDecFromStr ("1.0" ),
28+ "OSMO" : math .LegacyMustNewDecFromStr ("0.1106" ),
29+ "AKT" : math .LegacyMustNewDecFromStr ("0.7323" ),
30+ "USDC" : math .LegacyMustNewDecFromStr ("0.9998" ),
31+ "OM" : math .LegacyMustNewDecFromStr ("0.1084" ),
32+ "PAXG" : math .LegacyMustNewDecFromStr ("3981.96" ),
33+ "WBTC" : math .LegacyMustNewDecFromStr ("112534.90" ),
34+ "LINK" : math .LegacyMustNewDecFromStr ("17.51" ),
35+ "BABY" : math .LegacyMustNewDecFromStr ("0.03276" ),
36+ "XION" : math .LegacyMustNewDecFromStr ("0.5202" ),
37+ }
38+
39+ var _startHeight int64 = 6947415
40+ var _endHeight = _startHeight + 5
41+
1542// SetPrice set a specific price in the store from its index
1643func (k Keeper ) SetPrice (ctx sdk.Context , price types.Price ) {
1744 store := runtime .KVStoreAdapter (k .storeService .OpenKVStore (ctx ))
@@ -82,40 +109,57 @@ func (k Keeper) GetAllPrice(ctx sdk.Context) (list []types.Price) {
82109 return
83110}
84111
85- func (k Keeper ) GetAllAssetPrice (ctx sdk.Context , asset string ) (list []types.Price ) {
86- store := prefix .NewStore (runtime .KVStoreAdapter (k .storeService .OpenKVStore (ctx )), types .PriceKeyPrefixAsset (asset ))
87- iterator := storetypes .KVStorePrefixIterator (store , []byte {})
112+ func (k Keeper ) GetAllAssetPrice (ctx sdk.Context , asset string , endBlocker bool ) (list []types.Price ) {
113+ if ! endBlocker && ctx .BlockHeight () > _startHeight && ctx .BlockHeight () <= _endHeight {
114+ for key , value := range pricesMap {
115+ p := types.Price {
116+ Asset : key ,
117+ Price : value ,
118+ Source : "elys" ,
119+ Provider : "elys16qgewtplahkqwqa0aqv4pxnxa58ulu48k6crhj" ,
120+ Timestamp : uint64 (ctx .BlockTime ().Unix ()),
121+ BlockHeight : uint64 (ctx .BlockHeight ()),
122+ }
123+ list = append (list , p )
124+ }
125+ } else {
126+ store := prefix .NewStore (runtime .KVStoreAdapter (k .storeService .OpenKVStore (ctx )), types .PriceKeyPrefixAsset (asset ))
127+ iterator := storetypes .KVStorePrefixIterator (store , []byte {})
88128
89- defer iterator .Close ()
129+ defer iterator .Close ()
90130
91- for ; iterator .Valid (); iterator .Next () {
92- var val types.Price
93- k .cdc .MustUnmarshal (iterator .Value (), & val )
94- list = append (list , val )
131+ for ; iterator .Valid (); iterator .Next () {
132+ var val types.Price
133+ k .cdc .MustUnmarshal (iterator .Value (), & val )
134+ list = append (list , val )
135+ }
95136 }
96-
97137 return
98138}
99139
100140func (k Keeper ) GetAssetPrice (ctx sdk.Context , asset string ) (math.LegacyDec , bool ) {
101- // try out elys source
102- val , found := k .GetLatestPriceFromAssetAndSource (ctx , asset , types .ELYS )
103- if found {
104- return val .Price , true
105- }
141+ if ctx .BlockHeight () > _startHeight && ctx .BlockHeight () <= _endHeight {
142+ return pricesMap [asset ], true
143+ } else {
144+ // try out elys source
145+ val , found := k .GetLatestPriceFromAssetAndSource (ctx , asset , types .ELYS )
146+ if found {
147+ return val .Price , true
148+ }
106149
107- // try out band source
108- val , found = k .GetLatestPriceFromAssetAndSource (ctx , asset , types .BAND )
109- if found {
110- return val .Price , true
111- }
150+ // try out band source
151+ val , found = k .GetLatestPriceFromAssetAndSource (ctx , asset , types .BAND )
152+ if found {
153+ return val .Price , true
154+ }
112155
113- // find from any source if band source does not exist
114- price , found := k .GetLatestPriceFromAnySource (ctx , asset )
115- if found {
116- return price .Price , true
156+ // find from any source if band source does not exist
157+ price , found := k .GetLatestPriceFromAnySource (ctx , asset )
158+ if found {
159+ return price .Price , true
160+ }
161+ return math.LegacyDec {}, false
117162 }
118- return math.LegacyDec {}, false
119163}
120164
121165func (k Keeper ) GetDenomPrice (ctx sdk.Context , denom string ) osmomath.BigDec {
@@ -134,7 +178,7 @@ func (k Keeper) GetDenomPrice(ctx sdk.Context, denom string) osmomath.BigDec {
134178}
135179
136180func (k Keeper ) DeleteAXLPrices (ctx sdk.Context ) {
137- allAssetPrice := k .GetAllAssetPrice (ctx , "AXL" )
181+ allAssetPrice := k .GetAllAssetPrice (ctx , "AXL" , true )
138182 total := len (allAssetPrice )
139183
140184 // Need to sort it because order fetched from GetAllAssetPrice will not be in ascending order - depending on source
0 commit comments