Skip to content

Commit b19e05f

Browse files
committed
ft_watcher: token router parser
Signed-off-by: bingyuyap <bingyu.yap.21@gmail.com>
1 parent fc3e7a1 commit b19e05f

16 files changed

+1996
-1640
lines changed

database/fast-transfer-schema.sql

+52-26
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,65 @@
1+
DROP TABLE IF EXISTS market_orders;
2+
DROP TABLE IF EXISTS fast_transfer_auctions;
3+
DROP TABLE IF EXISTS fast_transfer_executions;
4+
DROP TABLE IF EXISTS fast_transfer_settlements;
5+
DROP TABLE IF EXISTS auction_logs;
6+
7+
DROP TYPE IF EXISTS FastTransferStatus;
8+
DROP TYPE IF EXISTS FastTransferProtocol;
9+
110
CREATE TYPE FastTransferProtocol AS ENUM ('cctp', 'local', 'none');
2-
CREATE TYPE FastTransferStatus AS ENUM ('pending', 'no_offer', 'executed', 'settled');
11+
CREATE TYPE FastTransferStatus AS ENUM ('pending', 'no_offer', 'executed', 'settled', 'auction');
312

4-
CREATE TABLE fast_transfers (
5-
fast_transfer_id VARCHAR(255) PRIMARY KEY,
6-
fast_vaa_hash VARCHAR(255) NOT NULL,
13+
-- Market Order tracks events of when fast market orders are
14+
-- placed in the token router
15+
CREATE TABLE market_orders (
16+
fast_vaa_id VARCHAR(255) PRIMARY KEY,
17+
fast_vaa_hash VARCHAR(255),
18+
amount_in BIGINT,
19+
min_amount_out BIGINT,
20+
src_chain INTEGER,
21+
dst_chain INTEGER,
22+
sender VARCHAR(255),
23+
redeemer VARCHAR(255),
24+
market_order_tx_hash VARCHAR(255),
25+
market_order_timestamp TIMESTAMP,
26+
status FastTransferStatus NOT NULL DEFAULT 'pending'
27+
);
28+
29+
-- Auction tracks the latest state of the auction.
30+
-- It is created when the auction is created in the `placeInitialOfferCctp`
31+
-- ix in the MatchingEngine contract.
32+
CREATE TABLE fast_transfer_auctions (
33+
fast_vaa_hash VARCHAR(255) PRIMARY KEY,
734
auction_pubkey VARCHAR(255),
8-
amount BIGINT NOT NULL,
9-
initial_offer_time TIMESTAMP,
10-
src_chain INTEGER NOT NULL,
11-
dst_chain INTEGER NOT NULL,
12-
sender VARCHAR(255) NOT NULL,
13-
redeemer VARCHAR(255) NOT NULL,
14-
tx_hash VARCHAR(255) NOT NULL,
15-
timestamp TIMESTAMP NOT NULL,
16-
start_slot BIGINT NOT NULL,
17-
-- auction end on this slot
18-
end_slot BIGINT NOT NULL,
19-
-- deadline to execute the auction (end_slot + grace_period)
20-
deadline_slot BIGINT NOT NULL,
21-
-- current best offers
35+
initial_offer_tx_hash VARCHAR(255),
36+
initial_offer_timestamp TIMESTAMP,
37+
start_slot BIGINT,
38+
end_slot BIGINT,
39+
deadline_slot BIGINT,
2240
best_offer_amount BIGINT,
2341
best_offer_token VARCHAR(255),
24-
-- Enum: cctp, local, wormhole
25-
message_protocol FastTransferProtocol NOT NULL DEFAULT 'none',
26-
cctp_domain INT NULL,
27-
local_program_id VARCHAR(255) NULL,
28-
-- execution data
29-
status FastTransferStatus NOT NULL DEFAULT 'pending',
42+
message_protocol FastTransferProtocol DEFAULT 'none',
43+
cctp_domain INT,
44+
local_program_id VARCHAR(255)
45+
);
46+
47+
-- Execution is created when the execution is created in the `executeFastOrder`
48+
-- ix in the MatchingEngine contract.
49+
CREATE TABLE fast_transfer_executions (
50+
fast_vaa_hash VARCHAR(255) PRIMARY KEY,
3051
user_amount BIGINT,
3152
penalty BIGINT,
3253
execution_payer VARCHAR(255),
3354
execution_tx_hash VARCHAR(255),
3455
execution_slot BIGINT,
35-
execution_time TIMESTAMP,
36-
-- settle data
56+
execution_time TIMESTAMP
57+
);
58+
59+
-- Settlement is created when the settlement is created in the `settleFastTransfer`
60+
-- ix in the MatchingEngine contract.
61+
CREATE TABLE fast_transfer_settlements (
62+
fast_transfer_id VARCHAR(255) PRIMARY KEY,
3763
repayment BIGINT,
3864
settle_payer VARCHAR(255),
3965
settle_tx_hash VARCHAR(255),

0 commit comments

Comments
 (0)