feat: add slippageIncrement to routeForTargetAmount#176
Conversation
WalkthroughThe changes add a new optional numeric parameter, Possibly related PRs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/request.ts (1)
53-53: Use const instead of let for slippageIncrementThe variable is never reassigned, so it's better to use const to prevent accidental reassignment.
- let { + const { senderAddress, fromToken, fromTokenDecimals, fromChainId, squidRouterUrl, provider, tokenType, slippagePercentage, slippageIncrement, linkDetails, } = props🧰 Tools
🪛 ESLint
[error] 53-53: 'slippageIncrement' is never reassigned. Use 'const' instead.
(prefer-const)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/request.ts(3 hunks)src/util.ts(5 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: jjramirezn
PR: peanutprotocol/peanut-sdk#166
File: src/request.ts:260-264
Timestamp: 2025-03-20T16:52:53.176Z
Learning: Validation for `slippagePercentage` is already performed within the called functions in `prepareXchainRequestFulfillmentTransaction`, so additional validation in this function is unnecessary.
src/request.ts (1)
Learnt from: jjramirezn
PR: peanutprotocol/peanut-sdk#166
File: src/request.ts:260-264
Timestamp: 2025-03-20T16:52:53.176Z
Learning: Validation for `slippagePercentage` is already performed within the called functions in `prepareXchainRequestFulfillmentTransaction`, so additional validation in this function is unnecessary.
🪛 ESLint
src/request.ts
[error] 53-53: 'slippageIncrement' is never reassigned. Use 'const' instead.
(prefer-const)
🔇 Additional comments (6)
src/request.ts (2)
25-25: Good addition of the slippageIncrement parameterThis new optional parameter will give users more control over slippage handling during cross-chain transactions. It's properly integrated in the type definition.
114-114: Good implementation of passing the slippageIncrement parameterThe parameter is correctly passed to the routeForTargetAmount function, maintaining consistency with the function's signature in util.ts.
src/util.ts (4)
751-762: Good code formatting improvementThe multi-line formatting of these BigNumber conversions improves readability while maintaining the same functionality. Each parameter is now clearly visible on its own line.
842-843: Appropriate addition of slippageIncrement parameterAdding this parameter to the function signature and interface allows for configurable slippage increments, which provides better flexibility for different trading scenarios.
Also applies to: 851-852
891-891: Default value for slippageIncrement is higher than previous hardcoded valueThe default value is now set to 0.4, which is higher than the previous hardcoded value of 0.1. This will make the slippage increase more aggressively by default, potentially reaching the target amount faster but with higher slippage.
Consider whether this more aggressive default is intentional. It may result in trades executing with higher slippage than before, which could affect users who don't explicitly provide a slippageIncrement value.
905-905: Good implementation of dynamic slippage incrementReplacing the hardcoded 0.1 increment with the configurable slippageIncrement parameter correctly implements the intended functionality.
No description provided.