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

Update DefaultFundingPpm for PML markets #2610

Merged
merged 4 commits into from
Nov 27, 2024
Merged

Update DefaultFundingPpm for PML markets #2610

merged 4 commits into from
Nov 27, 2024

Conversation

teddyding
Copy link
Contributor

@teddyding teddyding commented Nov 25, 2024

Changelist

Also updated DefaultFundingPpm for testnets

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Updated funding parameters for various perpetual markets, enhancing potential returns.
    • Configured liquidity tiers and market parameters for TEST-USD to improve trading conditions.
    • Updated default_funding_ppm for multiple markets from 0 to 100, impacting operational dynamics.
  • Bug Fixes

    • Adjusted the DefaultFundingPpm constant to reflect accurate funding rates, ensuring clarity for users.

Copy link
Contributor

coderabbitai bot commented Nov 25, 2024

Walkthrough

The changes in this pull request primarily involve modifications to the genesis.sh script, the constants.go file, and the sample_pregenesis.json configuration. The genesis.sh script updates the funding parameters for various perpetual markets, setting the default_funding_ppm from 0 to 100 for multiple currencies, adjusts market parameters, initializes bank balances, and configures interchain accounts. The constants.go file reflects a similar change by updating the DefaultFundingPpm constant to 100, and the sample_pregenesis.json file also updates the funding parameters for several markets.

Changes

File Path Change Summary
protocol/testing/genesis.sh Updated default_funding_ppm from 0 to 100 for multiple markets; modified market parameters for TEST-USD; initialized bank balances and updated interchain accounts.
protocol/x/listing/types/constants.go Changed DefaultFundingPpm from 0 to 100 with an added comment explaining its meaning.
protocol/scripts/genesis/sample_pregenesis.json Updated app_version and changed default_funding_ppm from 0 to 100 for multiple perpetual markets.

Possibly related PRs

Suggested labels

indexer

Suggested reviewers

  • vincentwschau
  • roy-dydx
  • chenyaoy

🐇 In the land of code where the markets play,
Funding parameters change in a grand ballet.
From zero to hundred, they leap with glee,
In genesis scripts, they dance so free.
With constants updated, all set to go,
Hop along, dear coder, let the blockchain flow! 🌟


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.

@teddyding teddyding marked this pull request as ready for review November 25, 2024 20:44
@teddyding teddyding requested a review from a team as a code owner November 25, 2024 20:44
Copy link
Contributor

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 744a58b and 2b9a6b6.

📒 Files selected for processing (2)
  • protocol/testing/genesis.sh (34 hunks)
  • protocol/x/listing/types/constants.go (1 hunks)
🔇 Additional comments (2)
protocol/x/listing/types/constants.go (1)

6-6: LGTM - Funding rate calculation is correct

The new value of 100 PPM (0.01%) per 8 hours equals 0.125 basis points per hour, which is correctly documented in the comment. This introduces a reasonable baseline funding rate for PML markets.

protocol/testing/genesis.sh (1)

221-221: Confirmation of 'default_funding_ppm' updates to '100' for all perpetual markets

The default_funding_ppm parameter has been updated to 100 across all perpetual markets, including the TEST-USD market. This change aligns with the PR objective to modify this parameter for PML markets and ensures consistency throughout the genesis configuration.

Also applies to: 231-231, 241-241, 251-251, 261-261, 271-271, 281-281, 291-291, 301-301, 311-311, 321-321, 331-331, 341-341, 351-351, 361-361, 371-371, 381-381, 391-391, 401-401, 411-411, 421-421, 431-431, 441-441, 451-451, 461-461, 471-471, 481-481, 491-491, 501-501, 511-511, 521-521, 531-531, 541-541, 2273-2273

@@ -3,7 +3,7 @@ package types
const (
MinPriceChangePpm_LongTail uint32 = 800

DefaultFundingPpm = 0
DefaultFundingPpm = 100 // 1bps per 8 hour or 0.125bps per hour
Copy link
Contributor

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 search results, I can now generate the final response:

Funding rate change requires upgrade handler for state migration

The change from 0 to 100 PPM for DefaultFundingPpm is indeed a state-breaking change that requires careful handling during upgrades. This is evidenced by:

  • All existing markets in genesis files (mainnet, testnet, preupgrade) have default_funding_ppm set to 0
  • The change affects all perpetual markets in the protocol
  • The genesis scripts and testing configurations consistently use 0 as the default value
🔗 Analysis chain

Verify state-breaking implications of funding rate change

The change from 0 to 100 PPM introduces funding payments where there were none before. This could be a state-breaking change that requires special handling during upgrades.

Consider documenting the upgrade process and any necessary state migrations in the PR description.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for upgrade handlers or migration logic related to funding parameters
rg -A 5 "UpgradeHandler|MigrateState.*funding" 

# Look for any existing markets that might be affected
rg -A 5 "default_funding_ppm"

Length of output: 92398

Copy link
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (1)
protocol/scripts/genesis/sample_pregenesis.json (1)

Line range hint 3034-3386: Review the uniform funding rate across different market tiers

The change sets default_funding_ppm to 100 for all perpetual markets, regardless of their liquidity tier. Consider if this uniform approach is appropriate given the different risk profiles:

  • Tier 0 (Large-Cap): BTC-USD, ETH-USD
  • Tier 1 (Small-Cap): Most altcoins
  • Tier 2 (Long-Tail): MKR-USD, COMP-USD, APE-USD, BLUR-USD, LDO-USD, SEI-USD

Consider if the funding rate should be tiered based on:

  1. Market liquidity
  2. Historical volatility
  3. Risk profile of the asset
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2b9a6b6 and 51b3966.

📒 Files selected for processing (1)
  • protocol/scripts/genesis/sample_pregenesis.json (34 hunks)
🔇 Additional comments (2)
protocol/scripts/genesis/sample_pregenesis.json (2)

Line range hint 3034-3919: Market parameters are well-configured for different asset characteristics

The configuration shows appropriate customization for each market:

  • Atomic resolution matches asset precision requirements (e.g., -16 for PEPE, -5 for BTC)
  • Price change minimums are calibrated to asset volatility
  • Liquidity tiers properly segment assets by market cap and risk

3919-3919: Verify the implications of major version upgrade

The app version has been updated from 5.2.1 to 7.0.0-dev0, which is a major version bump. This could indicate breaking changes.

@teddyding teddyding merged commit 3566800 into main Nov 27, 2024
22 checks passed
@teddyding teddyding deleted the td/default-funding branch November 27, 2024 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants