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

F/add stake grants #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

F/add stake grants #20

wants to merge 5 commits into from

Conversation

hanssun123
Copy link
Contributor

@hanssun123 hanssun123 commented Nov 5, 2024

Added documentation on stake grants and updated some snippets

Summary by CodeRabbit

  • New Features

    • Added a new section on "Stake Delegations/Grants" in the documentation, clarifying how staked INJ can be utilized for fee discounts.
    • Introduced new message types for managing stake grants and authorizations, enhancing user capabilities.
    • New event messages related to market and order management have been added, improving event handling.
  • Documentation

    • Updated several documents to improve clarity and consistency, including the addition of new sections and parameters.

Copy link

coderabbitai bot commented Nov 5, 2024

Walkthrough

The changes in this pull request involve updates to several documentation files and the .gitignore file. The .gitignore file now includes the .idea directory to prevent tracking of IDE-specific files. Documentation updates include the addition of new sections and types related to staking, fee discounts, and event messages within the exchange module. New message definitions and parameters have also been introduced, enhancing the clarity and functionality of the staking and trading processes.

Changes

File Path Change Summary
.gitignore Added .idea directory to ignore list.
docs/develop/modules/injective/exchange/02_other_concepts.md Added section on "Stake Delegations/Grants" explaining staked INJ requirements for fee discounts.
docs/develop/modules/injective/exchange/03_state.md Introduced new types: GrantAuthorization, ActiveGrant, and EffectiveGrant for managing fee discounts.
docs/develop/modules/injective/exchange/04_state_transitions.md Added sections for "Fee Discount Schedule Proposal," "Stake Grant Authorizations," and "Stake Grant Activation"; improved clarity and consistency.
docs/develop/modules/injective/exchange/05_messages.md Introduced new message types: MsgAuthorizeStakeGrants and MsgActivateStakeGrant; clarified MsgBatchUpdateOrders.
docs/develop/modules/injective/exchange/09_events.md Added new event messages and modified existing ones for consistency; expanded event handling capabilities.
docs/develop/modules/injective/exchange/10_params.md Added new parameter PostOnlyModeHeightThreshold and improved formatting of the parameters table.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Exchange
    participant Grantor
    participant Grantee

    User->>Exchange: Request Fee Discount
    Exchange->>Grantor: Authorize Stake Grants
    Grantor->>Exchange: Send Grant Authorization
    Exchange->>Grantee: Activate Stake Grant
    Grantee->>Exchange: Use Fee Discount
Loading

🐰 "In the fields where we play,
New grants and stakes come our way.
With discounts to cheer and rules to abide,
We hop along, with joy as our guide!
So let’s celebrate this change, oh so bright,
For every hop brings new delight!" 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (11)
docs/develop/modules/injective/exchange/02_other_concepts.md (1)

71-73: LGTM! Documentation clearly explains stake grants mechanics.

The new section provides accurate information about stake grants and their relationship to fee discount tiers.

Consider these improvements for better clarity:

  1. Add examples to illustrate the formula:
### Example
If Account A has:
- OwnStake: 1000 INJ
- Received grant from Account B: 500 INJ
- Granted to Account C: 200 INJ

Total stake for fee discount = 1000 + 500 - 200 = 1300 INJ
  1. Add a subsection about grant management:
### Managing Stake Grants
- To grant stake: Use `MsgAuthorizeStakeGrants`
- To activate a received grant: Use `MsgActivateStakeGrant`
- To revoke a grant: [Add revocation process]
  1. Highlight the validator limit more prominently:
### Important Note About Validators
The 25-validator limit is crucial for stake grants:
- Only INJ staked with ≤25 validators counts for `OwnStake`
- Exceeding this limit will reduce usable stake for grants
- Choose validators strategically to maximize grant potential
docs/develop/modules/injective/exchange/09_events.md (3)

56-67: Consider adding field validation and type consistency.

