-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat(rfq-relayer): make QuoteWidthBps a token-level param [SLT-354] #3305
Conversation
WalkthroughThe pull request introduces a new field, Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Deploying sanguine-fe with Cloudflare Pages
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3305 +/- ##
===================================================
- Coverage 33.27199% 24.99048% -8.28151%
===================================================
Files 543 198 -345
Lines 34777 13125 -21652
Branches 82 82
===================================================
- Hits 11571 3280 -8291
+ Misses 22183 9563 -12620
+ Partials 1023 282 -741
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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 (3)
services/rfq/relayer/relconfig/config.go (2)
142-144
: LGTM. Consider adding validation for QuoteWidthBps.The addition of
QuoteWidthBps
to theTokenConfig
struct allows for more granular control over quote width for individual tokens, which is a good improvement.Consider adding a validation check in the
Validate
method to ensure thatQuoteWidthBps
is always positive, as per the comment. This would prevent configuration errors at runtime.
Add validation for
QuoteWidthBps
in theValidate
method.The
validate
method inservices/rfq/relayer/relconfig/config.go
does not currently include validation for the newly addedQuoteWidthBps
field inTokenConfig
. To ensure configuration integrity, please update theValidate
method to include appropriate checks forQuoteWidthBps
.
- File:
services/rfq/relayer/relconfig/config.go
- Lines to Update: Within the
Validate
method, add validation logic forQuoteWidthBps
similar to existing field validations.🔗 Analysis chain
Line range hint
279-321
: Update Validate method and review QuoteWidthBps usage.With the addition of
QuoteWidthBps
toTokenConfig
, theValidate
method of theConfig
struct may need to be updated to include validation for this new field. Additionally, the usage ofQuoteWidthBps
throughout the codebase should be reviewed to ensure it's now being accessed from the correct location.
- Update the
Validate
method to include checks forQuoteWidthBps
in eachTokenConfig
.- Review and update any code that previously accessed
QuoteWidthBps
fromChainConfig
to now use it fromTokenConfig
.Please run the following script to identify potential areas that need updating:
Review the results and make necessary updates to align with the new configuration structure.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usages of QuoteWidthBps in the codebase rg -i 'quotewidthbps' --type go # Search for the Validate method rg -i 'func \(c config\) validate' --type goLength of output: 146
Script:
#!/bin/bash # Search for QuoteWidthBps within the validate method rg -i 'func \(c Config\) validate[^}]*quotewidthbps' --type go # Search for any remaining usages of QuoteWidthBps outside of test files rg -i 'quotewidthbps' --type go -g '!*.test.go'Length of output: 1758
services/rfq/relayer/quoter/quoter.go (1)
821-824
: LGTM! Consider enhancing error handling.The changes look good and align with the PR objective of making QuoteWidthBps a token-level parameter. This allows for more granular control over quote widths based on specific tokens.
Consider wrapping the error returned from
m.config.GetQuoteWidthBps
with additional context:quoteWidthBps, err := m.config.GetQuoteWidthBps(input.DestChainID, tokenName) if err != nil { - return nil, fmt.Errorf("error getting quote width bps: %w", err) + return nil, fmt.Errorf("error getting quote width bps for token %s on chain %d: %w", tokenName, input.DestChainID, err) }This will provide more detailed information in case of an error, making debugging easier.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
- services/rfq/relayer/quoter/quoter.go (1 hunks)
- services/rfq/relayer/relconfig/config.go (1 hunks)
- services/rfq/relayer/relconfig/config_test.go (0 hunks)
- services/rfq/relayer/relconfig/getters.go (1 hunks)
💤 Files with no reviewable changes (1)
- services/rfq/relayer/relconfig/config_test.go
🧰 Additional context used
🔇 Additional comments (3)
services/rfq/relayer/relconfig/config.go (1)
Line range hint
65-106
: Verify usage of QuoteWidthBps in other parts of the codebase.The
QuoteWidthBps
field has been removed from theChainConfig
struct and added to theTokenConfig
struct. This change allows for more granular control but may require updates in other parts of the codebase.Please run the following script to check for any remaining references to
QuoteWidthBps
in the context ofChainConfig
:#!/bin/bash # Search for references to QuoteWidthBps in the context of ChainConfig rg -i 'chainconfig.*quotewidthbps' --type goEnsure that all occurrences are updated to use the new
TokenConfig.QuoteWidthBps
instead.services/rfq/relayer/relconfig/getters.go (2)
442-458
: Function implementation looks goodThe updated
GetQuoteWidthBps
function correctly retrieves theQuoteWidthBps
value from the token configuration based on the providedchainID
andtokenName
. Error handling is appropriately managed for missing chain or token configurations, and negative width values.
442-458
: Ensure all calls toGetQuoteWidthBps
are updated with the new parameterThe method
GetQuoteWidthBps
now includes an additional parametertokenName string
in its signature. Please verify that all invocations of this method throughout the codebase have been updated to pass bothchainID
andtokenName
to prevent any potential runtime errors.Run the following script to identify any usages of
GetQuoteWidthBps
that may not have been updated:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- services/rfq/relayer/quoter/quoter_test.go (2 hunks)
🧰 Additional context used
🔇 Additional comments (1)
services/rfq/relayer/quoter/quoter_test.go (1)
401-404
: Test correctly validates error handling for negativeQuoteWidthBps
The test case appropriately verifies that setting
QuoteWidthBps
to a negative value results in an error fromGetDestAmount
. This strengthens the validation logic by ensuring that invalid configuration values are properly handled, enhancing the robustness of the system.
tokenCfg := s.config.Chains[origin].Tokens["USDC"] | ||
tokenCfg.QuoteOffsetBps = originQuoteOffsetBps | ||
s.config.Chains[origin].Tokens["USDC"] = tokenCfg | ||
tokenCfg = s.config.Chains[dest].Tokens["USDC"] | ||
tokenCfg.QuoteOffsetBps = destQuoteOffsetBps | ||
tokenCfg.QuoteWidthBps = quoteWidthBps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider setting QuoteWidthBps
for the origin token configuration
In the setQuoteParams
function, QuoteWidthBps
is being set only for the destination token configuration. If QuoteWidthBps
is a token-level parameter that affects both origin and destination tokens, consider setting it for the origin token configuration as well. This ensures comprehensive testing and consistent behavior across all tokens.
🛠️ Refactor suggestion
Use integer types for basis points parameters
The setQuoteParams
function accepts basis points parameters (originQuoteOffsetBps
, destQuoteOffsetBps
, quoteWidthBps
) as float64
. Since basis points represent integer values (1 basis point = 0.01%), consider using integer types (e.g., int
or uint
) for these parameters. This prevents potential floating-point precision issues and more accurately represents the discrete nature of basis points.
There was a problem hiding this 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)
services/rfq/relayer/quoter/quoter_test.go (1)
Line range hint
251-326
: Add tests forQuoteWidthBps
inTestGetOriginAmount
Currently, the
TestGetOriginAmount
function does not include test cases that assess the impact ofQuoteWidthBps
on origin amount calculations. Adding such tests would enhance coverage and verify thatQuoteWidthBps
is consistently applied in both origin and destination amount computations.Would you like assistance in adding these test cases?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- services/rfq/relayer/quoter/quoter_test.go (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
services/rfq/relayer/quoter/quoter_test.go (2)
362-365
: Consider settingQuoteWidthBps
for the origin token configurationCurrently,
QuoteWidthBps
is being set only for the destination token configuration in thesetQuoteParams
function. IfQuoteWidthBps
should also affect the origin token calculations, consider setting it for the origin token configuration to ensure consistent behavior across both origin and destination tokens.
401-405
: Proper error handling for negativeQuoteWidthBps
valuesThe test case correctly verifies that a negative
QuoteWidthBps
value results in an error. This ensures that the system robustly handles invalid input forQuoteWidthBps
.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Refactor
Tests