11package single_asset_feed
22
33import (
4- "encoding/hex"
54 "fmt"
65 "time"
76
87 "github.com/Gearbox-protocol/sdk-go/artifacts/multicall"
9- "github.com/Gearbox-protocol/sdk-go/artifacts/redstone"
108 "github.com/Gearbox-protocol/sdk-go/core"
119 "github.com/Gearbox-protocol/sdk-go/core/schemas"
1210 "github.com/Gearbox-protocol/sdk-go/log"
13- "github.com/Gearbox-protocol/sdk-go/pkg/priceFetcher"
1411 "github.com/Gearbox-protocol/third-eye/ds"
1512 "github.com/Gearbox-protocol/third-eye/models/aggregated_block_feed/base_price_feed"
16- "github.com/ethereum/go-ethereum/common"
1713)
1814
1915type SingleAssetFeed struct {
@@ -31,50 +27,8 @@ func NewSingleAssetFromAdapter(adapter *ds.SyncAdapter) *SingleAssetFeed {
3127 }
3228}
3329
34- func (feed SingleAssetFeed ) GetRedstonePF () * core.RedStonePF {
35- if len (feed .DetailsDS .Underlyings ) == 0 {
36- return nil
37- }
38- return feed .DetailsDS .Info [feed .DetailsDS .Underlyings [0 ]]
39- }
40-
41- func (mdl * SingleAssetFeed ) GetCalls (blockNum int64 ) (calls []multicall.Multicall2Call , isQueryable bool ) {
42- updateABI := core .GetAbi ("UpdatePriceFeed" )
43- for _ , entry := range mdl .DetailsDS .Underlyings {
44- contract , err := redstone .NewRedstone (common .HexToAddress (entry ), mdl .Client )
45- log .CheckFatal (err )
46- var tokenDetails * core.RedStonePF
47- if _ , ok := mdl .DetailsDS .Info [entry ]; ok {
48- tokenDetails = mdl .DetailsDS .Info [entry ]
49- } else if _ , err := contract .DataFeedId (nil ); err == nil {
50- feedToken , signThreshold , dataId := priceFetcher .RedstoneDetails (common .HexToAddress (entry ), mdl .Client )
51- //
52- tokenDetails = & core.RedStonePF {
53- Type : 15 ,
54- DataServiceId : "redstone-primary-prod" ,
55- DataId : dataId ,
56- SignersThreshold : signThreshold ,
57- UnderlyingToken : feedToken ,
58- }
59- mdl .DetailsDS .Info [entry ] = tokenDetails
60- }
61- if tokenDetails != nil {
62- pod := mdl .Repo .GetRedStonemgr ().GetPodSignWithRedstoneToken (int64 (mdl .Repo .SetAndGetBlock (blockNum ).Timestamp ), * tokenDetails )
63- update , err := updateABI .Pack ("updatePrice" , pod .CallData )
64- log .CheckFatal (err )
65- calls = append (calls , multicall.Multicall2Call {
66- Target : common .HexToAddress (entry ),
67- CallData : update ,
68- })
69- }
70- }
71- b , err := hex .DecodeString ("feaf968c" )
72- log .CheckFatal (err )
73- calls = append (calls , multicall.Multicall2Call {
74- Target : common .HexToAddress (mdl .Address ),
75- CallData : b ,
76- })
77- return calls , true
30+ func (feed SingleAssetFeed ) GetCalls (blockNum int64 ) (calls []multicall.Multicall2Call , isQueryable bool ) {
31+ return feed .GetUnderlyingCalls (blockNum )
7832}
7933
8034var counter = log .SendMsgIfCountMoreThan (24 * time .Hour , 10 )
0 commit comments