UniDex Leverage Fee Revenue

This adapter should track the protocol revenue of the leverage protocol from UniDex. Fees are collected every time a user opens/closes a trade or gets liquidated. This fee revenue is split 60/40 between the liquidity pools and holders.

Revenue is collected in both USDC and FTM while the adapter will convert the FTM fees to a USD value and combine it with the USDC fees collected for the queryable USD value of the fees collected for that day.

PS: First time trying to add one of these so sorry if I messed up the format :stuck_out_tongue:

Hey @krunalunidex, thanks for submitting this!

Overall, adapter looks good, but one issue is that the adapter lists the protocol launch date as 2020-10-30, but queries after that date are still failing. Even 2021-10-30 (1 year after launch) is still failing.

Can you update the launch date to be the date that fees become available?

Also, the query seems to make the assumption that the FTM data will always be returned first, and the USDC data will always be returned second. It seems that this assumption might not always hold up.

It should be easier to query the dayData entities by ID instead, such as the ID 0x0000000000000000000000000000000000000000-19169 for FTM and 0x04068da6c83afcfa0e13ba15a6696662335d5b75-19169 for USDC. The second number in the ID is the day number, you can look at the Uniswap adapter for an example of how to use those.

Also, an icon must be included in the adapter, preferably an SVG icon. Click the “Image Library” in the bottom left of the adapter editor to upload an icon.

Other than that, couple style fixes:

  • The Promise.all on line 9 is unnecessary, can be reduced to this:
    const ftmPrice = await sdk.coinGecko.getHistoricalPrice('fantom', date);
  • The use of “variable” for Graph queries is deprecated, you can simplify the code to this:
    const data = await sdk.graph.query(
      'unidex-finance/unidexleverage',
      graphQuery,
      {
        date: sdk.date.dateToTimestamp(date),
        nextDate,
      },
    );

thanks for the input

made some adjustments :arrow_right: https://cryptostats.community/discover/adapter/QmV3htgmbwQ5zinWHm24LeszE7Jf57HyWbDWQaAWYWnMAT

  • added a logo that should be easily viewable/distinguishable
  • fixed the date to match the queryable subgraph start block
  • fixed the styling changes that was pointed add
  • We didn’t change the methodology of fetching data since it doesn’t seem possible to have one before the other. We use the same methodology for our stats page.