|
| 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 | + |
1 | 10 | 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'); |
3 | 12 |
|
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, |
7 | 34 | 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, |
22 | 40 | best_offer_amount BIGINT,
|
23 | 41 | 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, |
30 | 51 | user_amount BIGINT,
|
31 | 52 | penalty BIGINT,
|
32 | 53 | execution_payer VARCHAR(255),
|
33 | 54 | execution_tx_hash VARCHAR(255),
|
34 | 55 | 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, |
37 | 63 | repayment BIGINT,
|
38 | 64 | settle_payer VARCHAR(255),
|
39 | 65 | settle_tx_hash VARCHAR(255),
|
|
0 commit comments