Expose integer base fees alongside execution fee curves
This commit is contained in:
@@ -233,6 +233,16 @@ END;
|
||||
CREATE TABLE IF NOT EXISTS market_fee_rates (
|
||||
market TEXT PRIMARY KEY REFERENCES markets(id), rate_ppm INTEGER NOT NULL CHECK(rate_ppm BETWEEN 0 AND 1000000)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS market_base_fees (
|
||||
market TEXT PRIMARY KEY REFERENCES markets(id), maker_bps INTEGER NOT NULL CHECK(maker_bps>=0),
|
||||
taker_bps INTEGER NOT NULL CHECK(taker_bps>=0)
|
||||
);
|
||||
-- Older editions stored only the execution curve. Publish its coefficient as an
|
||||
-- integer basis-point default only when that conversion is exact.
|
||||
CREATE VIEW IF NOT EXISTS market_fee_terms AS
|
||||
SELECT m.id AS market, COALESCE(f.rate_ppm,0) AS rate_ppm, COALESCE(b.maker_bps,0) AS maker_bps,
|
||||
COALESCE(b.taker_bps,CASE WHEN COALESCE(f.rate_ppm,0)%100=0 THEN COALESCE(f.rate_ppm,0)/100 END) AS taker_bps
|
||||
FROM markets m LEFT JOIN market_fee_rates f ON f.market=m.id LEFT JOIN market_base_fees b ON b.market=m.id;
|
||||
CREATE TABLE IF NOT EXISTS cash_remainders (
|
||||
account TEXT PRIMARY KEY REFERENCES accounts(id), micros INTEGER NOT NULL CHECK(micros BETWEEN 0 AND 9999)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user