Skip to content

Commit dbb6724

Browse files
lukegao209luke
andauthored
Accept price deviation ppm configuration (#1109)
* Add AcceptPriceDeviationPpm configuration --------- Co-authored-by: luke <[email protected]>
1 parent 842d367 commit dbb6724

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

rfq/cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const (
2222
type CliConfig struct {
2323
PriceOracleAddress string `long:"priceoracleaddress" description:"Price oracle gRPC server address (rfqrpc://<hostname>:<port>). To use the integrated mock, use the following value: use_mock_price_oracle_service_promise_to_not_use_on_mainnet"`
2424

25+
AcceptPriceDeviationPpm uint64 `long:"acceptpricedeviationppm" description:"The default price deviation in parts per million that is accepted by the RFQ negotiator"`
26+
2527
SkipAcceptQuotePriceCheck bool `long:"skipacceptquotepricecheck" description:"Accept any price quote returned by RFQ peer, skipping price validation"`
2628

2729
MockOracleAssetsPerBTC uint64 `long:"mockoracleassetsperbtc" description:"Mock price oracle static asset units per BTC rate (for example number of USD cents per BTC if one asset unit represents a USD cent); whole numbers only, use either this or mockoraclesatsperasset depending on required precision"`

rfq/manager.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ type ManagerCfg struct {
7575
// into the manager once lnd and tapd are hooked together.
7676
AliasManager ScidAliasManager
7777

78+
// AcceptPriceDeviationPpm is the price deviation in
79+
// parts per million that is accepted by the RFQ negotiator.
80+
//
81+
// Example: 50,000 ppm => price deviation is set to 5% .
82+
AcceptPriceDeviationPpm uint64
83+
7884
// SkipAcceptQuotePriceCheck is a flag that, when set, will cause the
7985
// RFQ negotiator to skip price validation on incoming quote accept
8086
// messages (this means that the price oracle will not be queried).
@@ -226,7 +232,7 @@ func (m *Manager) startSubsystems(ctx context.Context) error {
226232
NegotiatorCfg{
227233
PriceOracle: m.cfg.PriceOracle,
228234
OutgoingMessages: m.outgoingMessages,
229-
AcceptPriceDeviationPpm: DefaultAcceptPriceDeviationPpm,
235+
AcceptPriceDeviationPpm: m.cfg.AcceptPriceDeviationPpm,
230236
SkipAcceptQuotePriceCheck: m.cfg.SkipAcceptQuotePriceCheck,
231237
ErrChan: m.subsystemErrChan,
232238
},

sample-tapd.conf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,18 @@
310310
; (latency, etc)
311311
; prometheus.perfhistograms=false
312312

313-
[experimental.rfq]
313+
[experimental]
314314

315315
; Price oracle gRPC server address (rfqrpc://<hostname>:<port>)
316316
; To use the integrated mock, use the following value:
317317
; use_mock_price_oracle_service_promise_to_not_use_on_mainnet
318318
; experimental.rfq.priceoracleaddress=
319319

320+
; The default price deviation inparts per million that is accepted by
321+
; the RFQ negotiator.
322+
; Example: 50,000 ppm => price deviation is set to 5% .
323+
; experimental.rfq.acceptpricedeviationppm=50000
324+
320325
; Accept any price quote returned by RFQ peer, skipping price validation
321326
; experimental.rfq.skipacceptquotepricecheck=false
322327

tapcfg/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,12 @@ func DefaultConfig() Config {
428428
AddrBook: &AddrBookConfig{
429429
DisableSyncer: false,
430430
},
431-
Experimental: &ExperimentalConfig{},
431+
// nolint: lll
432+
Experimental: &ExperimentalConfig{
433+
Rfq: rfq.CliConfig{
434+
AcceptPriceDeviationPpm: rfq.DefaultAcceptPriceDeviationPpm,
435+
},
436+
},
432437
}
433438
}
434439

tapcfg/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
373373
ChannelLister: walletAnchor,
374374
AliasManager: lndRouterClient,
375375
// nolint: lll
376+
AcceptPriceDeviationPpm: rfqCfg.AcceptPriceDeviationPpm,
377+
// nolint: lll
376378
SkipAcceptQuotePriceCheck: rfqCfg.SkipAcceptQuotePriceCheck,
377379
ErrChan: mainErrChan,
378380
},

0 commit comments

Comments
 (0)