-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlssdrpc.proto
More file actions
204 lines (177 loc) · 5.59 KB
/
lssdrpc.proto
File metadata and controls
204 lines (177 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
syntax = "proto3";
package lssdrpc;
// A non-negative Big Integer represented as string, like "100000000"
message BigInteger {
string value = 1;
}
enum OrderSide {
buy = 0;
sell = 1;
}
// currencies
service currencies {
// before being able to enable a trading pair, you need to add the two involved currencies
// for example, for activating XSN_LTC, you will add the XSN currency, and the LTC currency.
//
// For now, only currencies supported by lnd (lightning network) work.
rpc AddCurrency (AddCurrencyRequest) returns (AddCurrencyResponse);
}
message AddCurrencyRequest {
// the currency, like XSN or LTC
string currency = 1;
// the address:port allowing lssd to connect to this currency lnd, like "localhost:10001"
// right now, it is assumed that the bot runs on the same network than lssd, so, there is
// no support for authentication.
string lndChannel = 2;
// the tls certificate used by lnd, so that lssd can be sure it's connecting to the right lnd
oneof tlsCert {
// the path to the tls certificate, if the certificate is stored on the same computer
string certPath = 3;
// the raw tls certificate represented as string
string rawCert = 4;
}
}
message AddCurrencyResponse {}
// trading pairs
service tradingPairs {
// Enables the given trading pair, like XSN_LTC, before calling this method, you must
// have already added the involved currencies.
//
// After enabling a trading pair, lssd will download the existing orders form the orderbook,
// try waiting some seconds (5 should be enough) before performing any other operation, so
// that lssd has the time to sync because this is done in the background.
rpc EnableTradingPair (EnableTradingPairRequest) returns (EnableTradingPairResponse);
}
message EnableTradingPairRequest {
string pairId = 1; // the trading pair to enable, like XSN_LTC
}
message EnableTradingPairResponse {}
// orders
service orders {
// Places an order to the orderbook, you must have already enabled the involved trading pair.
//
// NOTE: After the order is matched, lssd will perform the swap automatically, so, your lnd
// needs to have a channel with enough coins to our hub.
rpc PlaceOrder (PlaceOrderRequest) returns (PlaceOrderResponse);
// Cancels an existing order.
rpc CancelOrder (CancelOrderRequest) returns (CancelOrderResponse);
// Susbcribe to events related to the orders in the orderbook.
rpc SubscribeOrders (SubscribeOrdersRequest) returns (stream OrderUpdate);
// List the available order on the orderbook.
rpc ListOrders (ListOrdersRequest) returns (ListOrdersResponse);
}
message ListOrdersRequest {
string pairId = 1;
bool includeOwnOrders = 2;
uint32 skip = 3;
uint32 limit = 4;
}
message ListOrdersResponse {
repeated Order orders = 1;
}
message PlaceOrderRequest {
string pairId = 1;
OrderSide side = 2; // whether you are buying or selling
BigInteger funds = 3; // the funds you want to exchange
BigInteger price = 4; // missing on market orders
}
// Outcome of place order, three possible situations
// 1. Order was placed
// 2. Order was placed and matched without going to orderbook
// 3. Place order or swap has failed
message PlaceOrderResponse {
oneof outcome {
SwapSuccess swapSuccess = 1;
Order order = 2;
PlaceOrderFailure failure = 3;
}
}
message OrderbookFailure {
string pairId = 1;
BigInteger funds = 2;
string failureReason = 3;
BigInteger requiredFee = 4;
}
message PlaceOrderFailure {
oneof failure {
SwapFailure swapFailure = 1;
OrderbookFailure orderbookFailure = 2;
}
}
message CancelOrderRequest {
string pairId = 1;
string orderId = 2;
}
message CancelOrderResponse {}
message SubscribeOrdersRequest {}
message OrderUpdate {
oneof update {
// An order that was added to the order book.
Order order = 1;
// An order that was removed from the order book.
Order orderRemoval = 2;
}
}
message Order {
string pairId = 1;
string orderId = 2;
// The price of the order in satoshis.
BigInteger price = 3;
// The funds of the order in satoshis.
BigInteger funds = 4;
// The epoch time when this order was created.
uint64 createdAt = 5;
// Whether this order is a buy or sell
OrderSide side = 6;
// Whether this order is a local own order or a remote peer order.
bool isOwnOrder = 7;
}
// swaps
service swaps {
rpc SubscribeSwaps (SubscribeSwapsRequest) returns (stream SwapResult);
}
message SubscribeSwapsRequest {}
message SwapResult {
oneof value {
SwapSuccess success = 1;
SwapFailure failure = 2;
}
}
message SwapSuccess {
// Order id assigned by orderbook
string orderId = 1;
// The trading pair that the swap is for.
string pairId = 2;
// The order funds that was swapped.
BigInteger funds = 3;
// The hex-encoded payment hash for the swap.
string rHash = 4;
// The amount received denominated in satoshis.
BigInteger amountReceived = 5;
// The amount sent denominated in satoshis.
BigInteger amountSent = 6;
enum Role {
TAKER = 0;
MAKER = 1;
}
// Our role in the swap, either MAKER or TAKER.
Role role = 7;
// The ticker symbol of the currency received.
string currencyReceived = 8;
// The ticker symbol of the currency sent.
string currencySent = 9;
// The hex-encoded preimage.
string rPreimage = 10;
// The price used for the swap.
BigInteger price = 11;
}
message SwapFailure {
// Order id assigned by orderbook
string orderId = 1;
// The trading pair that the swap is for.
string pairId = 2;
// The order funds that was attempted to be swapped.
BigInteger funds = 3;
// The reason why the swap failed.
string failureReason = 4;
}