1919 // so we can do better rounding on limits per currency.
2020 //
2121 // todo: configurable
22- maxUsdTransactionValue = 2.0 * limit .SendLimits [currency_util .USD ].PerTransaction
23- maxDailyUsdLimit = 1.5 * limit .SendLimits [currency_util .USD ].Daily
22+ maxDailyUsdLimit = 1.2 * limit .SendLimits [currency_util .USD ].Daily
2423)
2524
2625// Guard gates money movement by applying rules on operations of interest to
@@ -43,11 +42,15 @@ func (g *Guard) AllowMoneyMovement(ctx context.Context, intentRecord *intent.Rec
4342 tracer := metrics .TraceMethodCall (ctx , metricsStructName , "AllowMoneyMovement" )
4443 defer tracer .End ()
4544
45+ var currency currency_util.Code
46+ var nativeAmount float64
4647 var usdMarketValue float64
4748 var consumptionCalculator func (ctx context.Context , owner string , since time.Time ) (uint64 , float64 , error )
4849 switch intentRecord .IntentType {
4950 case intent .SendPublicPayment :
50- // Public sends are subject to USD-based limits
51+ // Public sends are subject to limits
52+ currency = intentRecord .SendPublicPaymentMetadata .ExchangeCurrency
53+ nativeAmount = intentRecord .SendPublicPaymentMetadata .NativeAmount
5154 usdMarketValue = intentRecord .SendPublicPaymentMetadata .UsdMarketValue
5255 consumptionCalculator = g .data .GetTransactedAmountForAntiMoneyLaundering
5356 case intent .ReceivePaymentsPublicly :
@@ -60,15 +63,23 @@ func (g *Guard) AllowMoneyMovement(ctx context.Context, intentRecord *intent.Rec
6063 }
6164
6265 log := g .log .WithFields (logrus.Fields {
63- "method" : "AllowMoneyMovement" ,
64- "owner" : intentRecord .InitiatorOwnerAccount ,
65- "usd_value" : usdMarketValue ,
66+ "method" : "AllowMoneyMovement" ,
67+ "owner" : intentRecord .InitiatorOwnerAccount ,
68+ "currency" : string (currency ),
69+ "native_amount" : nativeAmount ,
70+ "usd_value" : usdMarketValue ,
6671 })
6772
68- // Bound the maximum dollar value of a payment
69- if usdMarketValue > maxUsdTransactionValue {
70- log .Info ("denying intent that exceeds per-transaction usd value" )
71- recordDenialEvent (ctx , "exceeds per-transaction usd value" )
73+ sendLimit , ok := limit .SendLimits [currency ]
74+ if ! ok {
75+ log .Info ("denying intent with unsupported currency" )
76+ recordDenialEvent (ctx , "unsupported currency" )
77+ return false , nil
78+ }
79+
80+ if nativeAmount > sendLimit .PerTransaction {
81+ log .Info ("denying intent that exceeds per-transaction value" )
82+ recordDenialEvent (ctx , "exceeds per-transaction value" )
7283 return false , nil
7384 }
7485
0 commit comments