From be0fd7684812bdcccba84ebfb97111b643c29075 Mon Sep 17 00:00:00 2001 From: "s@6120.eu" Date: Mon, 2 Dec 2024 14:28:13 +0100 Subject: [PATCH 1/3] chore: initial commit for Usual in defillama yield server --- src/adaptors/usual/index.js | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/adaptors/usual/index.js diff --git a/src/adaptors/usual/index.js b/src/adaptors/usual/index.js new file mode 100644 index 0000000000..71f09be356 --- /dev/null +++ b/src/adaptors/usual/index.js @@ -0,0 +1,43 @@ +const sdk = require('@defillama/sdk'); +const axios = require('axios'); +const utils = require('../utils'); + +const usd0PP = '0x35D8949372D46B7a3D5A56006AE77B215fc69bC0'; +const usd0 = '0x73A15FeD60Bf67631dC6cd7Bc5B6e8da8190aCF5'; +const usual = '0xC4441c2BE5d8fA8126822B9929CA0b81Ea0DE38E'; + +const symbol = 'USD0++'; + +const baseURLRewardRate = 'https://app.usual.money/api/rewards/rates/'; +const baseURLLlamaPrice = 'https://coins.llama.fi/prices/current/'; +const scalarOne = 1e18; + +const apy = async () => { + const totalSupply = + ( await sdk.api.abi.call({ + target: usd0PP, + abi: 'erc20:totalSupply', + }) + ).output / scalarOne; + const priceKey = `ethereum:${usd0PP}`; + const price = (await axios.get(`${baseURLLlamaPrice}${priceKey}` )).data.coins[priceKey].price; + const tvlUsd = totalSupply * price; + const reward = (await axios.get(`${baseURLRewardRate}${symbol}`)).data.rewards.find((e) => usual.toLowerCase() == e.rewardToken.toLowerCase()); + const apyBase = utils.aprToApy(reward.apr, 52); + return [{ + pool: usd0PP, + chain: 'Ethereum', + project: 'Usual', + symbol: 'USD0++', + tvlUsd, + apyBase, + rewardTokens: [usual], + underlyingTokens: [usd0], + }, + ]; +} + +module.exports = { + apy, + url: 'https://app.usual.money/swap?action=stake', +}; From f9ada7526bd1708d3e66ce9b4e20c3d60e34b292 Mon Sep 17 00:00:00 2001 From: "s@6120.eu" Date: Mon, 2 Dec 2024 14:43:05 +0100 Subject: [PATCH 2/3] fix: scale apy to the hundred scale --- src/adaptors/usual/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/usual/index.js b/src/adaptors/usual/index.js index 71f09be356..ed29a52af0 100644 --- a/src/adaptors/usual/index.js +++ b/src/adaptors/usual/index.js @@ -23,7 +23,7 @@ const apy = async () => { const price = (await axios.get(`${baseURLLlamaPrice}${priceKey}` )).data.coins[priceKey].price; const tvlUsd = totalSupply * price; const reward = (await axios.get(`${baseURLRewardRate}${symbol}`)).data.rewards.find((e) => usual.toLowerCase() == e.rewardToken.toLowerCase()); - const apyBase = utils.aprToApy(reward.apr, 52); + const apyBase = utils.aprToApy(reward.apr, 52) * 100; return [{ pool: usd0PP, chain: 'Ethereum', From c180bf94eee9482786817aa8620d7823790b16aa Mon Sep 17 00:00:00 2001 From: "s@6120.eu" Date: Mon, 2 Dec 2024 15:11:29 +0100 Subject: [PATCH 3/3] fix: project slug --- src/adaptors/{usual => usual-money}/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/adaptors/{usual => usual-money}/index.js (97%) diff --git a/src/adaptors/usual/index.js b/src/adaptors/usual-money/index.js similarity index 97% rename from src/adaptors/usual/index.js rename to src/adaptors/usual-money/index.js index ed29a52af0..ffbb4cc6be 100644 --- a/src/adaptors/usual/index.js +++ b/src/adaptors/usual-money/index.js @@ -27,7 +27,7 @@ const apy = async () => { return [{ pool: usd0PP, chain: 'Ethereum', - project: 'Usual', + project: 'usual-money', symbol: 'USD0++', tvlUsd, apyBase,