@@ -23,7 +23,7 @@ demo demonstrates one way to host an exchange on the Solana blockchain by
23
23
emulating a currency exchange.
24
24
25
25
The assets are virtual tokens held by investors who may post trade requests to
26
- the exchange. A broker monitors the exchange and posts swap requests for
26
+ the exchange. A Swapper monitors the exchange and posts swap requests for
27
27
matching trade orders. All the transactions can execute concurrently.
28
28
29
29
## Premise
@@ -75,7 +75,7 @@ matching trade orders. All the transactions can execute concurrently.
75
75
contain the same information as the trade request.
76
76
- Price spread
77
77
- The difference between the two matching trade orders. The spread is the
78
- profit of the broker initiating the swap request.
78
+ profit of the Swapper initiating the swap request.
79
79
- Swap requirements
80
80
- Policies that result in a successful trade swap.
81
81
- Swap request
@@ -85,49 +85,49 @@ matching trade orders. All the transactions can execute concurrently.
85
85
swap requirements. A trade swap may not wholly satisfy one or both of the
86
86
trade orders in which case the trade orders are adjusted appropriately. As
87
87
long as the swap requirements are met there will be an exchange of tokens
88
- between accounts. Any price spread is deposited into the broker 's profit
88
+ between accounts. Any price spread is deposited into the Swapper 's profit
89
89
account. All trade swaps are recorded in a new account for posterity.
90
90
- Investor
91
91
- Individual investors who hold a number of tokens and wish to trade them on
92
92
the exchange. Investors operate as Solana thin clients who own a set of
93
93
accounts containing tokens and/or trade requests. Investors post
94
94
transactions to the exchange in order to request tokens and post or cancel
95
95
trade requests.
96
- - Broker
97
- - An agent who facilitates trading between investors. Brokers operate as
96
+ - Swapper
97
+ - An agent who facilitates trading between investors. Swappers operate as
98
98
Solana thin clients who monitor all the trade orders looking for a trade
99
- match. Once found, the broker issues a swap request to the exchange.
100
- Brokers are the engine of the exchange and are rewarded for their efforts by
101
- accumulating the price spreads of the swaps they initiate. Brokers also
99
+ match. Once found, the Swapper issues a swap request to the exchange.
100
+ Swappers are the engine of the exchange and are rewarded for their efforts by
101
+ accumulating the price spreads of the swaps they initiate. Swappers also
102
102
provide current bid/ask price and OHLCV (Open, High, Low, Close, Volume)
103
103
information on demand via a public network port.
104
104
- Transaction fees
105
105
- Solana transaction fees are paid for by the transaction submitters who are
106
- the Investors and Brokers .
106
+ the Investors and Swappers .
107
107
108
108
## Exchange startup
109
109
110
110
The exchange is up and running when it reaches a state where it can take
111
- investor's trades and broker 's swap requests. To achieve this state the
111
+ investor's trades and Swapper 's swap requests. To achieve this state the
112
112
following must occur in order:
113
113
114
114
- Start the Solana blockchain
115
- - Start the broker thin-client
116
- - The broker subscribes to change notifications for all the accounts owned by
115
+ - Start the Swapper thin-client
116
+ - The Swapper subscribes to change notifications for all the accounts owned by
117
117
the exchange program id. The subscription is managed via Solana's JSON RPC
118
118
interface.
119
- - The broker starts responding to queries for bid/ask price and OHLCV
119
+ - The Swapper starts responding to queries for bid/ask price and OHLCV
120
120
121
- The broker responding successfully to price and OHLCV requests is the signal to
121
+ The Swapper responding successfully to price and OHLCV requests is the signal to
122
122
the investors that trades submitted after that point will be analyzed. <!--This
123
123
is not ideal, and instead investors should be able to submit trades at any time,
124
- and the broker could come and go without missing a trade. One way to achieve
125
- this is for the broker to read the current state of all accounts looking for all
124
+ and the Swapper could come and go without missing a trade. One way to achieve
125
+ this is for the Swapper to read the current state of all accounts looking for all
126
126
open trade orders.-->
127
127
128
128
Investors will initially query the exchange to discover their current balance
129
129
for each type of token. If the investor does not already have an account for
130
- each type of token, they will submit account requests. Brokers as well will
130
+ each type of token, they will submit account requests. Swappers as well will
131
131
request accounts to hold the tokens they earn by initiating trade swaps.
132
132
133
133
``` rust
@@ -165,7 +165,7 @@ pub struct TokenAccountInfo {
165
165
}
166
166
```
167
167
168
- For this demo investors or brokers can request more tokens from the exchange at
168
+ For this demo investors or Swappers can request more tokens from the exchange at
169
169
any time by submitting token requests. In non-demos, an exchange of this type
170
170
would provide another way to exchange a 3rd party asset into tokens.
171
171
@@ -269,10 +269,10 @@ pub enum ExchangeInstruction {
269
269
270
270
## Trade swaps
271
271
272
- The broker is monitoring the accounts assigned to the exchange program and
272
+ The Swapper is monitoring the accounts assigned to the exchange program and
273
273
building a trade-order table. The trade order table is used to identify
274
274
matching trade orders which could be fulfilled. When a match is found the
275
- broker should issue a swap request. Swap requests may not satisfy the entirety
275
+ Swapper should issue a swap request. Swap requests may not satisfy the entirety
276
276
of either order, but the exchange will greedily fulfill it. Any leftover tokens
277
277
in either account will keep the trade order valid for further swap requests in
278
278
the future.
@@ -310,14 +310,14 @@ whole for clarity.
310
310
| 5 | 1 T AB 2 10 | 2 F AB 1 5 |
311
311
312
312
As part of a successful swap request, the exchange will credit tokens to the
313
- broker 's account equal to the difference in the price ratios or the two orders.
314
- These tokens are considered the broker 's profit for initiating the trade.
313
+ Swapper 's account equal to the difference in the price ratios or the two orders.
314
+ These tokens are considered the Swapper 's profit for initiating the trade.
315
315
316
- The broker would initiate the following swap on the order table above:
316
+ The Swapper would initiate the following swap on the order table above:
317
317
318
318
- Row 1, To: Investor 1 trades 2 A tokens to 8 B tokens
319
319
- Row 1, From: Investor 2 trades 2 A tokens from 8 B tokens
320
- - Broker takes 8 B tokens as profit
320
+ - Swapper takes 8 B tokens as profit
321
321
322
322
Both row 1 trades are fully realized, table becomes:
323
323
@@ -328,11 +328,11 @@ Both row 1 trades are fully realized, table becomes:
328
328
| 3 | 1 T AB 2 8 | 2 F AB 3 6 |
329
329
| 4 | 1 T AB 2 10 | 2 F AB 1 5 |
330
330
331
- The broker would initiate the following swap:
331
+ The Swapper would initiate the following swap:
332
332
333
333
- Row 1, To: Investor 1 trades 1 A token to 4 B tokens
334
334
- Row 1, From: Investor 2 trades 1 A token from 4 B tokens
335
- - Broker takes 4 B tokens as profit
335
+ - Swapper takes 4 B tokens as profit
336
336
337
337
Row 1 From is not fully realized, table becomes:
338
338
@@ -343,11 +343,11 @@ Row 1 From is not fully realized, table becomes:
343
343
| 3 | 1 T AB 2 10 | 2 F AB 3 6 |
344
344
| 4 | | 2 F AB 1 5 |
345
345
346
- The broker would initiate the following swap:
346
+ The Swapper would initiate the following swap:
347
347
348
348
- Row 1, To: Investor 1 trades 1 A token to 6 B tokens
349
349
- Row 1, From: Investor 2 trades 1 A token from 6 B tokens
350
- - Broker takes 2 B tokens as profit
350
+ - Swapper takes 2 B tokens as profit
351
351
352
352
Row 1 To is now fully realized, table becomes:
353
353
@@ -357,11 +357,11 @@ Row 1 To is now fully realized, table becomes:
357
357
| 2 | 1 T AB 2 8 | 2 F AB 3 5 |
358
358
| 3 | 1 T AB 2 10 | 2 F AB 1 5 |
359
359
360
- The broker would initiate the following last swap:
360
+ The Swapper would initiate the following last swap:
361
361
362
362
- Row 1, To: Investor 1 trades 2 A token to 12 B tokens
363
363
- Row 1, From: Investor 2 trades 2 A token from 12 B tokens
364
- - Broker takes 4 B tokens as profit
364
+ - Swapper takes 4 B tokens as profit
365
365
366
366
Table becomes:
367
367
@@ -383,7 +383,7 @@ pub enum ExchangeInstruction {
383
383
/// key 3 - `From` trade order
384
384
/// key 4 - Token account associated with the To Trade
385
385
/// key 5 - Token account associated with From trade
386
- /// key 6 - Token account in which to deposit the brokers profit from the swap.
386
+ /// key 6 - Token account in which to deposit the Swappers profit from the swap.
387
387
SwapRequest ,
388
388
}
389
389
@@ -442,14 +442,14 @@ pub enum ExchangeInstruction {
442
442
/// key 3 - `From` trade order
443
443
/// key 4 - Token account associated with the To Trade
444
444
/// key 5 - Token account associated with From trade
445
- /// key 6 - Token account in which to deposit the brokers profit from the swap.
445
+ /// key 6 - Token account in which to deposit the Swappers profit from the swap.
446
446
SwapRequest ,
447
447
}
448
448
```
449
449
450
450
## Quotes and OHLCV
451
451
452
- The broker will provide current bid/ask price quotes based on trade actively and
452
+ The Swapper will provide current bid/ask price quotes based on trade actively and
453
453
also provide OHLCV based on some time window. The details of how the bid/ask
454
454
price quotes are calculated are yet to be decided.
455
455
0 commit comments