Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
2b26bef
get order by uuid fn test
shanu516516 Feb 14, 2024
7c04ba4
RelayerDB in lib
shanu516516 Feb 14, 2024
8c3f53a
pub
shanu516516 Feb 14, 2024
8875296
git update in cargo toml
shanu516516 Feb 14, 2024
b62933b
cargo toml bug
shanu516516 Feb 14, 2024
3eb4233
Candle fixes
tjsharp1 Mar 12, 2024
d6196fe
Update filter
tjsharp1 Mar 13, 2024
f4e42b2
Merge remote-tracking branch 'origin/initial-database' into develop
shanu516516 Mar 19, 2024
8d3652e
delay in ws
shanu516516 Mar 19, 2024
081a98e
24hr change data interval added
shanu516516 Mar 19, 2024
3b2b4ea
typo error
shanu516516 Mar 20, 2024
14762d3
websocket 24hour change correction
shanu516516 Mar 21, 2024
ac937fe
24hour change candle update every 1 sec
shanu516516 Mar 21, 2024
5848a6d
order query
shanu516516 Mar 22, 2024
aaf6cf0
Merge remote-tracking branch 'origin/develop' into zkos-integration-l…
shanu516516 Mar 22, 2024
5f872ef
order query for trader order
shanu516516 Mar 22, 2024
de5489a
trader order query api
shanu516516 Mar 22, 2024
98541d1
query lend order from public api
shanu516516 Mar 22, 2024
c24cb92
Merge pull request #21 from twilight-project/zkos-integration-lib-create
shanu516516 Mar 22, 2024
b64e822
Merge pull request #22 from twilight-project/main
shanu516516 Mar 22, 2024
7547475
rpc open api shifted to public api module
shanu516516 Mar 26, 2024
4b2b13e
request id added in order submit and settle rpc
shanu516516 Mar 26, 2024
3f17cbf
order status sql types update
shanu516516 Mar 26, 2024
34022ca
temp migration
shanu516516 Mar 27, 2024
c6b009f
Txhash update added
shanu516516 Mar 27, 2024
1a5ac6b
Add aggregation tables
tjsharp1 Mar 28, 2024
f70c69f
Merge remote-tracking branch 'origin/add-aggregation-tables' into dev…
shanu516516 Apr 2, 2024
4265680
date_trunc for candle update
Apr 7, 2024
dc184b8
Merge pull request #23 from twilight-project/add-aggregation-tables
shanu516516 Apr 9, 2024
c8c794a
Increase connection limit
May 2, 2024
bb7d229
Catchup for candle updates
May 4, 2024
997026e
Spawn query task for candles
May 13, 2024
a2a4a32
Merge remote-tracking branch 'origin/add-aggregation-tables' into dev…
shanu516516 May 18, 2024
ab35d32
delete test feed
shanu516516 May 18, 2024
26930d9
branch update
shanu516516 May 18, 2024
c4aec67
orderbook update
shanu516516 May 18, 2024
0a52bea
liquidation event update
shanu516516 May 21, 2024
41827be
orderbook correction
shanu516516 May 22, 2024
61c1b81
Merge branch 'develop-merge-psql' of https://github.com/twilight-proj…
shanu516516 May 22, 2024
5b043b9
missing orders added in recent order script
shanu516516 May 22, 2024
f0187f3
correcting bid and ask for recent order
shanu516516 May 22, 2024
ec4d75e
Fix aggregation start time
May 28, 2024
710d102
cargo update for zkos-rust
shanu516516 May 30, 2024
578b142
temperary update
shanu516516 Jun 6, 2024
f94973a
Update orderbook with sorted set commands
Jun 10, 2024
46483ba
optimized script for recent order api
shanu516516 Jun 13, 2024
4879fb0
Update query
Jun 17, 2024
2bcc784
Increase batch size
Jun 17, 2024
7a5590e
commit interval
Jun 17, 2024
50a22ff
batch size update
shanu516516 Jun 19, 2024
7f705f8
BtcUsdPrice::update_candles removed from archiver
shanu516516 Jun 20, 2024
43f3dc4
trigger added for null request id
shanu516516 Jun 20, 2024
5d3d6ea
minor update on trigger
shanu516516 Jun 20, 2024
f679853
Remove catchup logic
Jun 23, 2024
19d3711
recent order query optimize
shanu516516 Jun 24, 2024
de0d447
repeated index removed
shanu516516 Jun 24, 2024
8dbf96c
Merge branch 'develop-merge-psql' of https://github.com/twilight-proj…
shanu516516 Jun 24, 2024
e684bf8
minor bug fixed
shanu516516 Jun 25, 2024
ff215cb
index bug removed
shanu516516 Jun 26, 2024
8c281e4
orderbook data correction
shanu516516 Jun 27, 2024
c28f448
Add redis caching
Jul 15, 2024
1612a96
event type added
shanu516516 Jul 17, 2024
7708f15
Merge branch 'develop-merge-psql' of https://github.com/twilight-proj…
shanu516516 Jul 17, 2024
33ce2ba
query bug fixed
shanu516516 Jul 17, 2024
542afef
Redis updates
Jul 24, 2024
156a6b5
funding updates seperated from trader order table
shanu516516 Jul 26, 2024
000eda8
Merge pull request #31 from twilight-project/develop-psql-old-before-…
shanu516516 Jul 27, 2024
d0c8da5
minor change
shanu516516 Jul 29, 2024
72da538
Cache updates
Jul 29, 2024
6f5103e
Update types
Aug 5, 2024
bd6b989
lua script update
shanu516516 Aug 6, 2024
da25799
minor bug
shanu516516 Aug 9, 2024
aae7f77
minor update correcting side for order settle
shanu516516 Aug 12, 2024
12cc303
duplicate order in api fixed
shanu516516 Aug 12, 2024
841edf3
minor bug in orderbook
shanu516516 Aug 20, 2024
2026f89
price correction for recent order at settlement or liq. in redis
shanu516516 Jun 19, 2025
77a04dc
public method pool_share_value added
shanu516516 Jun 20, 2025
53a1d9c
redis check
shanu516516 Jun 21, 2025
2cef085
redis orderbook insert update
shanu516516 Jun 21, 2025
35cc94d
old side remove correction
shanu516516 Jun 21, 2025
5f02192
echo removed
shanu516516 Jun 21, 2025
6293914
TraderOrderLimitUpdate
shanu516516 Jun 22, 2025
7a6f768
orderbook insert correction at restart
shanu516516 Jun 22, 2025
727625b
redis script update on settle order by limit price
shanu516516 Jun 23, 2025
a61de64
orderbook view added in postgresql and changed query orderbook from t…
shanu516516 Jun 23, 2025
61f34a8
websocket update Recent order struct correction
shanu516516 Jun 24, 2025
bbbefb6
new orderbook entry correction
shanu516516 Jun 24, 2025
ddccf64
minor correction in order book
shanu516516 Jun 24, 2025
ba7801a
minor correction orderbook new data only
shanu516516 Jun 24, 2025
cf74e45
all lowercase in NewOrderBookOrder
shanu516516 Jun 24, 2025
0a4d31c
bug fix
shanu516516 Jun 24, 2025
54bf8d7
migration update
shanu516516 Jun 24, 2025
c8f1a91
Recend order wrong entry price
shanu516516 Jun 24, 2025
41a28c8
position size update for settle order in redis script
shanu516516 Jun 25, 2025
6365b3e
remove .env files
shanu516516 Jun 26, 2025
5a2b26a
.env.example added
shanu516516 Jun 26, 2025
77c00e2
branch update to develop
shanu516516 Jun 26, 2025
b0f06de
docker file update
shanu516516 Jun 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions .compose.env

