Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit f6c7812

Browse files
authored
Rename Broker to Swapper (#4371)
1 parent 2f7561e commit f6c7812

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

bench-exchange/README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ demo demonstrates one way to host an exchange on the Solana blockchain by
2323
emulating a currency exchange.
2424

2525
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
2727
matching trade orders. All the transactions can execute concurrently.
2828

2929
## Premise
@@ -75,7 +75,7 @@ matching trade orders. All the transactions can execute concurrently.
7575
contain the same information as the trade request.
7676
- Price spread
7777
- 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.
7979
- Swap requirements
8080
- Policies that result in a successful trade swap.
8181
- Swap request
@@ -85,49 +85,49 @@ matching trade orders. All the transactions can execute concurrently.
8585
swap requirements. A trade swap may not wholly satisfy one or both of the
8686
trade orders in which case the trade orders are adjusted appropriately. As
8787
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
8989
account. All trade swaps are recorded in a new account for posterity.
9090
- Investor
9191
- Individual investors who hold a number of tokens and wish to trade them on
9292
the exchange. Investors operate as Solana thin clients who own a set of
9393
accounts containing tokens and/or trade requests. Investors post
9494
transactions to the exchange in order to request tokens and post or cancel
9595
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
9898
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
102102
provide current bid/ask price and OHLCV (Open, High, Low, Close, Volume)
103103
information on demand via a public network port.
104104
- Transaction fees
105105
- Solana transaction fees are paid for by the transaction submitters who are
106-
the Investors and Brokers.
106+
the Investors and Swappers.
107107

108108
## Exchange startup
109109

110110
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
112112
following must occur in order:
113113

114114
- 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
117117
the exchange program id. The subscription is managed via Solana's JSON RPC
118118
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
120120

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
122122
the investors that trades submitted after that point will be analyzed. <!--This
123123
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
126126
open trade orders.-->
127127

128128
Investors will initially query the exchange to discover their current balance
129129
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
131131
request accounts to hold the tokens they earn by initiating trade swaps.
132132

133133
```rust
@@ -165,7 +165,7 @@ pub struct TokenAccountInfo {
165165
}
166166
```
167167

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
169169
any time by submitting token requests. In non-demos, an exchange of this type
170170
would provide another way to exchange a 3rd party asset into tokens.
171171

@@ -269,10 +269,10 @@ pub enum ExchangeInstruction {
269269

270270
## Trade swaps
271271

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
273273
building a trade-order table. The trade order table is used to identify
274274
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
276276
of either order, but the exchange will greedily fulfill it. Any leftover tokens
277277
in either account will keep the trade order valid for further swap requests in
278278
the future.
@@ -310,14 +310,14 @@ whole for clarity.
310310
| 5 | 1 T AB 2 10 | 2 F AB 1 5 |
311311

312312
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.
315315

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:
317317

318318
- Row 1, To: Investor 1 trades 2 A tokens to 8 B tokens
319319
- 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
321321

322322
Both row 1 trades are fully realized, table becomes:
323323

@@ -328,11 +328,11 @@ Both row 1 trades are fully realized, table becomes:
328328
| 3 | 1 T AB 2 8 | 2 F AB 3 6 |
329329
| 4 | 1 T AB 2 10 | 2 F AB 1 5 |
330330

331-
The broker would initiate the following swap:
331+
The Swapper would initiate the following swap:
332332

333333
- Row 1, To: Investor 1 trades 1 A token to 4 B tokens
334334
- 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
336336

337337
Row 1 From is not fully realized, table becomes:
338338

@@ -343,11 +343,11 @@ Row 1 From is not fully realized, table becomes:
343343
| 3 | 1 T AB 2 10 | 2 F AB 3 6 |
344344
| 4 | | 2 F AB 1 5 |
345345

346-
The broker would initiate the following swap:
346+
The Swapper would initiate the following swap:
347347

348348
- Row 1, To: Investor 1 trades 1 A token to 6 B tokens
349349
- 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
351351

352352
Row 1 To is now fully realized, table becomes:
353353

@@ -357,11 +357,11 @@ Row 1 To is now fully realized, table becomes:
357357
| 2 | 1 T AB 2 8 | 2 F AB 3 5 |
358358
| 3 | 1 T AB 2 10 | 2 F AB 1 5 |
359359

360-
The broker would initiate the following last swap:
360+
The Swapper would initiate the following last swap:
361361

362362
- Row 1, To: Investor 1 trades 2 A token to 12 B tokens
363363
- 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
365365

366366
Table becomes:
367367

@@ -383,7 +383,7 @@ pub enum ExchangeInstruction {
383383
/// key 3 - `From` trade order
384384
/// key 4 - Token account associated with the To Trade
385385
/// 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.
387387
SwapRequest,
388388
}
389389

@@ -442,14 +442,14 @@ pub enum ExchangeInstruction {
442442
/// key 3 - `From` trade order
443443
/// key 4 - Token account associated with the To Trade
444444
/// 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.
446446
SwapRequest,
447447
}
448448
```
449449

450450
## Quotes and OHLCV
451451

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
453453
also provide OHLCV based on some time window. The details of how the bid/ask
454454
price quotes are calculated are yet to be decided.
455455

0 commit comments

Comments
 (0)