Skip to content

Commit

Permalink
refactor: update types, change weight calculation from timestamp to e…
Browse files Browse the repository at this point in the history
…poch based
  • Loading branch information
kerber0x committed May 9, 2024
1 parent 70f8303 commit efb05a4
Show file tree
Hide file tree
Showing 17 changed files with 274 additions and 417 deletions.
230 changes: 73 additions & 157 deletions contracts/liquidity_hub/bonding-manager/schema/bonding-manager.json

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions contracts/liquidity_hub/bonding-manager/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@
},
"unbonding_period": {
"description": "The unbonding period.",
"anyOf": [
{
"$ref": "#/definitions/Uint64"
},
{
"type": "null"
}
]
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
"type": "string"
},
"grace_period": {
"description": "Grace period the maximum age of a bucket before fees are forwarded from it",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
"description": "Grace period the maximum age of a epoch bucket before it's considered expired and fees are forwarded from it",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"growth_rate": {
"description": "Weight grow rate. Needs to be between 0 and 1.",
Expand All @@ -43,23 +41,17 @@
]
},
"unbonding_period": {
"description": "Unbonding period in nanoseconds. The time that needs to pass before an unbonded position can be withdrawn",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
"description": "Unbonding period in epochs. The time (in epochs) that needs to pass before an unbonded position can be withdrawn",
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false,
"definitions": {
"Decimal": {
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"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"
}
}
}
46 changes: 15 additions & 31 deletions contracts/liquidity_hub/bonding-manager/schema/raw/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@
"description": "The address to check for weight.",
"type": "string"
},
"epoch_id": {
"description": "The timestamp to check for weight. If none is provided, the current block time is used.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"global_index": {
"description": "The global index to check for weight. If none is provided, the current global index is used.",
"anyOf": [
Expand All @@ -133,17 +142,6 @@
"type": "null"
}
]
},
"timestamp": {
"description": "The timestamp to check for weight. If none is provided, the current block time is used.",
"anyOf": [
{
"$ref": "#/definitions/Timestamp"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -217,7 +215,7 @@
"required": [
"bonded_amount",
"bonded_assets",
"timestamp",
"last_updated",
"weight"
],
"properties": {
Expand All @@ -236,13 +234,11 @@
"$ref": "#/definitions/Coin"
}
},
"timestamp": {
"description": "The timestamp at which the total bond was registered.",
"allOf": [
{
"$ref": "#/definitions/Timestamp"
}
]
"last_updated": {
"description": "The epoch id at which the total bond was updated.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"weight": {
"description": "The total weight of the bond at the given block height.",
Expand All @@ -255,21 +251,9 @@
},
"additionalProperties": false
},
"Timestamp": {
"description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 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 `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
},
"first_bonded_epoch_id": {
"description": "If Some, the epoch id at which the user/address bonded first time. None is used when this Response is used to check the bonded assets in the contract.",
"anyOf": [
{
"$ref": "#/definitions/Uint64"
},
{
"type": "null"
}
]
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"total_bonded": {
"description": "The total amount of bonded tokens by the address. Bear in mind the bonded assets are considered to be equal for this purpose.",
Expand Down Expand Up @@ -55,10 +53,6 @@
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 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 `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
"$ref": "#/definitions/GlobalIndex"
},
"id": {
"$ref": "#/definitions/Uint64"
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"start_time": {
"$ref": "#/definitions/Timestamp"
Expand All @@ -77,7 +79,7 @@
"required": [
"bonded_amount",
"bonded_assets",
"timestamp",
"last_updated",
"weight"
],
"properties": {
Expand All @@ -96,13 +98,11 @@
"$ref": "#/definitions/Coin"
}
},
"timestamp": {
"description": "The timestamp at which the total bond was registered.",
"allOf": [
{
"$ref": "#/definitions/Timestamp"
}
]
"last_updated": {
"description": "The epoch id at which the total bond was updated.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"weight": {
"description": "The total weight of the bond at the given block height.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
]
},
"grace_period": {
"description": "The duration of the grace period in epochs, i.e. how many expired epochs can be claimed",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
"description": "Grace period the maximum age of a epoch bucket before it's considered expired and fees are forwarded from it",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"growth_rate": {
"description": "A fraction that controls the effect of time on the weight of a bond. If the growth rate is set to zero, time will have no impact on the weight.",
Expand All @@ -57,11 +55,9 @@
},
"unbonding_period": {
"description": "Unbonding period in nanoseconds. The time that needs to pass before an unbonded position can be withdrawn",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false,
Expand All @@ -73,10 +69,6 @@
"Decimal": {
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"required": [
"bonded_amount",
"bonded_assets",
"timestamp",
"last_updated",
"weight"
],
"properties": {
Expand All @@ -24,13 +24,11 @@
"$ref": "#/definitions/Coin"
}
},
"timestamp": {
"description": "The timestamp at which the total bond was registered.",
"allOf": [
{
"$ref": "#/definitions/Timestamp"
}
]
"last_updated": {
"description": "The epoch id at which the total bond was updated.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"weight": {
"description": "The total weight of the bond at the given block height.",
Expand Down Expand Up @@ -58,21 +56,9 @@
}
}
},
"Timestamp": {
"description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 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 `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"required": [
"asset",
"created_at_epoch",
"timestamp",
"updated_last",
"weight"
],
"properties": {
Expand All @@ -45,19 +45,15 @@
},
"created_at_epoch": {
"description": "The epoch id at which the Bond was created.",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"timestamp": {
"description": "The timestamp at which the bond was done.",
"allOf": [
{
"$ref": "#/definitions/Timestamp"
}
]
"updated_last": {
"description": "The epoch id at which the bond was last time updated.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"weight": {
"description": "The weight of the bond at the given block height.",
Expand Down Expand Up @@ -85,21 +81,9 @@
}
}
},
"Timestamp": {
"description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```",
"allOf": [
{
"$ref": "#/definitions/Uint64"
}
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 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 `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"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"
}
}
}
Loading

0 comments on commit efb05a4

Please sign in to comment.