11const utils = require ( '../utils' ) ;
22
3- const superagent = require ( 'superagent' ) ;
43const { request, gql } = require ( 'graphql-request' ) ;
5- const ethers = require ( 'ethers' ) ;
64const { default : BigNumber } = require ( 'bignumber.js' ) ;
75const sdk = require ( '@defillama/sdk' ) ;
86
@@ -50,60 +48,80 @@ const rtokenQuery = gql`
5048` ;
5149
5250const poolsMap = {
53- // Ethereum
54- '405d8dad-5c99-4c91-90d3-82813ade1ff1' : 'sadai' ,
55- 'a349fea4-d780-4e16-973e-70ca9b606db2' : 'sausdc' ,
56- '60d657c9-5f63-4771-a85b-2cf8d507ec00' : 'sausdt' ,
57- '1d53fa29-b918-4d74-9508-8fcf8173ca51' : 'sausdp' ,
58- 'cc110152-36c2-4e10-9c12-c5b4eb662143' : 'cdai' ,
59- 'cefa9bb8-c230-459a-a855-3b94e96acd8c' : 'cusdc' ,
60- '57647093-2868-4e65-97ab-9cae8ec74e7d' : 'cusdt' ,
61- '6c2b7a5c-6c4f-49ea-a08c-0366b772f2c2' : 'cusdp' ,
62- '1d876729-4445-4623-8b6b-c5290db5d100' : 'cwbtc' ,
63- '1e5da7c6-59bb-49bd-9f97-4f4fceeffad4' : 'ceth' ,
64- 'fa4d7ee4-0001-4133-9e8d-cf7d5d194a91' : 'fusdc' ,
65- 'ed227286-abb0-4a34-ada5-39f7ebd81afb' : 'fdai' ,
66- '6600934f-6323-447d-8a7d-67fbede8529d' : 'fusdt' ,
67- '747c1d2a-c668-4682-b9f9-296708a3dd90' : 'wsteth' ,
68- 'd4b3c522-6127-4b89-bedf-83641cdcd2eb' : 'reth' ,
69- '7da72d09-56ca-4ec5-a45f-59114353e487' : 'wcusdcv3' ,
70- '8a20c472-142c-4442-b724-40f2183c073e' : 'stkcvxmim-3lp3crv-f' ,
71- 'ad3d7253-fb8f-402f-a6f8-821bc0a055cb' : 'stkcvxcrv3crypto' ,
72- '7394f1bc-840a-4ff0-9e87-5e0ef932943a' : 'stkcvx3crv' ,
73- 'c04005c9-7e34-41a6-91c4-295834ed8ac0' : 'stkcvxeusd3crv-f' ,
74- '325ad2d6-70b1-48d7-a557-c2c99a036f87' : 'mrp-ausdc' ,
75- '1343a280-7812-4bc3-8f98-d1c37e11d271' : 'mrp-ausdt' ,
76- 'b8bcdf8e-96ed-40ca-a7aa-aa048b9874e5' : 'mrp-adai' ,
77- '7be52986-18c2-450f-b74b-d65fb1205bbf' : 'mrp-aweth' ,
78- 'ff61171d-d7b0-4989-816c-b9bf02a15f00' : 'mrp-awbtc' ,
79- 'eab8d63d-8a8f-48cb-8027-583508831d24' : 'mrp-asteth' ,
80- '0f45d730-b279-4629-8e11-ccb5cc3038b4' : 'cbeth' ,
81- 'c8a24fee-ec00-4f38-86c0-9f6daebc4225' : 'sdai' ,
82- '55de30c3-bf9f-4d4e-9e0b-536a8ef5ab35' : 'sfrax' ,
83- 'aa70268e-4b52-42bf-a116-608b370f9501' : 'saethusdc' ,
84- 'd118f505-e75f-4152-bad3-49a2dc7482bf' : 'saethpyusd' ,
85- '01146cce-9140-4e03-9a2e-82c99ccc42f1' : 'stkcvxpyusdusdc' ,
86- '77020688-e1f9-443c-9388-e51ace15cc32' : 'sfrxeth' ,
87- 'bf3815bb-1059-4f24-90a3-14998e8493fa' : 're7weth' ,
88- 'a3ffd3fe-b21c-44eb-94d5-22c80057a600' : 'stkcvxcrvusdusdt-f' ,
89- '755fcec6-f4fd-4150-9184-60f099206694' : 'stkcvxcrvusdusdc-f' ,
90- 'd1dacce1-7815-420c-bb6d-d3c4320e1b2a' : 'steakpyusd' ,
91- '043a8330-bc29-4164-aa1c-28de7bf87755' : 'bbusdt' ,
92- 'a44febf3-34f6-4cd5-8ab1-f246ebe49f9e' : 'steakusdc' ,
93- '74346f6f-c7ee-4506-a204-baf48e13decb' : 'stkcvxeth+eth-f' ,
94-
95- // Base
96- 'df65c4f4-e33a-481c-bac8-0c2252867c93' : 'wcusdbcv3' ,
97- '0c8567f8-ba5b-41ad-80de-00a71895eb19' : 'wcusdcv3' ,
98- '9d09b0be-f6c2-463a-ad2c-4552b3e12bd9' : 'wsgusdbc' ,
99- '7e0661bf-8cf3-45e6-9424-31916d4c7b84' : 'sabasusdc' ,
100- '833ec61b-f9e6-46ac-9eff-2785808b2389' : 'sabasusdbc' ,
101-
102- // Arbitrum
103- 'd9c395b9-00d0-4426-a6b3-572a6dd68e54' : 'wcusdcv3' ,
104- 'd9fa8e14-0447-4207-9ae8-7810199dfa1f' : 'saarbusdcn' ,
105- '3a6cc030-738d-4e19-8a40-e63e9c4d5a6f' : 'saarbusdt' ,
106- }
51+ ethereum : {
52+ 'acee1e4d-a73c-4e20-98f7-e87c13d446e4' : 'apxeth' ,
53+ '405d8dad-5c99-4c91-90d3-82813ade1ff1' : 'sadai' ,
54+ 'a349fea4-d780-4e16-973e-70ca9b606db2' : 'sausdc' ,
55+ '60d657c9-5f63-4771-a85b-2cf8d507ec00' : 'sausdt' ,
56+ '1d53fa29-b918-4d74-9508-8fcf8173ca51' : 'sausdp' ,
57+ 'cc110152-36c2-4e10-9c12-c5b4eb662143' : 'cdai' ,
58+ 'cefa9bb8-c230-459a-a855-3b94e96acd8c' : 'cusdc' ,
59+ '57647093-2868-4e65-97ab-9cae8ec74e7d' : 'cusdt' ,
60+ '6c2b7a5c-6c4f-49ea-a08c-0366b772f2c2' : 'cusdp' ,
61+ '1d876729-4445-4623-8b6b-c5290db5d100' : 'cwbtc' ,
62+ '1e5da7c6-59bb-49bd-9f97-4f4fceeffad4' : 'ceth' ,
63+ 'fa4d7ee4-0001-4133-9e8d-cf7d5d194a91' : 'fusdc' ,
64+ 'ed227286-abb0-4a34-ada5-39f7ebd81afb' : 'fdai' ,
65+ '6600934f-6323-447d-8a7d-67fbede8529d' : 'fusdt' ,
66+ '747c1d2a-c668-4682-b9f9-296708a3dd90' : 'wsteth' ,
67+ 'd4b3c522-6127-4b89-bedf-83641cdcd2eb' : 'reth' ,
68+ '7da72d09-56ca-4ec5-a45f-59114353e487' : 'wcusdcv3' ,
69+ 'f4d5b566-e815-4ca2-bb07-7bcd8bc797f1' : 'wcusdtv3' ,
70+ '8a20c472-142c-4442-b724-40f2183c073e' : 'stkcvxmim-3lp3crv-f' ,
71+ 'ad3d7253-fb8f-402f-a6f8-821bc0a055cb' : 'stkcvxcrv3crypto' ,
72+ '7394f1bc-840a-4ff0-9e87-5e0ef932943a' : 'stkcvx3crv' ,
73+ 'c04005c9-7e34-41a6-91c4-295834ed8ac0' : 'stkcvxeusd3crv-f' ,
74+ '325ad2d6-70b1-48d7-a557-c2c99a036f87' : 'mrp-ausdc' ,
75+ '1343a280-7812-4bc3-8f98-d1c37e11d271' : 'mrp-ausdt' ,
76+ 'b8bcdf8e-96ed-40ca-a7aa-aa048b9874e5' : 'mrp-adai' ,
77+ '7be52986-18c2-450f-b74b-d65fb1205bbf' : 'mrp-aweth' ,
78+ 'ff61171d-d7b0-4989-816c-b9bf02a15f00' : 'mrp-awbtc' ,
79+ 'eab8d63d-8a8f-48cb-8027-583508831d24' : 'mrp-asteth' ,
80+ '0f45d730-b279-4629-8e11-ccb5cc3038b4' : 'cbeth' ,
81+ 'c8a24fee-ec00-4f38-86c0-9f6daebc4225' : 'sdai' ,
82+ '55de30c3-bf9f-4d4e-9e0b-536a8ef5ab35' : 'sfrax' ,
83+ 'aa70268e-4b52-42bf-a116-608b370f9501' : 'saethusdc' ,
84+ 'd118f505-e75f-4152-bad3-49a2dc7482bf' : 'saethpyusd' ,
85+ '01146cce-9140-4e03-9a2e-82c99ccc42f1' : 'stkcvxpyusdusdc' ,
86+ '5b3aebb3-891d-47fc-92e2-927ada3d5b82' : 'sfrxeth' ,
87+ 'bf3815bb-1059-4f24-90a3-14998e8493fa' : 're7weth' ,
88+ 'a3ffd3fe-b21c-44eb-94d5-22c80057a600' : 'stkcvxcrvusdusdt-f' ,
89+ '755fcec6-f4fd-4150-9184-60f099206694' : 'stkcvxcrvusdusdc-f' ,
90+ 'd1dacce1-7815-420c-bb6d-d3c4320e1b2a' : 'steakpyusd' ,
91+ '043a8330-bc29-4164-aa1c-28de7bf87755' : 'bbusdt' ,
92+ 'a44febf3-34f6-4cd5-8ab1-f246ebe49f9e' : 'steakusdc' ,
93+ '152b7ce2-7193-475d-9b15-3f17fee66047' : 'stkcvxeth+eth' ,
94+ '74346f6f-c7ee-4506-a204-baf48e13decb' : 'stkcvxeth+eth-f' ,
95+ '66985a81-9c51-46ca-9977-42b4fe7bc6df' : 'susde' ,
96+ '90bfb3c2-5d35-4959-a275-ba5085b08aa3' : 'ethx' ,
97+ 'd8c4eff5-c8a9-46fc-a888-057c4c668e72' : 'susds' ,
98+ '423681e3-4787-40ce-ae43-e9f67c5269b3' : 'woeth' ,
99+ 'f981a304-bb6c-45b8-b0c5-fd2f515ad23a' : 'saethusdt' ,
100+ '85fc6934-c94d-4ebe-9c60-66beb363669f' : 'saethrlusd' ,
101+ } ,
102+ base : {
103+ 'df65c4f4-e33a-481c-bac8-0c2252867c93' : 'wcusdbcv3' ,
104+ '0c8567f8-ba5b-41ad-80de-00a71895eb19' : 'wcusdcv3' ,
105+ '9d09b0be-f6c2-463a-ad2c-4552b3e12bd9' : 'wsgusdbc' ,
106+ '7e0661bf-8cf3-45e6-9424-31916d4c7b84' : 'sabasusdc' ,
107+ '833ec61b-f9e6-46ac-9eff-2785808b2389' : 'sabasusdbc' ,
108+ 'b90eba2e-ed29-414e-b16d-82f9c3eae707' : 'meusd' ,
109+ 'bde35fef-649f-4514-a564-e7e7da05eb52' : 'wsamm-eusd/usdc' ,
110+ '69c0fc74-dee5-4c60-9aed-a593661d54ea' : 'wvamm-weth/aero' ,
111+ '7b542141-5eed-4d70-bee6-0f9733beb362' : 'wvamm-mog/weth' ,
112+ 'be8a4206-6543-4690-a5c2-b3e032245aa2' : 'wsamm-usdz/usdc' ,
113+ '593056a0-1e39-451d-acc8-081526625ab3' : 'wvamm-weth/cbbtc' ,
114+ '8af246ee-cf26-4c8e-88f8-f2021a69e44d' : 'wvamm-weth/well' ,
115+ '7e15dae2-ba5c-4658-b1a2-efb908a15200' : 'wvamm-weth/degen' ,
116+ 'f388573e-5c0f-4dac-9f70-116a4aabaf17' : 'wsuperoethb' ,
117+ } ,
118+ arbitrum : {
119+ 'd9c395b9-00d0-4426-a6b3-572a6dd68e54' : 'wcusdcv3' ,
120+ '85247b13-8180-44e7-b38c-4d324cc68a92' : 'wcusdtv3' ,
121+ 'd9fa8e14-0447-4207-9ae8-7810199dfa1f' : 'saarbusdcn' ,
122+ '3a6cc030-738d-4e19-8a40-e63e9c4d5a6f' : 'saarbusdt' ,
123+ } ,
124+ } ;
107125
108126const rtokenTvl = ( rtoken ) =>
109127 ( rtoken . token ?. totalSupply / 1e18 ) * rtoken . token ?. lastPriceUSD || 0 ;
@@ -113,20 +131,20 @@ const apyChain = async (chainProps) => {
113131 const poolsData = ( await utils . getData ( 'https://yields.llama.fi/pools' ) )
114132 ?. data ;
115133
116- const poolsInfo = ( poolsData || [ ] )
117- . filter ( ( pool ) => poolsMap [ pool . pool ] )
118- . reduce ( ( acc , pool ) => {
119- const chain = pool . chain . toLowerCase ( )
120- const poolsByChain = acc [ chain ] || { }
121- acc [ chain ] = {
122- ...poolsByChain ,
123- [ poolsMap [ pool . pool ] ] : {
124- yield : pool . apyMean30d || 0 ,
125- underlyings : pool . underlyingTokens ,
126- } ,
127- }
128- return acc
129- } , { } )
134+ const poolsInfo = ( poolsData || [ ] )
135+ . filter ( ( pool ) => chains . some ( ( chain ) => poolsMap [ chain . chainName ] [ pool . pool ] ) )
136+ . reduce ( ( acc , pool ) => {
137+ const chain = pool . chain . toLowerCase ( )
138+ const poolsByChain = acc [ chain ] || { }
139+ acc [ chain ] = {
140+ ...poolsByChain ,
141+ [ poolsMap [ chain ] [ pool . pool ] ] : {
142+ yield : pool . apyMean30d || 0 ,
143+ underlyings : pool . underlyingTokens ,
144+ } ,
145+ }
146+ return acc
147+ } , { } )
130148
131149 const { rtokens } = await request ( graph , rtokenQuery ) ;
132150
@@ -172,6 +190,13 @@ const poolsInfo = (poolsData || [])
172190 } ) ) ,
173191 } ) ;
174192
193+ const fallbackPools = Object . values ( poolsInfo ) . reduce ( ( acc , pools ) => {
194+ Object . keys ( pools ) . forEach ( ( pool ) => {
195+ acc [ pool ] = pools [ pool ]
196+ } )
197+ return acc
198+ } ) ;
199+
175200 const reservePools = Promise . all (
176201 filteredRtokens . map ( async ( rtoken , i ) => {
177202 if ( ! rtoken ) return null ;
@@ -184,13 +209,6 @@ const poolsInfo = (poolsData || [])
184209 params : [ ] ,
185210 } ) ) ,
186211 } ) ;
187-
188- const fallbackPools = Object . values ( poolsInfo ) . reduce ( ( acc , pools ) => {
189- Object . keys ( pools ) . forEach ( ( pool ) => {
190- acc [ pool ] = pools [ pool ]
191- } )
192- return acc
193- } )
194212
195213 let apyBase = BigNumber ( 0 ) ;
196214 let totalShares = BigNumber ( 0 ) ;
@@ -227,7 +245,7 @@ const poolsInfo = (poolsData || [])
227245 apyReward : 0 ,
228246 rewardTokens : [ ] ,
229247 underlyingTokens : underlyingTokens ,
230- url : `https://register. app/#/overview? token= ${ rtoken . id } ` ,
248+ url : `https://app.reserve.org/ ${ chainName } / token/ ${ rtoken . id } /overview ` ,
231249 } ;
232250 } )
233251 ) ;
0 commit comments