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

Asset group #34

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Asset group #34

wants to merge 18 commits into from

Conversation

iboss-ptk
Copy link
Collaborator

@iboss-ptk iboss-ptk commented Sep 30, 2024

This PR introduce concept of scope for limiter and upcoming rebalancing incentive

scope can be either denom or asset_group which can practically represent source chain or bridge. This is what changed in registering limiter:

{
  "register_limiter": {
-  "denom": "token1",
+  "scope": "denom::token1",
    "label": "1h",
    "limiter_params": {
      "change_limiter": {
        "window_config": {
          "window_size": "3600000000000",
          "division_count": "5"
        },
        "boundary_offset": "0.2"
      }
    }
  }
}

scope can be prefixed with either denom:: or asset_group:: to differentiate the scope variant.

In order to specify an asset_group as scope, it creating new group is requried

{ 
  "create_asset_group": {
    "label": "group0",
    "denom": ["denom0", "denom1"]
  }
}

it can also be removed, and the associated limiters will we removed along with it

{ "remove_asset_group": { "label": "group0" } }

mark_corrupted_assets & unmark_corrupted_assets also changed to mark_corrupted_scopes & unmark_corrupted_scopes

The assets that are within the corrupted scopes will be removed from the pool when the amount reaches 0 as before. The reference to the specific asset that is corrupted and reaches 0 will also be removed from asset_group. Once asset group emptied, it is also automatically removed.

@@ -1343,7 +1343,7 @@ fn test_register_limiter_after_having_liquidity() {
t.contract
.execute(
&ExecMsg::RegisterLimiter {
denom: COSMOS_USDC.to_string(),
scope: Scope::Denom(COSMOS_USDC.to_string()),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test need replicated for a Group scope?

&self,
ExecCtx { deps, env: _, info }: ExecCtx,
label: String,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can this label be an empty string?


// ensure that all denoms are valid pool assets
for denom in &denoms {
ensure!(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a DOS vector here if I add an asset group with the same asset a ton of times? Might be worth enforcing uniqueness of elements

Copy link

@crnbarr93 crnbarr93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments otherwise LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants