From 310a39ed7bf714750b699505dcf026cf772bcfdf Mon Sep 17 00:00:00 2001 From: 0xmDreamy <0xmDreamy@proton.me> Date: Sun, 29 Dec 2024 15:49:50 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Add=20APY=20for=20USD0++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/collateralsApy/getUsd0ppApy.ts | 40 ++++++++++++++++++++++ src/helpers/collateralsApy/index.js | 5 ++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/helpers/collateralsApy/getUsd0ppApy.ts diff --git a/src/helpers/collateralsApy/getUsd0ppApy.ts b/src/helpers/collateralsApy/getUsd0ppApy.ts new file mode 100644 index 000000000..0c21b55f4 --- /dev/null +++ b/src/helpers/collateralsApy/getUsd0ppApy.ts @@ -0,0 +1,40 @@ +import axios from "axios"; +import { formatToFixed } from "@/helpers/filters"; +import { getCoinsPrices } from "@/helpers/prices/defiLlama"; +import { mainnet } from "viem/chains"; +import { type Address, formatEther } from "viem"; + +const usualAddress = + "0xC4441c2BE5d8fA8126822B9929CA0b81Ea0DE38E" as const satisfies Address; +const usd0ppAddress = "0x35D8949372D46B7a3D5A56006AE77B215fc69bC0" as const satisfies Address; +const usualChainId = mainnet.id; +const endpoint = "https://api.0xdreamy.dev/functions/v1/usd0pp-rewards"; // Wraps https://app.usual.money/api/rewards/rates + +export const getUsd0ppApy = async (): Promise => { + try { + const [prices, { data }] = await Promise.all([ + getCoinsPrices(usualChainId, [usualAddress, usd0ppAddress]), + await axios.get(endpoint), + ]); + + const usualPrice = prices?.[0]?.price; + const usd0ppPrice = prices?.[1]?.price; + + if (usualPrice === undefined || usd0ppPrice === undefined) { + return 0; + } + + const usd0ppUsualRewards = Number( + formatEther(BigInt(data?.["USD0++"] ?? "0")), + ); + + return Number( + formatToFixed( + ((1 + usd0ppUsualRewards / usd0ppPrice * usualPrice) ** 365 - 1) * 100, + 2, + ), + ); + } catch (error) { + return 0; + } +}; diff --git a/src/helpers/collateralsApy/index.js b/src/helpers/collateralsApy/index.js index 6ac460033..8df549fe6 100644 --- a/src/helpers/collateralsApy/index.js +++ b/src/helpers/collateralsApy/index.js @@ -12,13 +12,14 @@ import { getMagicGlpApy } from "@/helpers/collateralsApy/getMagicGlpApy"; import { getMagicApeApy } from "@/helpers/collateralsApy/getMagicApeApy"; import { getYearnVaultsApy } from "@/helpers/collateralsApy/getYearnVaultsApy"; import { getMaxLeverageMultiplierAlternative } from "@/helpers/cauldron/getMaxLeverageMultiplier.ts"; +import { getUsd0ppApy } from "./getUsd0ppApy"; export const isApyCalcExist = (chainId, poolId) => { let cauldronsIds = []; if (chainId === 1) { cauldronsIds = [ - 6, 7, 15, 16, 24, 25, 29, 30, 31, 32, 33, 34, 37, 38, 39, 43, 44, + 6, 7, 15, 16, 24, 25, 29, 30, 31, 32, 33, 34, 37, 38, 39, 43, 44, 45 ]; } @@ -57,6 +58,8 @@ export const fetchTokenApy = async (pool, chainId, provider) => { if (pool.config.id === 39) return await getMagicApeApy(chainId); if (pool.config.id === 43 || pool.config.id === 44) return getElixirApy(); + + if (pool.config.id === 45) return getUsd0ppApy(); } if (chainId === 10) { From 51356cfbdee56b98b73c19da8044c22cf3491966 Mon Sep 17 00:00:00 2001 From: 0xmDreamy <0xmDreamy@proton.me> Date: Sun, 29 Dec 2024 15:51:17 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9E=20Remove=20pills=20from=20USD0?= =?UTF-8?q?++=20cauldron=20and=20USD0=20pool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/images/pools/pills-potions.png | Bin 2612 -> 0 bytes .../images/pools/rewards/pills-icon.svg | 9 -- src/components/cauldrons/CauldronCardItem.vue | 1 - src/components/cauldrons/RewardInfo.vue | 15 --- .../market/DynamicPillsMultiplier.vue | 93 ------------------ src/components/market/LeverageBlock.vue | 9 -- src/components/market/MarketHead.vue | 1 - src/components/pools/PoolListCard.vue | 21 ---- src/components/pools/pool/PillsPotions.vue | 90 ----------------- src/components/pools/pool/TokenPair.vue | 37 ------- .../pools/pool/position/Deposited.vue | 38 ------- .../rewardPoints/RewardPointsTagWrap.vue | 10 -- .../pools/rewardPoints/pills/PillsBanner.vue | 41 -------- .../rewardPoints/pills/PillsRewardTag.vue | 53 ---------- src/configs/pools/ethereumPools.ts | 1 - src/configs/pools/types.ts | 1 - src/helpers/getTokenLinkData.ts | 2 +- 17 files changed, 1 insertion(+), 421 deletions(-) delete mode 100644 src/assets/images/pools/pills-potions.png delete mode 100644 src/assets/images/pools/rewards/pills-icon.svg delete mode 100644 src/components/market/DynamicPillsMultiplier.vue delete mode 100644 src/components/pools/pool/PillsPotions.vue delete mode 100644 src/components/pools/rewardPoints/pills/PillsBanner.vue delete mode 100644 src/components/pools/rewardPoints/pills/PillsRewardTag.vue diff --git a/src/assets/images/pools/pills-potions.png b/src/assets/images/pools/pills-potions.png deleted file mode 100644 index 2c6e3faac0ccba6ea1c3aedff67ce47439ece984..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2612 zcmV-43d{A0P)E-p2JDiVQ&h6<9gH)YVvKQ}j#TnkJf$)yj0sR`Cvm2@W%#`T zObE`w{*LWPsj*4a&uG#%l7{QBLcmJW#v<7(zkb&{aLXQM5FD3iSOq3Q(y%gvVj`8% z=r7~WB8l25N{H1#kO7|`W6QpZgJ<7ID%XFf-RJh}fs_i4pCCDxRz8I?N6>6w5biUN zIH8*JmD_*%`?IVkngP$pF`1{xf!k`w@)fiHit>^=(X@>82Cl;j0UsqGEUf&x4J5vo zpy-I@VYwYuc4#FND#D#a7`IjMduR?dAd54qTebmJN<59lJ@G0Inq34w`( zL14_n8jN#((U@0NokhA*&{Si<<8HTv3AGjY(cI0b2~81A%San=4W`(iW#ZVc_#r#3 zp)|+Ni~)&@nP;AeHYv}^kRRJz&Om2p3L`4LOrqfFOZQ;^>0M~)Y=zh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#2P3y7k_!jbH3WpnxBCFs<$D_M5isCXK z{FPpF8>(DA1ec(o`1!iU_^hj0bhnna0;>!AzivPqvXeGO zd+BfyLAnhBs~>SYV!gD->Fh>v$cxe{FB9vpN)@`nP0#U@;lu2?*B-%{b0C3xtzM{s-fRFs#Fr0uMN!0-SZ^y@=g#~EzexeohU zw~Ij+PF+uMKZdn8!c7Ad=J9x{DHW}N_2VbShlFzfNVuIv5S~qC6X;Dusqodrd<)ad z{DRgR@g@Df%;Rw@pPi;Mdskw_9>7W)t4 WwRb;kH#xHa0000 - - - - - - - - diff --git a/src/components/cauldrons/CauldronCardItem.vue b/src/components/cauldrons/CauldronCardItem.vue index b7f7a4d31..b1ed219fa 100644 --- a/src/components/cauldrons/CauldronCardItem.vue +++ b/src/components/cauldrons/CauldronCardItem.vue @@ -82,7 +82,6 @@ export default { data() { return { elixirPotions: [43, 44], - pillsPoints: [45], }; }, diff --git a/src/components/cauldrons/RewardInfo.vue b/src/components/cauldrons/RewardInfo.vue index 900ede1e6..a2a659f1d 100644 --- a/src/components/cauldrons/RewardInfo.vue +++ b/src/components/cauldrons/RewardInfo.vue @@ -20,13 +20,6 @@ -
-
-
Pills Multiplier
-
1x - 6.3x
-
-
-
{{ loopApr }}
@@ -53,7 +46,6 @@ export default { data() { return { elixirPotions: [43, 44], - pillsPoints: [45], }; }, @@ -65,13 +57,6 @@ export default { ); }, - isPillsPoints() { - return ( - this.cauldron.config.chainId === MAINNET_CHAIN_ID && - this.pillsPoints.includes(this.cauldron.config.id) - ); - }, - loopApr(): string { if (!this.cauldron.apr.value) return "-"; diff --git a/src/components/market/DynamicPillsMultiplier.vue b/src/components/market/DynamicPillsMultiplier.vue deleted file mode 100644 index 29e29faf7..000000000 --- a/src/components/market/DynamicPillsMultiplier.vue +++ /dev/null @@ -1,93 +0,0 @@ - - - - - diff --git a/src/components/market/LeverageBlock.vue b/src/components/market/LeverageBlock.vue index 9449e108d..dae3384ae 100644 --- a/src/components/market/LeverageBlock.vue +++ b/src/components/market/LeverageBlock.vue @@ -27,8 +27,6 @@ v-if="hasElixirPotions" /> - - import("@/components/market/DynamicElixirPotionsMultiplier.vue") ), - DynamicPillsMultiplier: defineAsyncComponent( - () => import("@/components/market/DynamicPillsMultiplier.vue") - ), }, }; diff --git a/src/components/market/MarketHead.vue b/src/components/market/MarketHead.vue index d22d44c72..4722c1c2f 100644 --- a/src/components/market/MarketHead.vue +++ b/src/components/market/MarketHead.vue @@ -134,7 +134,6 @@ export default { potionText() { if (this.cauldron.config.cauldronSettings.hasElixirPotions) return "Earning Elixir Potions"; - if (this.cauldron.config.cauldronSettings.isUSD0) return "Earning Pills"; return ""; }, diff --git a/src/components/pools/PoolListCard.vue b/src/components/pools/PoolListCard.vue index 4b6ff4047..189a81976 100644 --- a/src/components/pools/PoolListCard.vue +++ b/src/components/pools/PoolListCard.vue @@ -128,23 +128,6 @@
5x Multiplier
- - @@ -242,10 +225,6 @@ export default { isElixir() { return this.pool.config.id === 1 && this.pool.config.chainId === 1; }, - - isPillsPotions() { - return this.pool.config.id === 2 && this.pool.config.chainId === 1; - }, }, methods: { diff --git a/src/components/pools/pool/PillsPotions.vue b/src/components/pools/pool/PillsPotions.vue deleted file mode 100644 index 7df0bae15..000000000 --- a/src/components/pools/pool/PillsPotions.vue +++ /dev/null @@ -1,90 +0,0 @@ - - - - - diff --git a/src/components/pools/pool/TokenPair.vue b/src/components/pools/pool/TokenPair.vue index d91efbbda..ccdd371f9 100644 --- a/src/components/pools/pool/TokenPair.vue +++ b/src/components/pools/pool/TokenPair.vue @@ -26,10 +26,6 @@

{{ pool.name }}

-
- - 1x Multiplier -
Deprecated
@@ -92,12 +88,6 @@ export default { quoteTokenConfig() { return this.pool.tokens.quoteToken.config; }, - - isPillsLabel() { - return ( - this.pool.config.settings.rewardPointsType === "pills" && this.isLabal - ); - }, }, methods: { getChainIcon }, @@ -164,31 +154,4 @@ export default { text-align: start; min-width: 110px; } - -.pills-wrap { - border-radius: 33px; - border: 1px solid var(--Primary-Gradient, #2d4a96); - background: linear-gradient(90deg, #1c2b53 0%, #303063 100%), - linear-gradient( - 90deg, - rgba(45, 74, 150, 0.12) 0%, - rgba(116, 92, 210, 0.12) 100% - ); - display: flex; - padding: 2px 5px; - align-items: flex-start; - gap: 4px; - - font-size: 14px; - font-style: normal; - font-weight: 500; - line-height: normal; - min-width: 120px; -} - -@media screen and (max-width: 600px) { - .pills-wrap { - display: none; - } -} diff --git a/src/components/pools/pool/position/Deposited.vue b/src/components/pools/pool/position/Deposited.vue index 34ceef710..c6bd8e444 100644 --- a/src/components/pools/pool/position/Deposited.vue +++ b/src/components/pools/pool/position/Deposited.vue @@ -159,7 +159,6 @@ export default { }, rewardTitle() { - if (this.rewardPointsType === "pills") return "Earning Rewards"; return "Staking Rewards"; }, }, @@ -292,41 +291,4 @@ export default { font-weight: 600; text-shadow: 0px 0px 16px #ab5de8; } - -.pills-rewards { - gap: 8px; - display: flex; - flex-direction: column; - color: #fff; -} - -.pills-title { - font-size: 18px; - font-weight: 500; - line-height: normal; -} - -.pills-row { - display: flex; - justify-content: space-between; - align-items: center; - background: linear-gradient(270deg, #915eff -3.8%, #d040c6 100%); - background-clip: text; - -webkit-background-clip: text; - -webkit-text-fill-color: transparent; - text-align: center; - font-weight: 500; - line-height: normal; -} - -.pills-icon-wrap { - gap: 4px; - display: flex; - align-items: center; -} - -.pills-icon { - width: 24px; - height: 24px; -} diff --git a/src/components/pools/rewardPoints/RewardPointsTagWrap.vue b/src/components/pools/rewardPoints/RewardPointsTagWrap.vue index d7e6b897b..1d61c9a04 100644 --- a/src/components/pools/rewardPoints/RewardPointsTagWrap.vue +++ b/src/components/pools/rewardPoints/RewardPointsTagWrap.vue @@ -7,13 +7,6 @@ :card="card" v-if="rewardPointsType === RewardPointsTypes.Elixir" /> - @@ -41,9 +34,6 @@ export default { ElixirRewardTag: defineAsyncComponent( () => import("@/components/pools/rewardPoints/elixir/ElixirRewardTag.vue") ), - PillsRewardTag: defineAsyncComponent( - () => import("@/components/pools/rewardPoints/pills/PillsRewardTag.vue") - ), }, }; diff --git a/src/components/pools/rewardPoints/pills/PillsBanner.vue b/src/components/pools/rewardPoints/pills/PillsBanner.vue deleted file mode 100644 index eac1fc742..000000000 --- a/src/components/pools/rewardPoints/pills/PillsBanner.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - - - diff --git a/src/components/pools/rewardPoints/pills/PillsRewardTag.vue b/src/components/pools/rewardPoints/pills/PillsRewardTag.vue deleted file mode 100644 index 89efc464a..000000000 --- a/src/components/pools/rewardPoints/pills/PillsRewardTag.vue +++ /dev/null @@ -1,53 +0,0 @@ - - - - - diff --git a/src/configs/pools/ethereumPools.ts b/src/configs/pools/ethereumPools.ts index 234345d75..fac4c3e6a 100644 --- a/src/configs/pools/ethereumPools.ts +++ b/src/configs/pools/ethereumPools.ts @@ -87,7 +87,6 @@ const ethereumPools: Array = [ isNew: false, isDeprecated: false, isMim: true, - rewardPointsType: RewardPointsTypes.Pills, }, initialParameters: { I: 1000000000000000000n, diff --git a/src/configs/pools/types.ts b/src/configs/pools/types.ts index 281439c2d..31ee4cb5d 100644 --- a/src/configs/pools/types.ts +++ b/src/configs/pools/types.ts @@ -60,5 +60,4 @@ export type TokenConfig = { export enum RewardPointsTypes { Elixir = "elixir", - Pills = "pills", } diff --git a/src/helpers/getTokenLinkData.ts b/src/helpers/getTokenLinkData.ts index e536aad26..a0112fc6a 100644 --- a/src/helpers/getTokenLinkData.ts +++ b/src/helpers/getTokenLinkData.ts @@ -125,7 +125,7 @@ const configs = [ chain: 1, href: "https://app.usual.money/", label: "Get USD0++ Token", - icon: useImage(`assets/images/pools/rewards/pills-icon.svg`), + icon: useImage(`assets/images/tokens/USD0pp.png`), }, ]; From af93630e84047e8df67d95b47935a45025b4f31e Mon Sep 17 00:00:00 2001 From: 0xmDreamy <0xmDreamy@proton.me> Date: Fri, 3 Jan 2025 22:55:30 +0100 Subject: [PATCH 3/3] consider magicusd0++ fee --- src/helpers/collateralsApy/getUsd0ppApy.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/helpers/collateralsApy/getUsd0ppApy.ts b/src/helpers/collateralsApy/getUsd0ppApy.ts index 0c21b55f4..afea91893 100644 --- a/src/helpers/collateralsApy/getUsd0ppApy.ts +++ b/src/helpers/collateralsApy/getUsd0ppApy.ts @@ -2,19 +2,30 @@ import axios from "axios"; import { formatToFixed } from "@/helpers/filters"; import { getCoinsPrices } from "@/helpers/prices/defiLlama"; import { mainnet } from "viem/chains"; -import { type Address, formatEther } from "viem"; +import { type Address, formatEther, type PublicClient, parseAbi } from "viem"; +import { getPublicClient } from "@/helpers/chains/getChainsInfo"; const usualAddress = "0xC4441c2BE5d8fA8126822B9929CA0b81Ea0DE38E" as const satisfies Address; const usd0ppAddress = "0x35D8949372D46B7a3D5A56006AE77B215fc69bC0" as const satisfies Address; +const magicUsd0ppHarvesterAddress = "0x80014629Ca75441599A1efd2283E3f71A8EC0AAB" as const satisfies Address; + +const feeCollectableAbi = parseAbi(["function feeBips() view returns (uint256)"]); + const usualChainId = mainnet.id; const endpoint = "https://api.0xdreamy.dev/functions/v1/usd0pp-rewards"; // Wraps https://app.usual.money/api/rewards/rates + export const getUsd0ppApy = async (): Promise => { try { - const [prices, { data }] = await Promise.all([ + const [prices, { data }, feeBips] = await Promise.all([ getCoinsPrices(usualChainId, [usualAddress, usd0ppAddress]), await axios.get(endpoint), + (getPublicClient(usualChainId) as PublicClient).readContract({ + abi: feeCollectableAbi, + address: magicUsd0ppHarvesterAddress, + functionName: "feeBips", + }), ]); const usualPrice = prices?.[0]?.price; @@ -27,10 +38,13 @@ export const getUsd0ppApy = async (): Promise => { const usd0ppUsualRewards = Number( formatEther(BigInt(data?.["USD0++"] ?? "0")), ); + + const apr = usd0ppUsualRewards * usualPrice / usd0ppPrice; + const aprWithFee = apr * (1 - Number(feeBips) / 10_000); return Number( formatToFixed( - ((1 + usd0ppUsualRewards / usd0ppPrice * usualPrice) ** 365 - 1) * 100, + ((1 + aprWithFee) ** 365 - 1) * 100, 2, ), );