From 7a04d4f936f1d16473067f7d2af0e1d3968de5f9 Mon Sep 17 00:00:00 2001 From: Sam Holmes Date: Wed, 2 Oct 2024 14:10:55 -0700 Subject: [PATCH 1/2] Add 0xGasless swap fee --- CHANGELOG.md | 2 ++ src/swap/defi/0x/0xGasless.ts | 10 +++++++--- src/swap/defi/0x/types.ts | 9 +++++++-- src/swap/defi/0x/zeroXApiTypes.ts | 6 +++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc5fe0c..50725b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- added: 0xGasless swap fee + ## 2.10.0 (2024-10-04) - added: (LI.FI) Added unique parent contract addresses diff --git a/src/swap/defi/0x/0xGasless.ts b/src/swap/defi/0x/0xGasless.ts index 4096ce68..049af240 100644 --- a/src/swap/defi/0x/0xGasless.ts +++ b/src/swap/defi/0x/0xGasless.ts @@ -80,11 +80,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: initOptions.feeReceiveAddress, + feeSellTokenPercentage: initOptions.feePercentage, + feeType: 'volume', sellToken: fromTokenAddress ?? NATIVE_TOKEN_ADDRESS, - buyToken: toTokenAddress ?? NATIVE_TOKEN_ADDRESS, - takerAddress: fromWalletAddress, - [amountField]: swapNativeAmount + takerAddress: fromWalletAddress }) if (!apiSwapQuote.liquidityAvailable) diff --git a/src/swap/defi/0x/types.ts b/src/swap/defi/0x/types.ts index 64ebe8f6..007182ab 100644 --- a/src/swap/defi/0x/types.ts +++ b/src/swap/defi/0x/types.ts @@ -1,5 +1,10 @@ -import { asObject, asString } from 'cleaners' +import { asNumber, asObject, asOptional, asString } from 'cleaners' export const asInitOptions = asObject({ - apiKey: asString + apiKey: asString, + feePercentage: asOptional(asNumber, 0.0075), + feeReceiveAddress: asOptional( + asString, + '0xd75eB391357b89C48eb64Ea621A785FF9B77e661' + ) }) diff --git a/src/swap/defi/0x/zeroXApiTypes.ts b/src/swap/defi/0x/zeroXApiTypes.ts index 520dadf6..f6cf5057 100644 --- a/src/swap/defi/0x/zeroXApiTypes.ts +++ b/src/swap/defi/0x/zeroXApiTypes.ts @@ -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 @@ -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 @@ -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 From 24d5d5736c725c38695ef7e0b27a43a3dfd650ae Mon Sep 17 00:00:00 2001 From: Sam Holmes Date: Tue, 8 Oct 2024 11:07:27 -0700 Subject: [PATCH 2/2] v2.11.0 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50725b65..ce43383e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +## 2.11.0 (2024-10-08) + - added: 0xGasless swap fee ## 2.10.0 (2024-10-04) diff --git a/package.json b/package.json index a1fed5e1..138fddf2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edge-exchange-plugins", - "version": "2.10.0", + "version": "2.11.0", "description": "Exchange-rate sources for the Edge core", "homepage": "https://edge.app/", "repository": {