@@ -86,24 +86,29 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
8686 return false , "" , err
8787 }
8888
89+ coreMintQuarksPerUnit := common .GetMintQuarksPerUnit (common .CoreMintAccount )
90+ otherMintQuarksPerUnit := common .GetMintQuarksPerUnit (mintAccount )
91+
8992 clientQuarks := big .NewFloat (float64 (proto .Quarks )).SetPrec (defaultPrecision )
93+ clientTokenUnits := new (big.Float ).Quo (
94+ clientQuarks ,
95+ big .NewFloat (float64 (otherMintQuarksPerUnit )).SetPrec (defaultPrecision ),
96+ )
9097 clientRate := big .NewFloat (proto .ExchangeRate ).SetPrec (defaultPrecision )
9198 clientNativeAmount := big .NewFloat (proto .NativeAmount ).SetPrec (defaultPrecision )
9299
93100 rateErrorThreshold := big .NewFloat (0.01 ).SetPrec (defaultPrecision )
94101 nativeAmountErrorThreshold := big .NewFloat (0.005 ).SetPrec (defaultPrecision )
95102
96103 log := logrus .StandardLogger ().WithFields (logrus.Fields {
97- "currency" : proto .Currency ,
98- "native_amount" : clientNativeAmount ,
99- "exhange_rate" : clientRate ,
100- "quarks" : proto .Quarks ,
101- "mint" : mintAccount .PublicKey ().ToBase58 (),
104+ "currency" : proto .Currency ,
105+ "client_native_amount" : clientNativeAmount ,
106+ "client_exchange_rate" : clientRate ,
107+ "client_token_units" : clientTokenUnits ,
108+ "client_quarks" : proto .Quarks ,
109+ "mint" : mintAccount .PublicKey ().ToBase58 (),
102110 })
103111
104- coreMintQuarksPerUnit := common .GetMintQuarksPerUnit (common .CoreMintAccount )
105- otherMintQuarksPerUnit := common .GetMintQuarksPerUnit (mintAccount )
106-
107112 latestExchangeRateTime := GetLatestExchangeRateTime ()
108113 for i := range 2 {
109114 exchangeRateTime := latestExchangeRateTime .Add (time .Duration (- i ) * timePerExchangeRateUpdate )
@@ -162,16 +167,14 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
162167 "native_amount_lower_bound" : nativeAmountLowerBound ,
163168 "native_amount_upper_bound" : nativeAmountUpperBound ,
164169 "potential_native_amount" : potentialNativeAmount ,
170+ "usd_rate" : usdRate ,
171+ "other_rate" : otherRate ,
165172 }).Info ("native amount is outside error threshold" )
166173 continue
167174 }
168175
169176 // For the valid native amount, is the exchange rate calculated correctly?
170- otherMintUnits := new (big.Float ).Quo (
171- clientQuarks ,
172- big .NewFloat (float64 (otherMintQuarksPerUnit )).SetPrec (defaultPrecision ),
173- )
174- expectedRate := new (big.Float ).Quo (potentialNativeAmount , otherMintUnits )
177+ expectedRate := new (big.Float ).Quo (potentialNativeAmount , clientTokenUnits )
175178 percentDiff := new (big.Float ).Quo (new (big.Float ).Abs (new (big.Float ).Sub (clientRate , expectedRate )), expectedRate )
176179 if percentDiff .Cmp (rateErrorThreshold ) > 0 {
177180 log .WithField ("potential_exchange_rate" , expectedRate ).Info ("exchange rate is outside error threshold" )
0 commit comments