Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use uint256 instead of uint64 for all rates #216

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions cosmwasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ pub struct ReferenceData {
// Pair rate e.g. rate of BTC/USD
pub rate: Uint256,
// Unix time of when the base asset was last updated. e.g. Last update time of BTC in Unix time
pub last_updated_base: Uint64,
pub last_updated_base: Uint256,
// Unix time of when the quote asset was last updated. e.g. Last update time of USD in Unix time
pub last_updated_quote: Uint64,
pub last_updated_quote: Uint256,
}
```

Expand Down Expand Up @@ -194,11 +194,11 @@ bulk variant returns `Vec<RefDeviationData>`
```rust
pub struct RefDeviationData {
// Deviation Rates of an asset relative to USD
pub rates: Vec<Uint64>,
pub rates: Vec<Uint256>,
// The resolve time of the request ID
pub resolve_time: Uint64,
pub resolve_time: Uint256,
// The request ID where the rate was derived from
pub request_id: Uint64,
pub request_id: Uint256,
}
```

Expand Down
209 changes: 207 additions & 2 deletions cosmwasm/contracts/price-feed/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"median_status"
],
"properties": {
"median_status": {
"type": "object",
"required": [
"status"
],
"properties": {
"status": {
"type": "boolean"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -100,7 +121,97 @@
"type": "string"
},
{
"$ref": "#/definitions/Uint64"
"$ref": "#/definitions/Uint256"
}
],
"maxItems": 2,
"minItems": 2
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"relay_historical_median"
],
"properties": {
"relay_historical_median": {
"type": "object",
"required": [
"request_id",
"resolve_time",
"symbol_rates"
],
"properties": {
"request_id": {
"$ref": "#/definitions/Uint64"
},
"resolve_time": {
"$ref": "#/definitions/Uint64"
},
"symbol_rates": {
"type": "array",
"items": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/Uint256"
}
}
],
"maxItems": 2,
"minItems": 2
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"relay_historical_deviation"
],
"properties": {
"relay_historical_deviation": {
"type": "object",
"required": [
"request_id",
"resolve_time",
"symbol_rates"
],
"properties": {
"request_id": {
"$ref": "#/definitions/Uint64"
},
"resolve_time": {
"$ref": "#/definitions/Uint64"
},
"symbol_rates": {
"type": "array",
"items": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/Uint256"
}
}
],
"maxItems": 2,
Expand Down Expand Up @@ -142,7 +253,97 @@
"type": "string"
},
{
"$ref": "#/definitions/Uint64"
"$ref": "#/definitions/Uint256"
}
],
"maxItems": 2,
"minItems": 2
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"force_relay_historical_median"
],
"properties": {
"force_relay_historical_median": {
"type": "object",
"required": [
"request_id",
"resolve_time",
"symbol_rates"
],
"properties": {
"request_id": {
"$ref": "#/definitions/Uint64"
},
"resolve_time": {
"$ref": "#/definitions/Uint64"
},
"symbol_rates": {
"type": "array",
"items": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/Uint256"
}
}
],
"maxItems": 2,
"minItems": 2
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"force_relay_historical_deviation"
],
"properties": {
"force_relay_historical_deviation": {
"type": "object",
"required": [
"request_id",
"resolve_time",
"symbol_rates"
],
"properties": {
"request_id": {
"$ref": "#/definitions/Uint64"
},
"resolve_time": {
"$ref": "#/definitions/Uint64"
},
"symbol_rates": {
"type": "array",
"items": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/Uint256"
}
}
],
"maxItems": 2,
Expand All @@ -157,6 +358,10 @@
}
],
"definitions": {
"Uint256": {
"description": "An implementation of u256 that is using strings for JSON encoding/decoding, such that the full u256 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances out of primitive uint types or `new` to provide big endian bytes:\n\n``` # use cosmwasm_std::Uint256; let a = Uint256::from(258u128); let b = Uint256::new([ 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, ]); assert_eq!(a, b); ```",
"type": "string"
},
"Uint64": {
"description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```",
"type": "string"
Expand Down
103 changes: 103 additions & 0 deletions cosmwasm/contracts/price-feed/schema/query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"median_status"
],
"properties": {
"median_status": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -121,6 +134,96 @@
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"get_median_ref"
],
"properties": {
"get_median_ref": {
"type": "object",
"required": [
"symbol"
],
"properties": {
"symbol": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"get_median_ref_data_bulk"
],
"properties": {
"get_median_ref_data_bulk": {
"type": "object",
"required": [
"symbols"
],
"properties": {
"symbols": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"get_deviation_ref"
],
"properties": {
"get_deviation_ref": {
"type": "object",
"required": [
"symbol"
],
"properties": {
"symbol": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"get_deviation_ref_bulk"
],
"properties": {
"get_deviation_ref_bulk": {
"type": "object",
"required": [
"symbols"
],
"properties": {
"symbols": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
Loading
Loading