-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2584 from get10101/feat/funding-fee-extravaganza
Funding fee feature
- Loading branch information
Showing
100 changed files
with
4,303 additions
and
953 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
coordinator/migrations/2024-05-01-042936_add_rollover_params_table/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS rollover_params; |
13 changes: 13 additions & 0 deletions
13
coordinator/migrations/2024-05-01-042936_add_rollover_params_table/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE TABLE rollover_params | ||
( | ||
id SERIAL PRIMARY KEY NOT NULL, | ||
protocol_id UUID NOT NULL REFERENCES dlc_protocols (protocol_id), | ||
trader_pubkey TEXT NOT NULL, | ||
margin_coordinator_sat BIGINT NOT NULL, | ||
margin_trader_sat BIGINT NOT NULL, | ||
leverage_coordinator REAL NOT NULL, | ||
leverage_trader REAL NOT NULL, | ||
liquidation_price_coordinator REAL NOT NULL, | ||
liquidation_price_trader REAL NOT NULL, | ||
expiry_timestamp TIMESTAMP WITH TIME ZONE NOT NULL | ||
); |
2 changes: 2 additions & 0 deletions
2
coordinator/migrations/2024-05-01-062836_add_funding_rate_tables/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
drop table if exists funding_rates; | ||
drop table if exists funding_fee_event; |
31 changes: 31 additions & 0 deletions
31
coordinator/migrations/2024-05-01-062836_add_funding_rate_tables/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
CREATE TABLE funding_rates | ||
( | ||
id SERIAL PRIMARY KEY NOT NULL, | ||
start_date TIMESTAMP WITH TIME ZONE NOT NULL, | ||
end_date TIMESTAMP WITH TIME ZONE NOT NULL, | ||
rate REAL NOT NULL, | ||
timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
CREATE TABLE funding_fee_events | ||
( | ||
id SERIAL PRIMARY KEY NOT NULL, | ||
amount_sats BIGINT NOT NULL, | ||
trader_pubkey TEXT NOT NULL, | ||
position_id INTEGER REFERENCES positions (id) NOT NULL, | ||
due_date TIMESTAMP WITH TIME ZONE NOT NULL, | ||
price REAL NOT NULL, | ||
funding_rate REAL NOT NULL, | ||
paid_date TIMESTAMP WITH TIME ZONE, | ||
timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
-- To prevent generating duplicates for the same position. | ||
UNIQUE (position_id, due_date) | ||
); | ||
|
||
CREATE TABLE protocol_funding_fee_events | ||
( | ||
id SERIAL PRIMARY KEY NOT NULL, | ||
protocol_id UUID REFERENCES dlc_protocols (protocol_id) NOT NULL, | ||
funding_fee_event_id INTEGER REFERENCES funding_fee_events (id) NOT NULL, | ||
timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.