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

Add 0xGasless swap fee #344

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 2.11.0 (2024-10-08)

- added: 0xGasless swap fee

## 2.10.0 (2024-10-04)

- added: (LI.FI) Added unique parent contract addresses
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
10 changes: 7 additions & 3 deletions src/swap/defi/0x/0xGasless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions src/swap/defi/0x/types.ts
Original file line number Diff line number Diff line change
@@ -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'
)
})
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
Loading