From 35dad91421b39ceb65be315c05946a3e55ae81db Mon Sep 17 00:00:00 2001 From: sotatek-tyler-nguyen4 Date: Mon, 28 Jul 2025 17:56:21 +0700 Subject: [PATCH 1/2] XDEFI-14819 feat: remove swap feature --- .vitepress/config.ts | 5 - about/xdefi-token/buy-xdefi.md | 3 - routing/introduction.md | 1 - routing/query-mutation-details.md | 89 +++++----- routing/swap-example.md | 266 ------------------------------ swap-widget/widget-integration.md | 32 ---- 6 files changed, 44 insertions(+), 352 deletions(-) delete mode 100644 routing/swap-example.md delete mode 100644 swap-widget/widget-integration.md diff --git a/.vitepress/config.ts b/.vitepress/config.ts index b36bc564c..58dca8ee5 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -652,11 +652,6 @@ export default { text: '🔹 Query and Mutation details', link: '/routing/query-mutation-details', }, - { text: '🔹 Swap example', link: '/routing/swap-example' }, - { - text: '🔹 Swap Widget', - link: '/swap-widget/widget-integration', - }, ], }, { diff --git a/about/xdefi-token/buy-xdefi.md b/about/xdefi-token/buy-xdefi.md index eb4923826..2570f6f0a 100644 --- a/about/xdefi-token/buy-xdefi.md +++ b/about/xdefi-token/buy-xdefi.md @@ -6,9 +6,6 @@ - [Ctrl Wallet](https://chrome.google.com/webstore/detail/xdefi-wallet/hmeobnfnfcmdkdcmlblgagmfpfboieaf) - [Ctrl Web App](https://ctrl.xyz/) - ::: info - You can implement our Routing API to easy swap any asset into **$XDEFI**. Follow [our documentation](/swap-widget/widget-integration) to implement it on any platform in few lines of code. - ::: ## DEX diff --git a/routing/introduction.md b/routing/introduction.md index be4671c96..5b18fd751 100644 --- a/routing/introduction.md +++ b/routing/introduction.md @@ -17,7 +17,6 @@ _Comprehensive description of the routing service and its endpoints_ - [Endpoints](./endpoints) - [Routing Graph QL API](./routing-graph-ql-api) - [Query and Mutation details](./query-mutation-details) -- [Step by step Swap example](./swap-example) ## Introduction diff --git a/routing/query-mutation-details.md b/routing/query-mutation-details.md index edfb1a39e..e7502c7d5 100644 --- a/routing/query-mutation-details.md +++ b/routing/query-mutation-details.md @@ -7,7 +7,6 @@ _Deep-dive into our Graph QL schema_ In the [previous section](./routing-graph-ql-api), we saw an overview of queries and mutations publicly available. Here we'll zoom into each one of them and present their inputs and outputs and also show some usage examples. -A step-by-step full example of how routing works is available in the [next section](./swap-example). ### chainsV2 & chainV2 @@ -16,12 +15,12 @@ Both of these queries return information about assets available in one (chain, g While `chainsV2` has no parameters, `chainV2` takes one of the following chain names: ```js [JavaScript] -const ENDPOINT = "https://routingapi.xdefiservices.com/"; +const ENDPOINT = 'https://routingapi.xdefiservices.com/'; const fetchChainsV2 = async () => { - fetch(ENDPOINT + "chains") - .then((response) => response.json()) - .then((result) => { + fetch(ENDPOINT + 'chains') + .then(response => response.json()) + .then(result => { console.log(result); }); }; @@ -69,7 +68,7 @@ Both queries return objects of type `RoutingTokenTypeV2` defined in the above se ::: code-group ```js [JavaScript] -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; +const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; const query = ` query TokenV2($tokenV2Id: String!) { routingV2 { @@ -88,21 +87,21 @@ query TokenV2($tokenV2Id: String!) { }`; const vars = { - tokenV2Id: "2a1456da-6642-4293-b383-baefcdf4c22e", + tokenV2Id: '2a1456da-6642-4293-b383-baefcdf4c22e', }; const fetchTokenV2 = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify({ query, variables: vars, }), }) - .then((response) => response.json()) - .then((result) => { + .then(response => response.json()) + .then(result => { console.log(result); }); }; @@ -127,7 +126,7 @@ fetchTokenV2(); ::: code-group ```js [JavaScript] -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; +const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; const query = ` query TokensV2($names: [String!]) { routingV2 { @@ -140,21 +139,21 @@ query TokensV2($names: [String!]) { }`; const vars = { - names: ["AVAX.AVAX", "AVAX.STG"], + names: ['AVAX.AVAX', 'AVAX.STG'], }; const fetchTokensV2 = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify({ query, variables: vars, }), }) - .then((response) => response.json()) - .then((result) => { + .then(response => response.json()) + .then(result => { console.log(result); }); }; @@ -325,7 +324,7 @@ The address is then checked: ::: code-group ```js [JavaScript] -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; +const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; const query = ` query AddressCheckV2($address: AddressRouteInputTypeV2!) { routingV2 { @@ -345,23 +344,23 @@ query AddressCheckV2($address: AddressRouteInputTypeV2!) { const vars = { address: { - address: "0x7045916CEEFf58547E80E31d2c60ae5F67D63027", - chain: "ETH", + address: '0x7045916CEEFf58547E80E31d2c60ae5F67D63027', + chain: 'ETH', }, }; const fetchAddressCheckV2 = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify({ query, variables: vars, }), }) - .then((response) => response.json()) - .then((result) => { + .then(response => response.json()) + .then(result => { console.log(result); }); }; @@ -387,9 +386,9 @@ fetchAddressCheckV2(); Rather than taking an input, this query relies on the header being passed through the `POST` request. ```js -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; -const ACCOUNT_ADDRESS = "Your account address"; -const SIGNED_MESSAGE = "The message signed with registered address"; +const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; +const ACCOUNT_ADDRESS = 'Your account address'; +const SIGNED_MESSAGE = 'The message signed with registered address'; const query = ` query ReferralFeeSummary { @@ -416,17 +415,17 @@ query ReferralFeeSummary { const fetchReferrerSummary = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', Authorization: `${ACCOUNT_ADDRESS}:${SIGNED_MESSAGE}`, }, query: JSON.stringify({ query: query, }), }) - .then((response) => response.json()) - .then((result) => { + .then(response => response.json()) + .then(result => { console.log(result); }); }; @@ -457,8 +456,8 @@ This query takes a date in the format `"YYYY-MM-DD"` and return for each date af ::: code-group ```js [JavaScript] -import moment from "moment"; -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; +import moment from 'moment'; +const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; const query = ` query Volume($startDate: String!) { routingV2 { @@ -470,21 +469,21 @@ query Volume($startDate: String!) { }`; const vars = { - startDate: moment().subtract(1, "weeks").format("YYYY-MM-DD"), + startDate: moment().subtract(1, 'weeks').format('YYYY-MM-DD'), }; const fetchDailyVolume = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify({ query, variables: vars, }), }) - .then((response) => response.json()) - .then((result) => { + .then(response => response.json()) + .then(result => { console.log(result); }); }; @@ -591,9 +590,9 @@ For referral programme participants, this triggers a claim of a fraction of the This mutation does not take an input but rather relies on the header which should include an `Authorization` field (similar to the `referralSummary` query) ```js -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; -const ACCOUNT_ADDRESS = "Your account address"; -const SIGNED_MESSAGE = "The message signed with registered address"; +const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; +const ACCOUNT_ADDRESS = 'Your account address'; +const SIGNED_MESSAGE = 'The message signed with registered address'; const query = ` mutation claimFees { @@ -607,17 +606,17 @@ mutation claimFees { const fetchClaimFees = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', Authorization: `${ACCOUNT_ADDRESS}:${SIGNED_MESSAGE}`, }, query: JSON.stringify({ query: query, }), }) - .then((response) => response.json()) - .then((result) => { + .then(response => response.json()) + .then(result => { console.log(result); }); }; diff --git a/routing/swap-example.md b/routing/swap-example.md deleted file mode 100644 index 362a42832..000000000 --- a/routing/swap-example.md +++ /dev/null @@ -1,266 +0,0 @@ -# Step-by-step Swap example - -[[toc]] - -## Swap Avalanche (AAVE) for Avalanche (USDT) - -This particular route (swap) consists of two transactions. However, the number of transactions required for swapping different coins and across different chains may vary and depend on several factors such as the source coin, the destination coin, and the number of available addresses for signing transactions. - -### Step 1 - -In this step, we prepare the data for the chains and assets that our routing system supports. This data enables us to display the source and destination tokens to users and query and display swap route in the next step. - -#### 1.1 Get list of supported chains - -[Explorer query ChainsV2](https://gql-router.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAMIAWAhgJZIDOAagExHAA6SRReEMKNA5kxbtOnKJRoNmbDqM5IKiEaIC%2BytUhUgVQA) - -```js -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; -const query = ` -query ChainsV2 { - routingV2 { - chainsV2 { - name, - } - } -}`; -const fetchChainsV2 = async () => { - setLoading(true); - setResponse({}); - - await fetch(GRAPHQL_ENDPOINT, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - query, - }), - }) - .then((response) => response.json()) - .then((result) => { - console.log(result); - }); -}; - -fetchChainsV2(); -``` - -
- -#### 1.2 Get list of assets for supported chain - -[Explorer query ChainV2](https://gql-router.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAMIAWAhgJZIBqATABQAkSFi6RAyinjQOYBCAJRFgAHSREieCDBQCGYydOlRKNBozYcirdglESpq6ToQrTRFBADWyAM7KTVohQcOEKZ69NQIqHgUUCiWvkQOBHAARhAANmFWAL6J0ikuROlpkkkgADQgAG4UfBTRcQgOGCDG0uIg5vWc9QCCtC0AGvU5IElAA) - -```js -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; -const query = ` -query ChainV2($name: String!) { - routingV2 { - chainV2(name: $name) { - name - tokens { - asset { - contract - symbol - } - } - } - } -}`; -const vars = { - name: "ETH", -}; -const fetchChainV2 = async () => { - await fetch(GRAPHQL_ENDPOINT, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - query, - variables: vars, - }), - }) - .then((response) => response.json()) - .then((result) => { - console.log(result); - }); -}; - -fetchChainV2(); -``` - -In demo we use `ETH` as a chain name. - -
- -### Step 2 - -Query swap route. This query returns a `tradesRoute` collection, along with other properties. Based on this data, we can show the user which providers we will use, the amount of fees in dollars and assets for each transaction, and thus calculate the total fees and approximate transaction time in seconds. - -[Explorer query RouteV2](https://gql-router.xdefi.services/graphql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAEoQwoIBqATABQAkAznlACoQDWy6RAyijwBLJAHMAhABoiDMAiYoO3JLwHCxUmUwA2QgA56AhqISrBIidIaGwYPPKbzeAbQCCt%2B0yZkKCAJJIehRsBHrUNOIAupqy8ijudg5m6pYyhnDkqHzkrKb85mJWIgBmIkKUrgZ4EABuhtq8AEIQENoIhkgAlETAADpIRETVFBa0Pf2Dg8OUtHQs7Fw8WqxKyNJyCqsqMhuKi0jSOvpGJrzMugbGCNI2iV5OaR4O8utxCZ5MZ7vvDjcZMFkclA8tZ-oCYLlpCUyhUqrV6mdoUhyghKnpqnVtN0%2BgNJoNbh95ONcXjBlAABaGEQTUn4p5eGl4gC%2BjMm33pTFZg3RQmBJEMlC5RB5fIFCDYCAAHighUdLiYhSL-HAjFAZSTJulMigAkLBDZ5D5KMTadyMUI5HgTabBhahYMWRq8VqATqkPaiC7UAB5CgeuAiVxglAkBDAoQ1BBgD2Ge5u602u1OyaOm2xxwoX0oBOmpM21Om4oIBA52lIBAoADuEDwnAAYsWACKtbSGPAewblqs1%2BvF1xxjtEEQAI0yYAbCGb2lb7eTeJHY4n-Yzg6YlcMegng6LCH5lDYeA6TEMaqEEHdc8mkrkpT4683xcH14Qt-vE6nM49BdpSr3CAAqkwYDLhWWYer%2BYqAcBca6pe%2BpyCEYRCt%2BkyiLGAAKwjApyyYbui8LaAEpTIpQdatqIQr4NUeCNDAQjaGAFhGggrIFo6TIgJIIB1MIhjDm0TAYCAOKDL0IDzFsYm8GJrhUK4AAaAB0AAMkoAGwAMyGAA7DQAAcylqcpACcenDmAGlgMZACsNDKVAUAACwaRp1lqbY2l6YYRbWRZenucZYmSDSYm7JJGBEDJclKapUDaQAjKZznaaZ9nKY58VQAZ1mGPFUZQMOhjWfZmUIL5w42fF8V6UFIXiRcJwsRFYnxbVuJiQSzychFzgiaaYkUlS7rNSAskKW1NodRyUmRSAqnWRpNDGQgw4AMLWcZykacOACi8WrUVjmOdpak0Il8Uac5dZGTtjbDtZq3GQdGliaxkTBe14BvNNI3zYty1rRtW27fth3Had52XRp13Kbd92Pc9E2zV6KDZBCwIzWJymKTQL2cXVSIomiGL1DNSAwNO-QcUyQA) - -::: code-group - -```ts [JavaScript] -const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; -const query = ` -query RouteV2($srcToken: String!, $destToken: String!, $slippage: String!, $addresses: [AddressRouteInputTypeV2!]!, $destAddress: String!, $amountSource: String, $infiniteApproval: Boolean) { - routingV2 { - routeV2(srcToken: $srcToken, destToken: $destToken, slippage: $slippage, addresses: $addresses, destAddress: $destAddress, amountSource: $amountSource, infiniteApproval: $infiniteApproval) { - addresses { - chain - address - } - destAddress - priceRate - priceRateText - slippage - priceImpact - amountIn - tradesRoute { - provider { - id - } - amountIn - amountOut - minAmountReceived - assetIn { - id - } - assetOut { - id - } - fee { - networkFeeDollar - networkFeeAsset - inboundFeeDollar - inboundFeeAsset - swapFee - feeRateTransaction - xdefiSwapFee - xdefiSwapFeeDollar - } - priceRateUsdAssetOut - priceRateUsdAssetIn - tradeType - } - gasPrices - approvalInfiniteFlag - errorBuildingRoute - } - } -}`; -const vars = { - srcToken: "AVAX.0x63a72806098bd3d9520cc43356dd78afe5d386d9", - destToken: "AVAX.0xc7198437980c041c805a1edcba50c1ce5db95118", - slippage: "1", - addresses: [ - { - chain: "AVAX", - address: "0x5329ebC5903bE1Ca544762191343F60EDb5C9Ca3", - }, - ], - destAddress: "0x5329ebC5903bE1Ca544762191343F60EDb5C9Ca3", - amountSource: "0.23", - infiniteApproval: null, -}; - -const fetchRouteV2 = async () => { - await fetch(GRAPHQL_ENDPOINT, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - query, - variables: vars, - }), - }) - .then((response) => response.json()) - .then((result) => { - console.log(result); - }); -}; - -fetchRouteV2(); -``` - -```js [Variables] -{ - "srcToken": "AVAX.0x63a72806098bd3d9520cc43356dd78afe5d386d9", - "destToken": "AVAX.0xc7198437980c041c805a1edcba50c1ce5db95118", - "slippage": "1", - "addresses": [ - { - "chain": "AVAX", - "address": "0x5329ebC5903bE1Ca544762191343F60EDb5C9Ca3" - }, - ], - "destAddress": "0x5329ebC5903bE1Ca544762191343F60EDb5C9Ca3", - "amountSource": "0.23", - "infiniteApproval": null -} -``` - -```ts [Snippets] -enum TradeType { - APPROVAL = "APPROVAL", - BRIDGE = "BRIDGE", - REDEEM = "REDEEM", - SWAP = "SWAP", -} -``` - -::: - -
- -**Variables:** - -- `chainName`: This variable is obtained from step [1.1](#1.1-get-list-of-supported-chains). -- `contract`: This variable is obtained from step [1.2](#1.2-get-list-of-assets-for-supported-chain. -- `srcToken`: This variable has the format `${chainName}.${contract} and represents the token to be swapped. -- `destToken`: This variable also has the format `${chainName}.${contract}` and represents the token to receive in exchange. -- For native tokens, the format is `${chainName}.${nativeTokenName}`. For example, Ethereum's native token is "ETH", so the format would be "ETH.ETH". For Polygon, it's "POLYGON.MATIC", and for Binance Smart Chain, it's "BSC.BNB". -- `slippage`: This variable represents the percentage of slippage tolerance for the trade. -- `addresses`: This variable is a collection of addresses available to sign transactions. For this swap, we only need one, as the trade takes place within the Avalanche chain. -- `destAddress`: This variable represents the address that will receive the swapped Avalanche (USDT) upon completion of the trade. -- `amountSource`: This variable represents the amount of Avalanche (AAVE) to be swapped. -- `infiniteApproval`: Using this prop is not mandatory, but it allows users to avoid approving trades when swapping ERC20 tokens. However, it's important to note that the first approval still needs to be granted. - -**Response:** - -- `networkFeeDollar`: Provider fee. 1Inch in example. -- `networkFeeAsset`: Provider fee in asset value. -- `inboundFeeDollar`: Network fee for transaction. Cost of Avalanche transaction. -- `inboundFeeAsset`: Network fee for transaction in native token. AVAX in example. - -**Snippets:** - -- Enum describes all possible values for `tradeType` property from the response. - - diff --git a/swap-widget/widget-integration.md b/swap-widget/widget-integration.md deleted file mode 100644 index 620fff312..000000000 --- a/swap-widget/widget-integration.md +++ /dev/null @@ -1,32 +0,0 @@ -# Swap Widget - -## Overview - -This documentation provides instructions for web developers to seamlessly integrate our swap widget into their webpages using an iframe. - -## Prerequisites - -Before integrating the widget, ensure that you have the following: - -- Access to the HTML of the page you will be adding the widget to -- Your referral codes generated and accessible. - -## Instructions - -Adding the swap widget is really simple. Just add the following iframe code to the HTML of your webpage where you want the widget to appear. - -Remember to replace the placeholder with your referral code. - -```html - -``` - -## Configuration - -You can configure the width and height of the widget to fit your page content by adjusting the width and height parameters in the iframe tag. From 9b37e7b020179a302ae6baec7def946c551aa61e Mon Sep 17 00:00:00 2001 From: sotatek-tyler-nguyen4 Date: Mon, 28 Jul 2025 18:05:16 +0700 Subject: [PATCH 2/2] fix: standardize string quotes in query-mutation-details.md --- routing/query-mutation-details.md | 60 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/routing/query-mutation-details.md b/routing/query-mutation-details.md index e7502c7d5..60157f036 100644 --- a/routing/query-mutation-details.md +++ b/routing/query-mutation-details.md @@ -15,10 +15,10 @@ Both of these queries return information about assets available in one (chain, g While `chainsV2` has no parameters, `chainV2` takes one of the following chain names: ```js [JavaScript] -const ENDPOINT = 'https://routingapi.xdefiservices.com/'; +const ENDPOINT = "https://routingapi.xdefiservices.com/"; const fetchChainsV2 = async () => { - fetch(ENDPOINT + 'chains') + fetch(ENDPOINT + "chains") .then(response => response.json()) .then(result => { console.log(result); @@ -68,7 +68,7 @@ Both queries return objects of type `RoutingTokenTypeV2` defined in the above se ::: code-group ```js [JavaScript] -const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; +const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; const query = ` query TokenV2($tokenV2Id: String!) { routingV2 { @@ -87,13 +87,13 @@ query TokenV2($tokenV2Id: String!) { }`; const vars = { - tokenV2Id: '2a1456da-6642-4293-b383-baefcdf4c22e', + tokenV2Id: "2a1456da-6642-4293-b383-baefcdf4c22e", }; const fetchTokenV2 = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify({ query, @@ -126,7 +126,7 @@ fetchTokenV2(); ::: code-group ```js [JavaScript] -const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; +const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; const query = ` query TokensV2($names: [String!]) { routingV2 { @@ -139,13 +139,13 @@ query TokensV2($names: [String!]) { }`; const vars = { - names: ['AVAX.AVAX', 'AVAX.STG'], + names: ["AVAX.AVAX", "AVAX.STG"], }; const fetchTokensV2 = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify({ query, @@ -324,7 +324,7 @@ The address is then checked: ::: code-group ```js [JavaScript] -const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; +const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; const query = ` query AddressCheckV2($address: AddressRouteInputTypeV2!) { routingV2 { @@ -344,15 +344,15 @@ query AddressCheckV2($address: AddressRouteInputTypeV2!) { const vars = { address: { - address: '0x7045916CEEFf58547E80E31d2c60ae5F67D63027', - chain: 'ETH', + address: "0x7045916CEEFf58547E80E31d2c60ae5F67D63027", + chain: "ETH", }, }; const fetchAddressCheckV2 = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify({ query, @@ -386,9 +386,9 @@ fetchAddressCheckV2(); Rather than taking an input, this query relies on the header being passed through the `POST` request. ```js -const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; -const ACCOUNT_ADDRESS = 'Your account address'; -const SIGNED_MESSAGE = 'The message signed with registered address'; +const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; +const ACCOUNT_ADDRESS = "Your account address"; +const SIGNED_MESSAGE = "The message signed with registered address"; const query = ` query ReferralFeeSummary { @@ -415,9 +415,9 @@ query ReferralFeeSummary { const fetchReferrerSummary = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", Authorization: `${ACCOUNT_ADDRESS}:${SIGNED_MESSAGE}`, }, query: JSON.stringify({ @@ -456,8 +456,8 @@ This query takes a date in the format `"YYYY-MM-DD"` and return for each date af ::: code-group ```js [JavaScript] -import moment from 'moment'; -const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; +import moment from "moment"; +const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; const query = ` query Volume($startDate: String!) { routingV2 { @@ -469,13 +469,13 @@ query Volume($startDate: String!) { }`; const vars = { - startDate: moment().subtract(1, 'weeks').format('YYYY-MM-DD'), + startDate: moment().subtract(1, "weeks").format("YYYY-MM-DD"), }; const fetchDailyVolume = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify({ query, @@ -590,9 +590,9 @@ For referral programme participants, this triggers a claim of a fraction of the This mutation does not take an input but rather relies on the header which should include an `Authorization` field (similar to the `referralSummary` query) ```js -const GRAPHQL_ENDPOINT = 'https://gql-router.xdefi.services/graphql'; -const ACCOUNT_ADDRESS = 'Your account address'; -const SIGNED_MESSAGE = 'The message signed with registered address'; +const GRAPHQL_ENDPOINT = "https://gql-router.xdefi.services/graphql"; +const ACCOUNT_ADDRESS = "Your account address"; +const SIGNED_MESSAGE = "The message signed with registered address"; const query = ` mutation claimFees { @@ -606,9 +606,9 @@ mutation claimFees { const fetchClaimFees = async () => { await fetch(GRAPHQL_ENDPOINT, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", Authorization: `${ACCOUNT_ADDRESS}:${SIGNED_MESSAGE}`, }, query: JSON.stringify({