From 6972bb7f688c8f32df6de6425799abdda5c6bf51 Mon Sep 17 00:00:00 2001 From: Alcibiades Athens Date: Sat, 9 Sep 2023 12:24:52 -0400 Subject: [PATCH 1/5] feat: spot price streaming endpoint --- proto/valorem/trade/v1/spot.proto | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 proto/valorem/trade/v1/spot.proto diff --git a/proto/valorem/trade/v1/spot.proto b/proto/valorem/trade/v1/spot.proto new file mode 100644 index 0000000..b238402 --- /dev/null +++ b/proto/valorem/trade/v1/spot.proto @@ -0,0 +1,58 @@ +syntax = "proto3"; + +// Import additional EVM data types types. +import "types.proto"; + +package valorem.trade.v1; + +// Spot service offers methods related to the spot prices of tokens +// on various Ethereum-related blockchains. +service Spot { + + // GetSpotPriceStream is a server-streaming RPC. It provides real-time spot prices + // for a list of tokens across multiple chains. + // + // Parameters: + // SpotPriceRequest: Contains information about which tokens' spot prices + // should be fetched on their respective chains. + // Returns: + // stream of SpotPriceResponse: Continuously streams data about the spot prices + // of the requested tokens on their respective chains + // as updates are available. + rpc GetSpotPriceStream (SpotPriceRequest) returns (stream SpotPriceResponse); +} + +// SpotPriceRequest encapsulates the details of the tokens for which +// spot prices are desired. +message SpotPriceRequest { + + // spot_price_info contains the details of each token (like its address and the + // chain it's on) for which the spot price should be fetched. + repeated SpotPriceInfo spot_price_info = 1; +} + +// SpotPriceResponse provides the fetched spot prices for the tokens specified in the request. +message SpotPriceResponse { + + // spot_price_info holds the data about the fetched spot prices for each of the + // tokens specified in the request. + repeated SpotPriceInfo spot_price_info = 1; +} + +// SpotPriceInfo represents the details and the spot price (if available) for a single token +// on a particular blockchain. +message SpotPriceInfo { + + // chain_id denotes the specific Ethereum-compatible blockchain on which the token is located. + uint64 chain_id = 1; + + // token_address is the Ethereum address of the token, usually in H160 format. + H160 token_address = 2; + + // spot_price, if available, is the current spot price of the token. + // It is represented in H256 format for high precision. + // This field is optional since the spot price might not always be available + // for every token, and because this message is reused in the request and + // response stream. + optional H256 spot_price = 3; +} \ No newline at end of file From e8efecb05c70b5d1406acac70066d9ff0d3cbb0e Mon Sep 17 00:00:00 2001 From: Alcibiades Athens Date: Sat, 9 Sep 2023 12:34:39 -0400 Subject: [PATCH 2/5] chore: make comments consistent --- proto/valorem/trade/v1/spot.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/valorem/trade/v1/spot.proto b/proto/valorem/trade/v1/spot.proto index b238402..14bf743 100644 --- a/proto/valorem/trade/v1/spot.proto +++ b/proto/valorem/trade/v1/spot.proto @@ -5,8 +5,8 @@ import "types.proto"; package valorem.trade.v1; -// Spot service offers methods related to the spot prices of tokens -// on various Ethereum-related blockchains. +// Spot service offers methods related to the spot tokens +// on various Ethereum-related chains. service Spot { // GetSpotPriceStream is a server-streaming RPC. It provides real-time spot prices @@ -43,7 +43,7 @@ message SpotPriceResponse { // on a particular blockchain. message SpotPriceInfo { - // chain_id denotes the specific Ethereum-compatible blockchain on which the token is located. + // chain_id denotes the specific chain on which the token is located. uint64 chain_id = 1; // token_address is the Ethereum address of the token, usually in H160 format. From 33e989c9ce93475623b50cd0f4bb0c64c1df8ade Mon Sep 17 00:00:00 2001 From: Alcibiades Athens Date: Sat, 9 Sep 2023 13:11:51 -0400 Subject: [PATCH 3/5] feat: stub erc20 spot price streaming service --- proto/valorem/trade/v1/spot.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/valorem/trade/v1/spot.proto b/proto/valorem/trade/v1/spot.proto index 14bf743..645839b 100644 --- a/proto/valorem/trade/v1/spot.proto +++ b/proto/valorem/trade/v1/spot.proto @@ -19,7 +19,7 @@ service Spot { // stream of SpotPriceResponse: Continuously streams data about the spot prices // of the requested tokens on their respective chains // as updates are available. - rpc GetSpotPriceStream (SpotPriceRequest) returns (stream SpotPriceResponse); + rpc GetSpotPrice (SpotPriceRequest) returns (stream SpotPriceResponse); } // SpotPriceRequest encapsulates the details of the tokens for which From 2dfb1bd568edea78aa9fa20facd78c8e97160948 Mon Sep 17 00:00:00 2001 From: Alcibiades Athens Date: Sat, 9 Sep 2023 15:13:15 -0400 Subject: [PATCH 4/5] fix: return spot price in USD --- proto/valorem/trade/v1/spot.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/valorem/trade/v1/spot.proto b/proto/valorem/trade/v1/spot.proto index 645839b..a0bf5ed 100644 --- a/proto/valorem/trade/v1/spot.proto +++ b/proto/valorem/trade/v1/spot.proto @@ -49,7 +49,7 @@ message SpotPriceInfo { // token_address is the Ethereum address of the token, usually in H160 format. H160 token_address = 2; - // spot_price, if available, is the current spot price of the token. + // spot_price, if available, is the current spot price in USD of the token. // It is represented in H256 format for high precision. // This field is optional since the spot price might not always be available // for every token, and because this message is reused in the request and From 485d3295abcddd993a4b8bda1e79a616a72c0ef9 Mon Sep 17 00:00:00 2001 From: Alcibiades Athens Date: Sat, 9 Sep 2023 21:25:01 -0400 Subject: [PATCH 5/5] fix: update proto --- proto/valorem/trade/v1/spot.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proto/valorem/trade/v1/spot.proto b/proto/valorem/trade/v1/spot.proto index a0bf5ed..f65df77 100644 --- a/proto/valorem/trade/v1/spot.proto +++ b/proto/valorem/trade/v1/spot.proto @@ -50,9 +50,9 @@ message SpotPriceInfo { H160 token_address = 2; // spot_price, if available, is the current spot price in USD of the token. - // It is represented in H256 format for high precision. - // This field is optional since the spot price might not always be available - // for every token, and because this message is reused in the request and - // response stream. + // It is represented in a 60x18 (42 integer digits, 18 decimals) H256 format + // for high precision. This field is optional since the spot price might not + // always be available for every token, and because this message is reused + // in the request and response stream. optional H256 spot_price = 3; } \ No newline at end of file