Skip to content

Commit

Permalink
feat: flow expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x authored Sep 22, 2023
2 parents 8be0687 + 5972d45 commit 0dfcd12
Show file tree
Hide file tree
Showing 24 changed files with 3,551 additions and 471 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/liquidity_hub/pool-network/incentive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "incentive"
version = "1.0.3"
version = "1.0.6"
authors = ["kaimen-sano <[email protected]>"]
edition.workspace = true
description = "An incentive manager for an LP token"
Expand Down
252 changes: 233 additions & 19 deletions contracts/liquidity_hub/pool-network/incentive/schema/incentive.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,26 @@
"open_flow": {
"type": "object",
"required": [
"curve",
"end_epoch",
"flow_asset"
],
"properties": {
"curve": {
"description": "The type of distribution curve.",
"allOf": [
"description": "The type of distribution curve. If unspecified, the distribution will be linear.",
"anyOf": [
{
"$ref": "#/definitions/Curve"
},
{
"type": "null"
}
]
},
"end_epoch": {
"description": "The epoch at which the flow should end.",
"type": "integer",
"description": "The epoch at which the flow should end. If unspecified, the flow will default to end at 14 epochs from the current one.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
Expand All @@ -130,8 +134,15 @@
}
]
},
"flow_label": {
"description": "If set, the label will be used to identify the flow, in addition to the flow_id.",
"type": [
"string",
"null"
]
},
"start_epoch": {
"description": "The epoch at which the flow should start.\n\nIf unspecified, the flow will start at the current epoch.",
"description": "The epoch at which the flow will start. If unspecified, the flow will start at the current epoch.",
"type": [
"integer",
"null"
Expand All @@ -155,14 +166,16 @@
"close_flow": {
"type": "object",
"required": [
"flow_id"
"flow_identifier"
],
"properties": {
"flow_id": {
"description": "The id of the flow to close.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
"flow_identifier": {
"description": "The identifier of the flow to close.",
"allOf": [
{
"$ref": "#/definitions/FlowIdentifier"
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -304,6 +317,51 @@
}
},
"additionalProperties": false
},
{
"description": "Expands an existing flow.",
"type": "object",
"required": [
"expand_flow"
],
"properties": {
"expand_flow": {
"type": "object",
"required": [
"flow_asset",
"flow_identifier"
],
"properties": {
"end_epoch": {
"description": "The epoch at which the flow should end. If not set, the flow will be expanded a default value of 14 epochs.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"flow_asset": {
"description": "The asset to expand this flow with.",
"allOf": [
{
"$ref": "#/definitions/Asset"
}
]
},
"flow_identifier": {
"description": "The identifier of the flow to expand, whether an id or a label.",
"allOf": [
{
"$ref": "#/definitions/FlowIdentifier"
}
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
Expand Down Expand Up @@ -382,6 +440,36 @@
}
]
},
"FlowIdentifier": {
"oneOf": [
{
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"label"
],
"properties": {
"label": {
"type": "string"
}
},
"additionalProperties": false
}
]
},
"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"
Expand All @@ -407,7 +495,7 @@
"additionalProperties": false
},
{
"description": "Retrieves a specific flow.",
"description": "Retrieves a specific flow. If start_epoch and end_epoch are set, the asset_history and emitted_tokens will be filtered to only include epochs within the range. The maximum gap between the start_epoch and end_epoch is 100 epochs.",
"type": "object",
"required": [
"flow"
Expand All @@ -416,12 +504,32 @@
"flow": {
"type": "object",
"required": [
"flow_id"
"flow_identifier"
],
"properties": {
"flow_id": {
"end_epoch": {
"description": "If set, filters the asset_history and emitted_tokens to only include epochs until end_epoch.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"flow_identifier": {
"description": "The id of the flow to find.",
"type": "integer",
"allOf": [
{
"$ref": "#/definitions/FlowIdentifier"
}
]
},
"start_epoch": {
"description": "If set, filters the asset_history and emitted_tokens to only include epochs from start_epoch.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
}
Expand All @@ -432,14 +540,34 @@
"additionalProperties": false
},
{
"description": "Retrieves the current flows.",
"description": "Retrieves the current flows. If start_epoch and end_epoch are set, the asset_history and emitted_tokens will be filtered to only include epochs within the range. The maximum gap between the start_epoch and end_epoch is 100 epochs.",
"type": "object",
"required": [
"flows"
],
"properties": {
"flows": {
"type": "object",
"properties": {
"end_epoch": {
"description": "If set, filters the asset_history and emitted_tokens to only include epochs until end_epoch.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"start_epoch": {
"description": "If set, filters the asset_history and emitted_tokens to only include epochs from start_epoch.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
}
},
Expand Down Expand Up @@ -539,7 +667,39 @@
},
"additionalProperties": false
}
]
],
"definitions": {
"FlowIdentifier": {
"oneOf": [
{
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"label"
],
"properties": {
"label": {
"type": "string"
}
},
"additionalProperties": false
}
]
}
}
},
"migrate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down Expand Up @@ -788,6 +948,7 @@
"description": "Represents a flow.",
"type": "object",
"required": [
"asset_history",
"claimed_amount",
"curve",
"emitted_tokens",
Expand All @@ -798,6 +959,25 @@
"start_epoch"
],
"properties": {
"asset_history": {
"description": "A map containing the amount of tokens it was expanded to at a given epoch. This is used to calculate the right amount of tokens to distribute at a given epoch when a flow is expanded.",
"type": "object",
"additionalProperties": {
"type": "array",
"items": [
{
"$ref": "#/definitions/Uint128"
},
{
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
],
"maxItems": 2,
"minItems": 2
}
},
"claimed_amount": {
"description": "The amount of the `flow_asset` that has been claimed so far.",
"allOf": [
Expand Down Expand Up @@ -849,6 +1029,13 @@
"format": "uint64",
"minimum": 0.0
},
"flow_label": {
"description": "An alternative flow label.",
"type": [
"string",
"null"
]
},
"start_epoch": {
"description": "The epoch at which the flow starts.",
"type": "integer",
Expand Down Expand Up @@ -965,6 +1152,7 @@
"description": "Represents a flow.",
"type": "object",
"required": [
"asset_history",
"claimed_amount",
"curve",
"emitted_tokens",
Expand All @@ -975,6 +1163,25 @@
"start_epoch"
],
"properties": {
"asset_history": {
"description": "A map containing the amount of tokens it was expanded to at a given epoch. This is used to calculate the right amount of tokens to distribute at a given epoch when a flow is expanded.",
"type": "object",
"additionalProperties": {
"type": "array",
"items": [
{
"$ref": "#/definitions/Uint128"
},
{
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
],
"maxItems": 2,
"minItems": 2
}
},
"claimed_amount": {
"description": "The amount of the `flow_asset` that has been claimed so far.",
"allOf": [
Expand Down Expand Up @@ -1026,6 +1233,13 @@
"format": "uint64",
"minimum": 0.0
},
"flow_label": {
"description": "An alternative flow label.",
"type": [
"string",
"null"
]
},
"start_epoch": {
"description": "The epoch at which the flow starts.",
"type": "integer",
Expand Down
Loading

0 comments on commit 0dfcd12

Please sign in to comment.