Allow setting custom markup fees for Vortex and partners#604
Merged
Conversation
Replaced single `fee` field with detailed fee breakdowns (`networkFee`, `processingFee`, `partnerMarkupFee`, `totalFee`, and `feeCurrency`). Added support for partner-specific fee configurations via `partnerId` in the quote process. Updated models, services, and associations to support the new fee structure and partner relationship.
Replaced individual fee fields with a unified JSON fee structure across the system. This simplifies fee data representation, provides better flexibility, and consolidates related fields into a single object. Updated migrations, models, endpoints, and services to align with the new structure.
✅ Deploy Preview for pendulum-pay canceled.
|
Revised fee storage to directly use detailed fee components in the database. Updated API response to transform and aggregate fees accordingly, ensuring clarity and reducing redundant transformations. Adjusted vortex fee logic to align with partner configuration.
This commit updates the database migration and model to eliminate the 'network_estimate' fee type from the ENUM definition. Associated seed data for 'network_estimate' has also been removed to align with the updated structure.
Removed obsolete helper functions for fee calculation and integrated fee logic directly into the ramp service. Improved clarity by renaming variables and restructuring the output amount calculation. Added logic to calculate network fees in USD for EVM on-ramps and prepared the service for dynamic pricing updates.
Core fee calculation now focuses on vortex, anchor, and partner markup fees, removing unnecessary network fee logic. Introduced a unified fee structure for maintaining detailed breakdowns, improving clarity and maintainability. This change refines the QuoteTicket creation process by leveraging a cleaner fee structure.
Revised the fee calculation workflow to include proper breakdowns and introduced a placeholder function for converting fees into output currencies. Added safety checks for negative output amounts, refined fee structures, and ensured the final output amount considers all applicable fees. Future implementation will enhance currency conversion using accurate exchange rates.
Replaces the combined "processing" fee field with distinct "vortex" and "anchor" fields throughout the codebase. Updates interfaces, models, and calculations to align with the new detailed fee structure. This improves clarity and consistency in fee handling.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a granular fee structure for Vortex by replacing the single fee field with a detailed breakdown that includes network, vortex, anchor, and partner markup fees, along with the related database schema, API, and frontend changes. Key changes include:
- Updating database models and migrations (for quote tickets, partners, and fee configurations).
- Refactoring fee calculation logic in the QuoteService along with corresponding frontend modifications.
- Enhancing associated documentation and decision logs to reflect the new fee structure.
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| memory-bank/*.md | Added decision logs and context updates for the fee structure. |
| frontend/src/hooks/* & components/* | Updated fee property usage to reference the new fee structure. |
| api/src/models/* & migrations/* | Changed fee field type to JSONB, added partner and fee configuration models, and updated associations. |
| api/src/api/services/ramp/quote.service.ts | Refactored fee calculation logic to compute and store detailed fee components. |
| docs/* | Provided detailed architectural and refactoring plans for the fee enhancements. |
Added functionality to determine and convert fees to a target fiat currency using placeholder logic. Updated fee storage and response structure to utilize the target fiat instead of USD, ensuring better alignment with input/output currencies. Placeholder conversion logic still needs proper implementation with live price feeds.
Introduced `grossOutputAmount`, `anchorFeeFiat`, `distributableFeesFiat`, and `targetFiat` to the `QuoteTicketMetadata` interface. Updated the quote service to calculate and store these fields, ensuring a more detailed fee structure is preserved. This enhances tracking and transparency of fee components.
Introduce separate handling for anchor fees by adding placeholder methods for Fiat-to-USD and USD-to-token conversions. Reorganize input/output amount calculations to distinguish between gross and net values and ensure proper fee deduction. Added better type safety and logging for future implementation of price-related conversions.
Replaced manual calculation of `outputAmountBeforeFees` with `grossOutputAmount` from quote metadata for improved accuracy and consistency. Updated all relevant validations, calculations, and transaction preparations to align with this change. Added error handling to ensure `grossOutputAmount` is present in metadata.
Introduce a handler to distribute network, vortex, and partner fees in stablecoin on Pendulum. Includes placeholder implementations for fiat to USD and USD to token unit conversions, fee processing, and blockchain transactions with error handling. Future improvements include stablecoin selection logic and proper conversion methods.
…f ramp operations
30eac25 to
7dea737
Compare
…d update references
e1872bd to
65bdc98
Compare
65bdc98 to
5a53d93
Compare
Member
Author
|
@pendulum-chain/devs I addressed most/all the relevant comments. This is finally ready for merge now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes across configuration, code quality, and feature updates. The most significant updates include adding a new
DistributeFeesHandlerclass, modifying existing phase handlers to integrate the new phase, and updating configurations for caching and external APIs. Additionally, the ESLint configuration and dependencies have been streamlined for better maintainability.Feature Updates:
DistributeFeesHandlerclass to handle the distribution of network, vortex, and partner fees using a stablecoin on Pendulum. This includes methods for executing the phase, submitting transactions, and transitioning to the next phase. (api/src/api/services/phases/handlers/distribute-fees-handler.ts)MoonbeamToPendulumXcmPhaseHandlerandNablaSwapPhaseHandlerto transition to the newdistributeFeesphase where applicable. (api/src/api/services/phases/handlers/moonbeam-to-pendulum-xcm-handler.ts, [1];api/src/api/services/phases/handlers/nabla-swap-handler.ts, [2]DistributeFeesHandlerin the phase handler registry. (api/src/api/services/phases/register-handlers.ts) [1] [2]Configuration Updates:
COINGECKO_API_KEY,COINGECKO_API_URL,CRYPTO_CACHE_TTL_MS,FIAT_CACHE_TTL_MS). (api/.env.example)Code Quality and Dependency Updates:
eslint-config-airbnb-basefrom thepackage.jsondependencies and corresponding ESLint rules, simplifying the ESLint configuration. (api/package.json, [1];api/.eslintrc.js, [2] [3]calculateTotalReceiveandcalculateTotalReceiveOnramp, to clean up the codebase. (api/src/api/helpers/quote.ts)Minor Enhancements:
api/src/api/services/phases/handlers/nabla-approve-handler.ts, [1];api/src/api/services/phases/handlers/pendulum-moonbeam-phase-handler.ts, [2];api/src/api/services/phases/handlers/nabla-swap-handler.ts, [3]These changes collectively improve the functionality, maintainability, and robustness of the application.
Review tips
I would recommend reading
docs/architecture/ramp-journey-and-fees.mdanddocs/refactoring/fee-handling-refactor-summary-2025-04-30-mdbefore starting to look at the code.Closes #552.