The new bankruptcy-related events look good, but could benefit from:

  1. Explicit field validation annotations for required fields
  2. Consistent type usage for market_id (string vs bytes) across events
  3. Decimal type annotations for price and fund fields
 message EventMarketBeyondBankruptcy {
-  string market_id = 1;
-  string settle_price = 2;
-  string missing_market_funds = 3;
+  string market_id = 1 [(gogoproto.nullable) = false];
+  string settle_price = 2 [
+    (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
+    (gogoproto.nullable) = false
+  ];
+  string missing_market_funds = 3 [
+    (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
+    (gogoproto.nullable) = false
+  ];
 }

137-138: Add field validation for deposit updates.

Consider adding validation annotations to ensure the repeated field is not empty.

-message EventBatchDepositUpdate { repeated DepositUpdate deposit_updates = 1; }
+message EventBatchDepositUpdate {
+  repeated DepositUpdate deposit_updates = 1 [(gogoproto.nullable) = false];
+}

188-240: Add field validations and documentation.

The new events are well-structured, but consider:

  1. Adding validation annotations for required fields
  2. Documenting the expected format/content of the description field in EventOrderCancelFail
  3. Adding size constraints for repeated fields where appropriate

Example improvements:

 message EventOrderCancelFail {
-  string market_id = 1;
-  string subaccount_id = 2;
-  string order_hash = 3;
+  string market_id = 1 [(gogoproto.nullable) = false];
+  string subaccount_id = 2 [(gogoproto.nullable) = false];
+  string order_hash = 3 [(gogoproto.nullable) = false];
   string cid = 4;
+  // Human-readable description of why the order cancellation failed
   string description = 5;
 }
docs/develop/modules/injective/exchange/05_messages.md (2)

447-448: Enhance documentation with examples

The documentation would benefit from including examples showing:

  1. How to grant stake authorization
  2. How to revoke a grant by setting amount to zero

Example:

// Example: Granting stake authorization
{
    "sender": "inj1...",
    "grants": [{
        "grantee": "inj1...",
        "amount": "1000000000000000000" // 1 INJ
    }]
}

// Example: Revoking stake authorization
{
    "sender": "inj1...",
    "grants": [{
        "grantee": "inj1...",
        "amount": "0"
    }]
}

Also applies to: 458-460


465-466: Enhance documentation with context and examples

The documentation should explain:

  1. When to use this message (e.g., after receiving a grant)
  2. The relationship between granter and sender
  3. The impact of activating a grant

Example:

// Example: Activating a stake grant
{
    "sender": "inj1...",  // The grantee who received the stake grant
    "granter": "inj1..."  // The address that authorized the stake grant
}

Additionally, consider adding a note about whether:

  • Multiple grants can be active simultaneously
  • An existing active grant needs to be deactivated first
  • There are any restrictions on activation/deactivation frequency

Also applies to: 476-477

docs/develop/modules/injective/exchange/03_state.md (3)

596-606: Consider enhancing documentation with an example.

The GrantAuthorization type is well-defined, but adding a usage example would make it more developer-friendly.

Consider adding an example like:

// Example:
// grantAuthorization := GrantAuthorization{
//   Grantee: "inj1...",  // Grantee's address
//   Amount: math.NewInt(1000000),  // 1 INJ (assuming 6 decimals)
// }

608-618: Clarify relationship with GrantAuthorization.

The ActiveGrant type is well-defined, but its documentation could better explain how it relates to GrantAuthorization in the stake grant lifecycle.

Consider adding clarification like:

`ActiveGrant` represents the portion of a `GrantAuthorization` that has been activated by the grantee. While `GrantAuthorization` tracks the authorized amount, `ActiveGrant` tracks how much of that authorization has been activated for use in fee discounts.

620-631: Document IsValid field and type relationships.

The EffectiveGrant type needs additional documentation to explain:

  1. The purpose of the IsValid field
  2. How NetGrantedStake relates to the amounts in GrantAuthorization and ActiveGrant

Consider adding:

The `IsValid` field indicates whether the grant is currently valid and can be used for fee discounts. `NetGrantedStake` represents the total stake amount authorized by the granter across all active grant authorizations, calculated as the sum of all `GrantAuthorization` amounts minus the sum of all `ActiveGrant` amounts for the same granter.
docs/develop/modules/injective/exchange/04_state_transitions.md (2)

450-460: Enhance documentation for Stake Grant Authorizations

While the steps are logically structured, the section could benefit from:

  1. An introductory paragraph explaining what stake grant authorizations are
  2. More detailed explanations for each step
  3. Examples of grant calculations

Consider adding an introduction like:

 ## Stake Grant Authorizations
+
+Stake grant authorizations allow a staker (granter) to authorize another address (grantee) 
+to utilize their staked tokens for fee discount purposes. This enables delegation of 
+staking benefits without transferring token ownership.
+
 **Steps**
🧰 Tools
🪛 Markdownlint

452-452: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


Line range hint 1-469: Consider adding cross-references between related sections

The document would benefit from cross-references between related sections, particularly:

  1. Link between Fee Discount Schedule Proposal and Stake Grant sections
  2. References to related message types and events

Consider adding "See also" sections at the end of related segments to improve navigation and understanding of the relationships between different components.

🧰 Tools
🪛 Markdownlint

452-452: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


464-464: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8e89397 and 00873d2.

📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • docs/develop/modules/injective/exchange/02_other_concepts.md (1 hunks)
  • docs/develop/modules/injective/exchange/03_state.md (1 hunks)
  • docs/develop/modules/injective/exchange/04_state_transitions.md (23 hunks)
  • docs/develop/modules/injective/exchange/05_messages.md (1 hunks)
  • docs/develop/modules/injective/exchange/09_events.md (4 hunks)
  • docs/develop/modules/injective/exchange/10_params.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🧰 Additional context used
🪛 Markdownlint
docs/develop/modules/injective/exchange/04_state_transitions.md

127-127: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


165-165: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


196-196: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


245-245: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


452-452: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


464-464: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/develop/modules/injective/exchange/05_messages.md

451-451: Column: 1
Hard tabs

(MD010, no-hard-tabs)


452-452: Column: 1
Hard tabs

(MD010, no-hard-tabs)


469-469: Column: 1
Hard tabs

(MD010, no-hard-tabs)


470-470: Column: 1
Hard tabs

(MD010, no-hard-tabs)


456-456: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


474-474: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (4)
docs/develop/modules/injective/exchange/10_params.md (1)

10-11: LGTM: Table formatting improvements

The table formatting changes improve readability with consistent column alignment.

docs/develop/modules/injective/exchange/09_events.md (2)

Line range hint 69-134: LGTM! Field annotation updates improve type safety.

The consistent addition of (gogoproto.nullable) = false annotations across messages improves type safety and makes the contract more explicit.


139-152: LGTM! Well-structured derivative order cancellation messages.

The messages are properly structured with appropriate annotations for decimal types and nullable fields.

docs/develop/modules/injective/exchange/04_state_transitions.md (1)

37-39: LGTM: Table of contents updated correctly

The new sections have been properly added to the table of contents, maintaining consistency with the document structure.

| BinaryOptionsAtomicMarketOrderFeeMultiplier | math.LegacyDec | 2x |
| MinimalProtocolFeeRate | math.LegacyDec | 0.00001% |
| IsInstantDerivativeMarketLaunchEnabled | bool | false |
| PostOnlyModeHeightThreshold | int64 | 1000 |
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the investigation so far:

  1. The parameter was recently added in a commit by Hans Sun specifically to add it to the params documentation
  2. We couldn't find any actual implementation in the Go code
  3. The parameter appears only in the documentation file without any context or explanation
  4. There's no evidence linking this to stake grants

The PostOnlyModeHeightThreshold parameter addition requires clarification

This parameter appears to be added in isolation without proper implementation or documentation. It was added in a recent commit but:

  • No implementation found in the codebase
  • No explanation of its purpose or usage
  • No connection to stake grants functionality
  • Only appears in the parameters documentation

Please provide the implementation details and proper documentation for this parameter, or remove it if it was added unintentionally.

🔗 Analysis chain

Please verify the addition of PostOnlyModeHeightThreshold parameter

The new parameter PostOnlyModeHeightThreshold appears to be unrelated to the PR's primary objective of enhancing stake grants documentation. Could you please:

  1. Confirm if this parameter addition is intentional
  2. Provide documentation about its purpose and usage
  3. Explain how it relates to stake grants, if applicable

Let's check if this parameter is documented elsewhere:


Let me search for more context about this parameter in the codebase:


Let me check the git history to understand when and why this parameter was added:


Let me check the actual code implementation to understand this parameter better:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any documentation or references to PostOnlyModeHeightThreshold
rg -i "PostOnlyModeHeightThreshold" --type md

Length of output: 183


Script:

#!/bin/bash
# Search for PostOnlyModeHeightThreshold in all files to understand its implementation and purpose
rg -i "PostOnlyModeHeightThreshold" -A 3 -B 3

Length of output: 597


Script:

#!/bin/bash
# Check git history for this parameter
git log -p | grep -A 10 -B 10 "PostOnlyModeHeightThreshold"

# Also check if there are any related code changes in the PR
git diff origin/master | grep -A 10 -B 10 "PostOnlyModeHeightThreshold"

Length of output: 3797


Script:

#!/bin/bash
# Search for the parameter in Go files to find its implementation
rg -t go "PostOnlyModeHeightThreshold" -A 5 -B 5

Length of output: 197

Comment on lines +166 to +187
message EventNewConditionalDerivativeOrder {
string market_id = 1;
DerivativeOrder order = 2;
bytes hash = 3;
bool is_market = 4;
}

message EventCancelConditionalDerivativeOrder {
string market_id = 1;
bool isLimitCancel = 2;
DerivativeLimitOrder limit_order = 3 [ (gogoproto.nullable) = true ];
DerivativeMarketOrder market_order = 4 [ (gogoproto.nullable) = true ];
}

message EventConditionalDerivativeOrderTrigger {
bytes market_id = 1;
bool isLimitTrigger = 2;
bytes triggered_order_hash = 3;
bytes placed_order_hash = 4;
string triggered_order_cid = 5;
}

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Standardize type usage across conditional order events.

There are inconsistencies in type usage:

  • market_id is string in EventNewConditionalDerivativeOrder but bytes in EventConditionalDerivativeOrderTrigger
  • Missing field validations for required fields

Consider standardizing the types and adding validations:

 message EventConditionalDerivativeOrderTrigger {
-  bytes market_id = 1;
+  string market_id = 1 [(gogoproto.nullable) = false];
   bool isLimitTrigger = 2;
-  bytes triggered_order_hash = 3;
-  bytes placed_order_hash = 4;
+  bytes triggered_order_hash = 3 [(gogoproto.nullable) = false];
+  bytes placed_order_hash = 4 [(gogoproto.nullable) = false];
   string triggered_order_cid = 5;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
message EventNewConditionalDerivativeOrder {
string market_id = 1;
DerivativeOrder order = 2;
bytes hash = 3;
bool is_market = 4;
}
message EventCancelConditionalDerivativeOrder {
string market_id = 1;
bool isLimitCancel = 2;
DerivativeLimitOrder limit_order = 3 [ (gogoproto.nullable) = true ];
DerivativeMarketOrder market_order = 4 [ (gogoproto.nullable) = true ];
}
message EventConditionalDerivativeOrderTrigger {
bytes market_id = 1;
bool isLimitTrigger = 2;
bytes triggered_order_hash = 3;
bytes placed_order_hash = 4;
string triggered_order_cid = 5;
}
message EventNewConditionalDerivativeOrder {
string market_id = 1;
DerivativeOrder order = 2;
bytes hash = 3;
bool is_market = 4;
}
message EventCancelConditionalDerivativeOrder {
string market_id = 1;
bool isLimitCancel = 2;
DerivativeLimitOrder limit_order = 3 [ (gogoproto.nullable) = true ];
DerivativeMarketOrder market_order = 4 [ (gogoproto.nullable) = true ];
}
message EventConditionalDerivativeOrderTrigger {
string market_id = 1 [(gogoproto.nullable) = false];
bool isLimitTrigger = 2;
bytes triggered_order_hash = 3 [(gogoproto.nullable) = false];
bytes placed_order_hash = 4 [(gogoproto.nullable) = false];
string triggered_order_cid = 5;
}

Comment on lines +468 to +472
type MsgAuthorizeStakeGrants struct {
Sender string
Granter string
}
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect struct name and formatting

The struct name is incorrect and should be MsgActivateStakeGrant instead of MsgAuthorizeStakeGrants.

-type MsgAuthorizeStakeGrants struct {
-	Sender  string 
-	Granter string 
+type MsgActivateStakeGrant struct {
+    Sender  string
+    Granter string
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
type MsgAuthorizeStakeGrants struct {
Sender string
Granter string
}
```
type MsgActivateStakeGrant struct {
Sender string
Granter string
}
🧰 Tools
🪛 Markdownlint

469-469: Column: 1
Hard tabs

(MD010, no-hard-tabs)


470-470: Column: 1
Hard tabs

(MD010, no-hard-tabs)

Comment on lines +449 to +454
```go
type MsgAuthorizeStakeGrants struct {
Sender string
Grants []*GrantAuthorization
}
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix struct name inconsistency and add type definition

The struct name in the code block should be MsgAuthorizeStakeGrants to match the section title. Also, the GrantAuthorization type definition is missing, which is crucial for understanding the Grants field.

 type MsgAuthorizeStakeGrants struct {
-	Sender  string 
-	Grants  []*GrantAuthorization 
+    Sender string
+    Grants []*GrantAuthorization
 }

+// GrantAuthorization defines the grant authorization structure
+type GrantAuthorization struct {
+    Grantee string
+    Amount  math.Int
+}

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Markdownlint

451-451: Column: 1
Hard tabs

(MD010, no-hard-tabs)


452-452: Column: 1
Hard tabs

(MD010, no-hard-tabs)

@@ -445,3 +446,24 @@ Derivative market param update is handled by `DerivativeMarketParamUpdateProposa
- Set the first fee paid bucket timestamp as the current block time
- Set New Fee Discount Schedule, delete it along with Market Qualifications
- Set New Market Qualifications

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing steps for Fee Discount Schedule Proposal

The section "Fee Discount Schedule Proposal" appears incomplete. While the heading is added, the steps are missing from the section content.

Would you like me to help draft the missing steps for the Fee Discount Schedule Proposal section? The steps should align with the existing format and detail the process of proposing and implementing fee discount schedules.

Comment on lines +462 to +469
## Stake Grant Activation

**Steps**

- Check to make sure grant from granter to grantee exists
- Check to make sure granter is not granting more than their total staked amount
- If grant amount is 0, delete the grant, otherwise write new grant amount to store
- Emit `EventGrantActivation` with grantee, granter, and amount
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve clarity of Stake Grant Activation section

The section needs more context about when and why stake grants are activated. Additionally, some steps need clarification:

  1. Step about checking grant existence should specify where to check
  2. The grant amount validation step needs more detail
  3. The deletion condition should be explained

Consider enhancing the section like this:

 ## Stake Grant Activation
+
+Stake grant activation is the process of enabling a previously authorized grant. 
+Only one grant can be active at a time for a grantee.
 
 **Steps**
 
-Check to make sure grant from granter to grantee exists
+- Verify the grant exists in the GrantAuthorization store for the granter-grantee pair
-Check to make sure granter is not granting more than their total staked amount
+- Validate that the granter's total granted amount (including this grant) does not exceed their total staked tokens
-If grant amount is 0, delete the grant, otherwise write new grant amount to store
+- If the grant amount is 0:
+  - Delete the grant from the GrantAuthorization store
+  - Clean up any associated metadata
+- Otherwise:
+  - Update the grant amount in the store
+  - Update the active grant status
 - Emit `EventGrantActivation` with grantee, granter, and amount
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Stake Grant Activation
**Steps**
- Check to make sure grant from granter to grantee exists
- Check to make sure granter is not granting more than their total staked amount
- If grant amount is 0, delete the grant, otherwise write new grant amount to store
- Emit `EventGrantActivation` with grantee, granter, and amount
## Stake Grant Activation
Stake grant activation is the process of enabling a previously authorized grant.
Only one grant can be active at a time for a grantee.
**Steps**
- Verify the grant exists in the GrantAuthorization store for the granter-grantee pair
- Validate that the granter's total granted amount (including this grant) does not exceed their total staked tokens
- If the grant amount is 0:
- Delete the grant from the GrantAuthorization store
- Clean up any associated metadata
- Otherwise:
- Update the grant amount in the store
- Update the active grant status
- Emit `EventGrantActivation` with grantee, granter, and amount
🧰 Tools
🪛 Markdownlint

464-464: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

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.

1 participant