This file was deleted.

74 changes: 0 additions & 74 deletions .env

This file was deleted.

20 changes: 20 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Authentication and Logging Configuration
NGINX_AUTH_SECRET="FNiPGdfBuvqToL7PHu4EHzu7ehSr8+L5yV2kkxSutSo" # Secret key for NGINX authentication
RUST_LOG=info # Logging level for Rust applications

# Database Connection URLs
DATABASE_URL=<PostgreSQL_database_connection_string> # Main PostgreSQL database connection
REDIS_HOSTNAME=<Redis_cache_connection_string> # Redis cache connection
BROKER=<Kafka_message_broker_connection> # Kafka message broker connection

# Event Logging Topics
PRICE_LOG=BinanceMiniTickerPayload # Topic for price updates
RPC_CLIENT_REQUEST=CLIENT-REQUEST # Topic for RPC client requests
RPC_CLIENT_FAILED_REQUEST=CLIENT-FAILED-REQUEST # Topic for failed RPC requests

# Event Log Topics for Different Components
TRADERORDER_EVENT_LOG=CoreEventLogTopic # Topic for trader order events
LENDORDER_EVENT_LOG=CoreEventLogTopic # Topic for lending order events
LENDPOOL_EVENT_LOG=CoreEventLogTopic # Topic for lending pool events
CORE_EVENT_LOG=CoreEventLogTopic # Topic for core system events
SNAPSHOT_LOG=SnapShotLogTopic # Topic for snapshot events
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ node_modules

