@@ -59,14 +59,14 @@ func validateCoreMintClientExchangeData(ctx context.Context, data code_data.Prov
5959
6060 log := logrus .StandardLogger ().WithFields (logrus.Fields {
6161 "currency" : proto .Currency ,
62- "client_native_amount" : clientNativeAmount ,
63- "client_exchange_rate" : clientRate ,
62+ "client_native_amount" : clientNativeAmount . Text ( 'f' , 10 ) ,
63+ "client_exchange_rate" : clientRate . Text ( 'f' , 10 ) ,
6464 "client_quarks" : proto .Quarks ,
65- "min_transfer_value" : minTransferValue ,
66- "native_amount_lower_bound" : nativeAmountLowerBound ,
67- "native_amount_upper_bound" : nativeAmountUpperBound ,
68- "quarks_lower_bound" : quarksLowerBound ,
69- "quarks_upper_bound" : quarksUpperBound ,
65+ "min_transfer_value" : minTransferValue . Text ( 'f' , 10 ) ,
66+ "native_amount_lower_bound" : nativeAmountLowerBound . Text ( 'f' , 10 ) ,
67+ "native_amount_upper_bound" : nativeAmountUpperBound . Text ( 'f' , 10 ) ,
68+ "quarks_lower_bound" : quarksLowerBound . Text ( 'f' , 10 ) ,
69+ "quarks_upper_bound" : quarksUpperBound . Text ( 'f' , 10 ) ,
7070 })
7171
7272 if clientNativeAmount .Cmp (nativeAmountErrorThreshold ) < 0 {
@@ -94,7 +94,7 @@ func validateCoreMintClientExchangeData(ctx context.Context, data code_data.Prov
9494 break
9595 }
9696
97- log .WithField ("rate " , actualRate ).Info ("exchange rate doesn't match" )
97+ log .WithField ("found_rate " , actualRate . Text ( 'f' , 10 ) ).Info ("exchange rate doesn't match" )
9898 }
9999
100100 if ! isClientRateValid {
@@ -135,14 +135,22 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
135135 rateErrorThreshold := big .NewFloat (0.001 ).SetPrec (defaultPrecision )
136136 nativeAmountErrorThreshold := new (big.Float ).Quo (minTransferValue , big .NewFloat (2.0 ))
137137
138+ nativeAmountLowerBound := new (big.Float ).Sub (clientNativeAmount , nativeAmountErrorThreshold )
139+ if nativeAmountLowerBound .Cmp (nativeAmountErrorThreshold ) < 0 {
140+ nativeAmountLowerBound = nativeAmountErrorThreshold
141+ }
142+ nativeAmountUpperBound := new (big.Float ).Add (clientNativeAmount , nativeAmountErrorThreshold )
143+
138144 log := logrus .StandardLogger ().WithFields (logrus.Fields {
139- "currency" : proto .Currency ,
140- "client_native_amount" : clientNativeAmount ,
141- "client_exchange_rate" : clientRate ,
142- "client_token_units" : clientTokenUnits ,
143- "client_quarks" : proto .Quarks ,
144- "mint" : mintAccount .PublicKey ().ToBase58 (),
145- "min_transfer_value" : minTransferValue ,
145+ "currency" : proto .Currency ,
146+ "client_native_amount" : clientNativeAmount .Text ('f' , 10 ),
147+ "client_exchange_rate" : clientRate .Text ('f' , 10 ),
148+ "client_token_units" : clientTokenUnits .Text ('f' , 10 ),
149+ "client_quarks" : proto .Quarks ,
150+ "min_transfer_value" : minTransferValue .Text ('f' , 10 ),
151+ "native_amount_lower_bound" : nativeAmountLowerBound .Text ('f' , 10 ),
152+ "native_amount_upper_bound" : nativeAmountUpperBound .Text ('f' , 10 ),
153+ "mint" : mintAccount .PublicKey ().ToBase58 (),
146154 })
147155
148156 if clientNativeAmount .Cmp (nativeAmountErrorThreshold ) < 0 {
@@ -192,24 +200,18 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
192200
193201 // Given the sell value, does it align with the native amount in the target currency
194202 // within half a minimum transfer unit?
195- nativeAmountLowerBound := new (big.Float ).Sub (clientNativeAmount , nativeAmountErrorThreshold )
196- if nativeAmountLowerBound .Cmp (nativeAmountErrorThreshold ) < 0 {
197- nativeAmountLowerBound = nativeAmountErrorThreshold
198- }
199- nativeAmountUpperBound := new (big.Float ).Add (clientNativeAmount , nativeAmountErrorThreshold )
200203 coreMintSellValueInUnits := new (big.Float ).Quo (
201204 big .NewFloat (float64 (coreMintSellValueInQuarks )).SetPrec (defaultPrecision ),
202205 big .NewFloat (float64 (coreMintQuarksPerUnit )).SetPrec (defaultPrecision ),
203206 )
204207 potentialNativeAmount := new (big.Float ).Mul (new (big.Float ).Quo (otherRate , usdRate ), coreMintSellValueInUnits )
205208
206209 log := log .WithFields (logrus.Fields {
207- "core_mint_sell_value" : coreMintSellValueInUnits ,
208- "native_amount_lower_bound" : nativeAmountLowerBound ,
209- "native_amount_upper_bound" : nativeAmountUpperBound ,
210- "potential_native_amount" : potentialNativeAmount ,
211- "usd_rate" : usdRate ,
212- "other_rate" : otherRate ,
210+ "core_mint_sell_value" : coreMintSellValueInUnits .Text ('f' , 10 ),
211+ "potential_native_amount" : potentialNativeAmount .Text ('f' , 10 ),
212+ "found_core_mint_locked" : reserveRecord .CoreMintLocked ,
213+ "found_usd_rate" : usdRate .Text ('f' , 10 ),
214+ "found_other_rate" : otherRate .Text ('f' , 10 ),
213215 })
214216
215217 if potentialNativeAmount .Cmp (nativeAmountLowerBound ) < 0 || potentialNativeAmount .Cmp (nativeAmountUpperBound ) > 0 {
@@ -220,9 +222,7 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
220222 // For the valid native amount, is the exchange rate calculated correctly?
221223 expectedRate := new (big.Float ).Quo (clientNativeAmount , clientTokenUnits )
222224 percentDiff := new (big.Float ).Quo (new (big.Float ).Abs (new (big.Float ).Sub (clientRate , expectedRate )), expectedRate )
223-
224- log = log .WithField ("potential_exchange_rate" , expectedRate )
225-
225+ log = log .WithField ("potential_exchange_rate" , expectedRate .Text ('f' , 10 ))
226226 if percentDiff .Cmp (rateErrorThreshold ) > 0 {
227227 log .Info ("exchange rate is outside error threshold" )
228228 continue
0 commit comments