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

Create sip-399.md #2046

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions content/sips/sip-399.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
sip: 399
network: Base
title: Add Dynamic UX Fee to Support Gasless Transactions
status: Draft
author: Kwentoids
created: 2024-07-23
type: Governance
---

## 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:
1. The frontend prepares a trade.
2. 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:
```javascript
const aaFee = isOneClickTrade ? await this.getAvgTxCost() : undefined

const tradeRequest = await this.synthetixSdk(chainId).markets.build.modifyPosition({
interfaceFee: interfaceFee(isOneClickTrade, aaFee),
})
Loading