Skip to content

Commit b414698

Browse files
committed
Add more logging around validateCurrencyLaunchpadClientExchangeData
1 parent 2dae222 commit b414698

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/code/currency/validation.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
transactionpb "github.com/code-payments/code-protobuf-api/generated/go/transaction/v2"
9+
"github.com/sirupsen/logrus"
910

1011
"github.com/code-payments/code-server/pkg/code/common"
1112
code_data "github.com/code-payments/code-server/pkg/code/data"
@@ -74,6 +75,14 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
7475
return false, "", err
7576
}
7677

78+
log := logrus.StandardLogger().WithFields(logrus.Fields{
79+
"currency": proto.Currency,
80+
"native_amount": proto.NativeAmount,
81+
"exhange_rate": proto.ExchangeRate,
82+
"quarks": proto.Quarks,
83+
"mint": mintAccount.PublicKey().ToBase58(),
84+
})
85+
7786
coreMintQuarksPerUnit := common.GetMintQuarksPerUnit(common.CoreMintAccount)
7887
otherMintQuarksPerUnit := common.GetMintQuarksPerUnit(mintAccount)
7988

@@ -126,6 +135,7 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
126135
coreMintSellValueInUnits := float64(coreMintSellValueInQuarks) / float64(coreMintQuarksPerUnit)
127136
potentialNativeAmount := otherExchangeRateRecord.Rate * coreMintSellValueInUnits / usdExchangeRateRecord.Rate
128137
if potentialNativeAmount < nativeAmountLowerBound || potentialNativeAmount > nativeAmountUpperBound {
138+
log.WithField("potential_native_amount", potentialNativeAmount).Info("native amount is outside error threshold")
129139
continue
130140
}
131141

@@ -134,6 +144,7 @@ func validateCurrencyLaunchpadClientExchangeData(ctx context.Context, data code_
134144
expectedRate := potentialNativeAmount / otherMintUnits
135145
percentDiff := math.Abs(proto.ExchangeRate-expectedRate) / expectedRate
136146
if percentDiff > 0.0001 {
147+
log.WithField("potential_exchange_rate", expectedRate).Info("native amount is outside error threshold")
137148
continue
138149
}
139150

0 commit comments

Comments
 (0)