github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/pkg/pricing/reporting.go (about) 1 package pricing 2 3 import ( 4 "strings" 5 6 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 7 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" 8 ) 9 10 type priceDebugger struct { 11 address base.Address 12 symbol string 13 blockNumber base.Blknum 14 source1 base.Address 15 theCall1 string 16 source2 base.Address 17 theCall2 string 18 first base.Address 19 second base.Address 20 reversed bool 21 float0 *base.Ether 22 float1 *base.Ether 23 float2 *base.Ether 24 int0 *base.Wei 25 int1 *base.Wei 26 bigPrice *base.Ether 27 price base.Float 28 source string 29 } 30 31 // TODO: Much of this reporting could be removed by using a String function on the types.Statement 32 func (r *priceDebugger) report(msg string) { 33 isStable := strings.Contains(msg, "stable-coin") 34 if isStable { 35 msg = "" 36 } 37 38 logger.TestLog(true, "=========================================================") 39 logger.TestLog(true, "===> PRICING FOR", r.address, "("+r.symbol+")", msg) 40 logger.TestLog(true, "=========================================================") 41 42 if isStable { 43 logger.TestLog(true, "stable-coin") 44 return 45 } 46 47 logger.TestLog(true, "blockNumber: ", r.blockNumber) 48 logger.TestLog(true, "source1 (uni/mkr): ", r.source1) 49 logger.TestLog(true, "str0 (call): ", r.theCall1) 50 if r.source2 != base.ZeroAddr { 51 logger.TestLog(true, "source2 (pair): ", r.source2) 52 } 53 logger.TestLog(true, "str1 (call/data): ", r.theCall2) 54 if r.first != base.ZeroAddr { 55 logger.TestLog(true, "first: ", r.first) 56 } 57 if r.second != base.ZeroAddr { 58 logger.TestLog(true, "second: ", r.second) 59 logger.TestLog(true, "reversed: ", r.reversed) 60 } 61 if r.int0 != nil { 62 logger.TestLog(true, "int0: ", r.int0) 63 } 64 if r.int1 != nil { 65 logger.TestLog(true, "int1: ", r.int1) 66 } 67 if r.float0 != nil { 68 logger.TestLog(true, "float0: ", r.float0) 69 } 70 if r.float1 != nil { 71 logger.TestLog(true, "float1: ", r.float1) 72 } 73 if r.float2 != nil { 74 logger.TestLog(true, "float2: ", r.float2) 75 } 76 logger.TestLog(true, "bigPrice: ", r.bigPrice) 77 logger.TestLog(true, "price: ", r.price) 78 logger.TestLog(true, "source: ", r.source) 79 }