#/target
/Cargo.lock
.vscode
.vscode
.env
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ name = "archiver"
[[bin]]
name = "api"

# [lib]
# name = "relayerarchiverlib"
# path = "src/lib.rs"
[lib]
name = "relayerarchiverlib"
path = "src/lib.rs"


[dependencies]
Expand Down Expand Up @@ -67,14 +67,14 @@ tower-http = { version = "0.4", features = [
"validate-request",
] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
twilight-relayer-rust = { git = "ssh://git@github.com/twilight-project/twilight-relayer.git", branch = "output-archiver-0.03.031" }

uuid = { version = "1.3.3", features = ["serde", "v4", "v7"] }
verify-keplr-sign = "0.1.0"
twilight-relayer-rust = { git = "ssh://git@github.com/twilight-project/twilight-relayer.git", branch = "develop" }
redis = { version = "0.25.4", features = ["r2d2"] }

[dependencies.zkos-relayer-wallet]
git = "ssh://github.com/twilight-project/zkos-relayer-wallet.git"
git = "ssh://git@github.com/twilight-project/zkos-relayer-wallet.git"
branch = "develop"
[dependencies.zkos-client-wallet]
git = "ssh://github.com/twilight-project/zkos-client-wallet.git"
git = "ssh://git@github.com/twilight-project/zkos-client-wallet.git"
branch = "develop"
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
FROM rust:1.72.0-slim-buster as builder
FROM rust:1.87 as builder

ARG SSH_KEY
RUN apt-get update && apt-get install -y openssh-client git libssl-dev build-essential libpq-dev pkg-config
RUN mkdir /root/.ssh
RUN echo "${SSH_KEY}" > /root/.ssh/id_rsa && \
RUN echo "${SSH_KEY}" > /root/.ssh/id_ed25519 && \
touch /root/.ssh/known_hosts && \
ssh-keyscan github.com >> /root/.ssh/known_hosts && \
chmod 0600 /root/.ssh/id_rsa

chmod 0600 /root/.ssh/id_ed25519
COPY . ./twilight-relayerAPI
WORKDIR /twilight-relayerAPI

RUN git config --global url."ssh://git@github.com/".insteadOf https://github.com/
RUN git config --global url."ssh://git@github.com/".insteadOf ssh://github.com/

RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=${PWD}/target \
cd ./twilight-relayerAPI && \
RUN eval `ssh-agent -s` && ssh-add /root/.ssh/id_ed25519 && \
git config --global url."ssh://git@github.com/".insteadOf https://github.com/ && \
git config --global url."ssh://git@github.com/".insteadOf ssh://github.com/ && \
git config --global url."ssh://git@github.com/twilight-project/zkos-relayer-wallet.git".insteadOf https://github.com/twilight-project/zkos-relayer-wallet.git && \
cargo --config "net.git-fetch-with-cli = true" b --release --bins

FROM debian:10-slim
Expand All @@ -23,7 +27,7 @@ COPY --from=builder ./twilight-relayerAPI/target/release/api ./
COPY --from=builder ./twilight-relayerAPI/target/release/archiver ./
COPY --from=builder ./twilight-relayerAPI/target/release/auth ./
COPY ./scripts/run.sh ./
COPY ./.compose.env .env
COPY ./.env ./.env


ENTRYPOINT ["/app/run.sh"]
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
For subscriptions and rpcs, see [here](./docs/API.md)

## install diesel_cli (Only necessary for development)

```command
sudo apt install libpq-dev
cargo install diesel_cli --no-default-features --features postgres
```

## running with docker-compose

Build the container, you will need an ssh-key with read-only access to the twilight-relayer repo for this:

```console
Expand All @@ -34,7 +36,12 @@ Check the .env file for the DATABASE_URL environment variable, be sure it's set

`cargo r --release --bin api`

## Run the auth server

`cargo r --release --bin auth`

## Testing

Tests are using uuid features that require additional compiler flags:

```command
Expand Down
16 changes: 16 additions & 0 deletions migrations/2024-03-26-213323_add_aggregation_tables/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- This file should undo anything in `up.sql`
-- DROP INDEX trader_order_time;
-- DROP INDEX price_time;
DROP INDEX trader_order_uuid;


DROP TABLE candles_1min;
DROP TABLE candles_1hour;
DROP TABLE candles_1day;

DROP FUNCTION get_ohlc_interval;
DROP FUNCTION get_volume_interval;
DROP FUNCTION get_candles_interval;
DROP FUNCTION update_candles_1min;
DROP FUNCTION update_candles_1hour;
DROP FUNCTION update_candles_1day;
Loading
Loading