Skip to content

Commit fb25ae3

Browse files
committed
rfq: integrate PortfolioPilot into negotiator and manager configuration
- Add PortfolioPilot to Negotiator and Manager structs. - Use internal implementation of PortfolioPilot if not specified.
1 parent 6972465 commit fb25ae3

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

rfq/manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ type ManagerCfg struct {
101101
// determine whether a quote is accepted or rejected.
102102
PriceOracle PriceOracle
103103

104+
// PortfolioPilot is the portfolio pilot that will make financial
105+
// decisions based on RFQ requests.
106+
PortfolioPilot PortfolioPilot
107+
104108
// ChannelLister is the channel lister that the RFQ manager will use to
105109
// determine the available channels for routing.
106110
ChannelLister ChannelLister
@@ -267,6 +271,7 @@ func (m *Manager) startSubsystems(ctx context.Context) error {
267271
// Initialise and start the quote negotiator.
268272
m.negotiator, err = NewNegotiator(NegotiatorCfg{
269273
PriceOracle: m.cfg.PriceOracle,
274+
PortfolioPilot: m.cfg.PortfolioPilot,
270275
OutgoingMessages: m.outgoingMessages,
271276
AcceptPriceDeviationPpm: m.cfg.AcceptPriceDeviationPpm,
272277
SkipAcceptQuotePriceCheck: m.cfg.SkipAcceptQuotePriceCheck,

rfq/negotiator.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ type NegotiatorCfg struct {
3333
// determine whether a quote is accepted or rejected.
3434
PriceOracle PriceOracle
3535

36+
// PortfolioPilot makes financial decisions when evaluating quotes.
37+
PortfolioPilot PortfolioPilot
38+
3639
// OutgoingMessages is a channel which is populated with outgoing peer
3740
// messages. These are messages which are destined to be sent to peers.
3841
OutgoingMessages chan<- rfqmsg.OutgoingMsg
@@ -93,6 +96,18 @@ type Negotiator struct {
9396

9497
// NewNegotiator creates a new quote negotiator.
9598
func NewNegotiator(cfg NegotiatorCfg) (*Negotiator, error) {
99+
// If the portfolio pilot is not specified, then we will use the
100+
// internal portfolio pilot.
101+
if cfg.PortfolioPilot == nil {
102+
cfgPortfolioPilot := InternalPortfolioPilotConfig{
103+
PriceOracle: cfg.PriceOracle,
104+
ForwardPeerIDToOracle: cfg.SendPeerId,
105+
}
106+
cfg.PortfolioPilot = NewInternalPortfolioPilot(
107+
cfgPortfolioPilot,
108+
)
109+
}
110+
96111
return &Negotiator{
97112
cfg: cfg,
98113

0 commit comments

Comments
 (0)