SIP-399: Add Dynamic UX Fee to Support Gasless Transactions
Author | Kwentoids |
---|---|
Status | Draft |
Type | Governance |
Network | Base |
Implementor | TBD |
Release | TBD |
Created | 2024-07-23 |
Simple Summary
Add a flexible additive integrator fee to all perps instances.
Abstract
Update V3 on Base, Arbitrum, and Ethereum to include a dynamic additive integrator fee. Each contract would follow an identical model to unify the process of building with Synthetix additive fees across all markets.
Motivation
Including a dynamic additive fee for integrators will enable new use cases for integrators and empower them as they gain more control over the perps markets fueled by Synthetix. Integrators require a unified fee system to offer a gasless experience within their trading features.
The additive fee would also reduce the overhead of building new contracts to issue fees for each instance of Synthetix. With multiple instances live and more on the way, managing this has become challenging and could cause issues as Synthetix contracts evolve, leading to an unreliable experience for users. These challenges can be alleviated by having the contracts support a reliable dynamic additive fee.
Specification
With the move to unified accounts across various marketplaces, integrators seek to bring a CEX-like trading experience to DeFi. Unified accounts will use account abstraction to sponsor gas costs and abstract the concept of ETH-based gas for traders. This will enable a better experience for those onboarding from centralized exchanges, as they will only need to bridge one asset (USDC) to trade.
To sponsor gas and remain net neutral on costs, integrators will charge a fee in USDC at trade time, submitted by the frontend to help recoup these costs. These fees can initially be directed to a multisig wallet that will manually handle conversion back to ETH. Eventually, fees can be sent to an automated contract.
The current solution is to build discrete AA paymasters for every Synthetix integration, but this increases development time, audit costs, and delays the launch of new perpetuals products.
We propose a dynamic fee, charged via the frontend, that is universal across all perps implementations and solely used to recoup gas costs.
Technical
Add a dynamicGasFee
parameter that can be passed through the TrustedForwarder
contract and used every time a position is created, closed, or modified. The fee is attempted to be pulled directly from the trader’s idle margin. If unsuccessful, the fee is pulled from an active position. If still unsuccessful, the transaction reverts. Reverting when the user doesn’t have enough margin would prevent attacks from draining the sponsorship tank.
The dynamicGasFee
should be a tuple, array, or struct that supports both a gas fee denominated in USDC (uint) and the recipient (address).
How the flow would work:
- The frontend prepares a trade.
- The backend/SDK calculates the expected gas cost, converts this to USDC, attaches the relevant recipient address, and submits this to the
TrustedForwardContract
with a trade.
Example SDK logic:
const aaFee = isOneClickTrade ? await this.getAvgTxCost() : undefined
const tradeRequest = await this.synthetixSdk(chainId).markets.build.modifyPosition({
…
interfaceFee: interfaceFee(isOneClickTrade, aaFee),
…
})