-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add Usual USD0++ in defillama yield server (#1627)
* chore: initial commit for Usual in defillama yield server * fix: scale apy to the hundred scale * fix: project slug
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) * 100; | ||
return [{ | ||
pool: usd0PP, | ||
chain: 'Ethereum', | ||
project: 'usual-money', | ||
symbol: 'USD0++', | ||
tvlUsd, | ||
apyBase, | ||
rewardTokens: [usual], | ||
underlyingTokens: [usd0], | ||
}, | ||
]; | ||
} | ||
|
||
module.exports = { | ||
apy, | ||
url: 'https://app.usual.money/swap?action=stake', | ||
}; |