@@ -99,15 +99,14 @@ export const processOTokenDailyStats = async (
9999 otokenObject ,
100100 apy ,
101101 rebases ,
102+ peg ,
102103 rateETH ,
103104 rateUSD ,
105+ rateNative ,
104106 dripperWETH ,
105107 amoSupply ,
106108 wrappedSupply ,
107109 wrappedRate ,
108- rateNative ,
109- urateETH ,
110- urateUSD ,
111110 ] = await Promise . all ( [
112111 ( async ( ) => {
113112 let otokenObject = findLast ( params . otokens , ( o ) => o . timestamp <= blockDate )
@@ -150,28 +149,37 @@ export const processOTokenDailyStats = async (
150149 )
151150 return rebases
152151 } ) ( ) ,
153- ensureExchangeRate ( ctx , block , params . otokenAddress as CurrencyAddress , 'ETH' ) . then ( ( a ) => a ?. rate ?? 0n ) ,
154- ensureExchangeRate ( ctx , block , params . otokenAddress as CurrencyAddress , 'USD' ) . then ( ( a ) => a ?. rate ?? 0n ) ,
155- getDripperAvailableFunds ( ) ,
156- params . getAmoSupply ( ctx , block . header . height ) ,
157- wotokenContract ? wotokenContract . totalSupply ( ) : 0n ,
158- wotokenContract ? wotokenContract . previewRedeem ( 10n ** 18n ) : 0n ,
152+ // peg: OToken → underlying (e.g., OETH→ETH, OUSD→USD, OS→S)
159153 ensureExchangeRate (
160154 ctx ,
161155 block ,
162156 params . otokenAddress as CurrencyAddress ,
163- ctx . chain . nativeCurrency . symbol as Currency ,
157+ ( underlyingSymbol === 'ETH' || underlyingSymbol === 'USD' )
158+ ? underlyingSymbol as Currency
159+ : ctx . chain . nativeCurrency . symbol as Currency ,
164160 ) . then ( ( a ) => a ?. rate ?? 0n ) ,
161+ // rateETH: underlying → ETH
165162 underlyingSymbol === 'ETH'
166163 ? 10n ** 18n
167164 : ensureExchangeRate ( ctx , block , underlyingSymbol as CurrencyAddress , 'ETH' ) . then (
168165 ( a ) => ( a ? a . rate * 10n ** BigInt ( 18 - a . decimals ) : 0n ) ,
169166 ) ,
167+ // rateUSD: underlying → USD
170168 underlyingSymbol === 'USD'
171169 ? 10n ** 18n
172170 : ensureExchangeRate ( ctx , block , underlyingSymbol as CurrencyAddress , 'USD' ) . then (
173171 ( a ) => ( a ? a . rate * 10n ** BigInt ( 18 - a . decimals ) : 0n ) ,
174172 ) ,
173+ // rateNative: underlying → chain native currency
174+ underlyingSymbol === ctx . chain . nativeCurrency . symbol
175+ ? 10n ** 18n
176+ : ensureExchangeRate ( ctx , block , underlyingSymbol as CurrencyAddress , ctx . chain . nativeCurrency . symbol as Currency ) . then (
177+ ( a ) => ( a ? a . rate * 10n ** BigInt ( 18 - a . decimals ) : 0n ) ,
178+ ) ,
179+ getDripperAvailableFunds ( ) ,
180+ params . getAmoSupply ( ctx , block . header . height ) ,
181+ wotokenContract ? wotokenContract . totalSupply ( ) : 0n ,
182+ wotokenContract ? wotokenContract . previewRedeem ( 10n ** 18n ) : 0n ,
175183 ] )
176184 if ( process . env . DEBUG_PERF === 'true' ) {
177185 ctx . log . info ( `getOTokenDailyStat async calls took ${ Date . now ( ) - asyncStartTime } ms` )
@@ -218,11 +226,10 @@ export const processOTokenDailyStats = async (
218226 entity . cumulativeYield = ( last ?. cumulativeYield ?? 0n ) + entity . yield
219227 entity . cumulativeFees = ( last ?. cumulativeFees ?? 0n ) + entity . fees
220228
229+ entity . peg = peg
221230 entity . rateETH = rateETH
222231 entity . rateUSD = rateUSD
223232 entity . rateNative = rateNative
224- entity . urateETH = urateETH
225- entity . urateUSD = urateUSD
226233 entity . amoSupply = amoSupply
227234
228235 entity . dripperWETH = dripperWETH
@@ -263,11 +270,10 @@ export const getOTokenDailyStat = async (
263270 apy14 : 0 ,
264271 apy30 : 0 ,
265272
273+ peg : 0n ,
266274 rateUSD : 0n ,
267275 rateETH : 0n ,
268276 rateNative : 0n ,
269- urateUSD : 0n ,
270- urateETH : 0n ,
271277
272278 totalSupply : 0n ,
273279 rebasingSupply : 0n ,
0 commit comments