Skip to content

Commit

Permalink
Add 0xGasless swap fee
Browse files Browse the repository at this point in the history
  • Loading branch information
samholmes committed Oct 2, 2024
1 parent 7c8a878 commit d4024c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- added: 0xGasless swap fee

## 2.8.1 (2024-10-02)

- fixed: POL currency code transcriptions for `letsexchange` and `changenow`
Expand Down
13 changes: 10 additions & 3 deletions src/swap/defi/0x/0xGasless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const swapInfo: EdgeSwapInfo = {
supportEmail: 'support@edge.app'
}

const EDGE_FEE_PERCENTAGE = 0.0075
const EDGE_FEE_RECEIVE_ADDRESS = '0xd75eB391357b89C48eb64Ea621A785FF9B77e661'

export const make0xGaslessPlugin: EdgeCorePluginFactory = opts => {
const { io } = opts
const initOptions = asInitOptions(opts.initOptions)
Expand Down Expand Up @@ -80,11 +83,15 @@ export const make0xGaslessPlugin: EdgeCorePluginFactory = opts => {
swapRequest.fromWallet.currencyInfo.pluginId
)
const apiSwapQuote = await api.gaslessSwapQuote(chainId, {
[amountField]: swapNativeAmount,
acceptedTypes: 'metatransaction_v2',
buyToken: toTokenAddress ?? NATIVE_TOKEN_ADDRESS,
checkApproval: true,
feeRecipient: EDGE_FEE_RECEIVE_ADDRESS,
feeSellTokenPercentage: EDGE_FEE_PERCENTAGE,
feeType: 'volume',
sellToken: fromTokenAddress ?? NATIVE_TOKEN_ADDRESS,
buyToken: toTokenAddress ?? NATIVE_TOKEN_ADDRESS,
takerAddress: fromWalletAddress,
[amountField]: swapNativeAmount
takerAddress: fromWalletAddress
})

if (!apiSwapQuote.liquidityAvailable)
Expand Down
6 changes: 3 additions & 3 deletions src/swap/defi/0x/zeroXApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface GaslessSwapQuoteRequest {
* specifies. If not provided, it means the caller accepts any types whose
* default value is currently set to `metatransaction_v2` and `otc`.
*/
acceptedTypes?: string
acceptedTypes?: 'metatransaction_v2' | 'otc'

/**
* [optional] The maximum amount of slippage acceptable to the user; any
Expand Down Expand Up @@ -122,7 +122,7 @@ export interface GaslessSwapQuoteRequest {
* would, however, potentially improve the pricing the endpoint returned as
* there are more sources for liquidity.
*/
feeType?: string
feeType?: 'volume'

/**
* [optional] The address the integrator fee would be transferred to. This is
Expand All @@ -137,7 +137,7 @@ export interface GaslessSwapQuoteRequest {
* `sellToken` integrator charges as fee. For example, setting it to `0.01`
* means 1% of the `sellToken` would be charged as fee for the integrator.
*/
feeSellTokenPercentage?: string
feeSellTokenPercentage?: number

/**
* [optional] A boolean that indicates whether or not to check for approval and
Expand Down

0 comments on commit d4024c0

Please sign in to comment.