From 9c0bf4b8eb3d222e788ca0862151492ae28f73ef Mon Sep 17 00:00:00 2001 From: Phu Pham Date: Wed, 13 Nov 2024 14:31:06 -0500 Subject: [PATCH 1/4] add OracleSet tx --- shared/requests/submit.yaml | 3 + shared/transactions/oracle_set.yaml | 95 +++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 shared/transactions/oracle_set.yaml diff --git a/shared/requests/submit.yaml b/shared/requests/submit.yaml index ecf4800..91b84d3 100644 --- a/shared/requests/submit.yaml +++ b/shared/requests/submit.yaml @@ -166,9 +166,11 @@ components: propertyName: TransactionType mapping: Payment: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1' + OracleSet: '../transactions/oracle_set.yaml#/components/schemas/OracleSet' # TODO: Add other transaction types here oneOf: - $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1' + - $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSet' # TODO: Add other transaction types here SubmitSuccessResponseV2: @@ -193,6 +195,7 @@ components: type: string oneOf: - $ref: '../base.yaml#/components/schemas/UniversalErrorResponseCodes' + - $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetErrorCode' - enum: - amendmentBlocked - highFee diff --git a/shared/transactions/oracle_set.yaml b/shared/transactions/oracle_set.yaml new file mode 100644 index 0000000..51a525d --- /dev/null +++ b/shared/transactions/oracle_set.yaml @@ -0,0 +1,95 @@ +components: + schemas: + OracleSet: + $id: OracleSet + type: object + required: + - Account + - OracleDocumentID + - LastUpdateTime + - PriceDataSeries + properties: + Account: + type: string + description: The account ID that must match the account in the Owner field of the Oracle object. + OracleDocumentID: + type: integer + description: A unique identifier of the price oracle for the Account. + Provider: + type: string + description: | + An arbitrary value identifying an oracle provider, such as Chainlink, Band, or DIA. + This field is a string, up to 256 ASCII hex-encoded characters (0x20-0x7E). + Required when creating a new Oracle ledger entry, but optional for updates. + maxLength: 256 + URI: + type: string + description: | + An optional Universal Resource Identifier (URI) to reference price data off-chain. + Limited to 256 bytes. + maxLength: 256 + LastUpdateTime: + type: integer + description: | + The timestamp indicating the last time the data was updated, + in seconds since the UNIX Epoch. + AssetClass: + type: string + description: | + Describes the type of asset, such as "currency", "commodity", or "index". + This field is a string, up to 16 ASCII hex-encoded characters (0x20-0x7E). + Required when creating a new Oracle ledger entry, but optional for updates. + maxLength: 16 + PriceDataSeries: + type: array + description: An array of up to 10 PriceData objects, each representing price information for a token pair. + maxItems: 10 + minItems: 1 + items: + $ref: '#/components/schemas/PriceData' + + PriceData: + $id: PriceData + type: object + required: + - BaseAsset + - QuoteAsset + properties: + BaseAsset: + type: string + description: | + The primary asset in a trading pair (e.g., BTC in BTC/USD). + Any valid identifier, such as a stock symbol, bond CUSIP, or currency code, is allowed. + QuoteAsset: + type: string + description: | + The quote asset in a trading pair, denoting the price of one unit of the base asset (e.g., USD in BTC/USD). + AssetPrice: + type: string + description: | + The asset price after applying the Scale precision level. + Recommended to be provided as a hexadecimal, but decimal numbers are accepted. + Not included if the last update transaction didn't include the BaseAsset/QuoteAsset pair. + Scale: + type: integer + description: | + The scaling factor to apply to an asset price. If Scale is 6 and the original price is 0.155, + then the scaled price is 155000. Valid scale ranges are 0-10. + Not included if the last update transaction didn't include the BaseAsset/QuoteAsset pair. + minimum: 0 + maximum: 10 + + OracleSetErrorCode: + $id: OracleSetErrorCode + enum: + - temARRAY_EMPTY + - tecARRAY_TOO_LARGE + - tecINVALID_UPDATE_TIME + - tecTOKEN_PAIR_NOT_FOUND + - temARRAY_TOO_LARGE + description: > + * `temARRAY_EMPTY` - The PriceDataSeries has no PriceData objects. + * `tecARRAY_TOO_LARGE` - The PriceDataSeries exceeds the ten PriceData objects limit. + * `tecINVALID_UPDATE_TIME` - The Oracle object has an invalid LastUpdateTime value. + * `tecTOKEN_PAIR_NOT_FOUND` - The token pair you're trying to delete doesn't exist in the Oracle object. + * `temARRAY_TOO_LARGE` - The PriceDataSeries exceeds the ten PriceData objects limit. From 42e3ae8793d6129fd64218cd846d8800d9547f53 Mon Sep 17 00:00:00 2001 From: Phu Pham Date: Thu, 14 Nov 2024 12:52:16 -0500 Subject: [PATCH 2/4] fix name --- shared/requests/submit.yaml | 4 ++-- shared/transactions/oracle_set.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/requests/submit.yaml b/shared/requests/submit.yaml index 91b84d3..c9d5e89 100644 --- a/shared/requests/submit.yaml +++ b/shared/requests/submit.yaml @@ -166,11 +166,11 @@ components: propertyName: TransactionType mapping: Payment: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1' - OracleSet: '../transactions/oracle_set.yaml#/components/schemas/OracleSet' + OracleSet: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction' # TODO: Add other transaction types here oneOf: - $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1' - - $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSet' + - $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction' # TODO: Add other transaction types here SubmitSuccessResponseV2: diff --git a/shared/transactions/oracle_set.yaml b/shared/transactions/oracle_set.yaml index 51a525d..62ed266 100644 --- a/shared/transactions/oracle_set.yaml +++ b/shared/transactions/oracle_set.yaml @@ -1,7 +1,7 @@ components: schemas: - OracleSet: - $id: OracleSet + OracleSetTransaction: + $id: OracleSetTransaction type: object required: - Account From 90288ffde1ed775aa9572e9b10e559987e0b75bf Mon Sep 17 00:00:00 2001 From: Phu Pham Date: Thu, 14 Nov 2024 14:25:50 -0500 Subject: [PATCH 3/4] add basetx inheritance --- shared/transactions/oracle_set.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared/transactions/oracle_set.yaml b/shared/transactions/oracle_set.yaml index 62ed266..1eefe0f 100644 --- a/shared/transactions/oracle_set.yaml +++ b/shared/transactions/oracle_set.yaml @@ -8,6 +8,8 @@ components: - OracleDocumentID - LastUpdateTime - PriceDataSeries + allOf: + - $ref: '../base.yaml#/components/schemas/BaseTransaction' properties: Account: type: string From cea7f45fc1a91de8dcd3f86d1ea83f708911585a Mon Sep 17 00:00:00 2001 From: Phu Pham Date: Thu, 14 Nov 2024 17:11:29 -0500 Subject: [PATCH 4/4] add custom rule price data --- shared/transactions/oracle_set.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/transactions/oracle_set.yaml b/shared/transactions/oracle_set.yaml index 1eefe0f..8513efe 100644 --- a/shared/transactions/oracle_set.yaml +++ b/shared/transactions/oracle_set.yaml @@ -80,6 +80,10 @@ components: Not included if the last update transaction didn't include the BaseAsset/QuoteAsset pair. minimum: 0 maximum: 10 + x-custom-validation: + mutualPresence: + - field1: AssetPrice + field2: Scale OracleSetErrorCode: $id: OracleSetErrorCode