@@ -64,23 +64,23 @@ export const getMainnetPrice = async (
6464 const priceEntry = priceMap [ `${ base } _${ quote } ` ]
6565 if ( priceEntry ) {
6666 const [ getPrice , decimals ] = priceEntry
67- return [ await getPrice ( ctx , block . height ) , decimals ]
67+ return [ await getPrice ( ctx , block ) , decimals ]
6868 }
6969 throw new Error ( `No price for ${ base } _${ quote } ` )
7070}
7171
72- const getOETHETHPrice = async ( ctx : Context , height : number ) => {
73- if ( height < 17230232 ) return 10n ** 18n
74- if ( height < 19384550 ) {
75- const contract = new curveLpToken . Contract ( ctx , { height } , CURVE_ETH_OETH_POOL_ADDRESS )
72+ const getOETHETHPrice = async ( ctx : Context , block : Block [ 'header' ] ) => {
73+ if ( block . height < 17230232 ) return 10n ** 18n
74+ if ( block . height < 19384550 ) {
75+ const contract = new curveLpToken . Contract ( ctx , { height : block . height } , CURVE_ETH_OETH_POOL_ADDRESS )
7676 return await contract . get_dy ( 0n , 1n , 1000000000000000000n )
7777 }
78- return chainlinkPriceFeeds [ 'OETH_ETH' ] ! . get ( ctx , height )
78+ return chainlinkPriceFeeds [ 'OETH_ETH' ] ! . get ( ctx , block . height )
7979}
8080
81- const getETHOETHPrice = async ( ctx : Context , height : number ) => {
82- if ( height < 17230232 ) return 10n ** 18n
83- const contract = new curveLpToken . Contract ( ctx , { height } , CURVE_ETH_OETH_POOL_ADDRESS )
81+ const getETHOETHPrice = async ( ctx : Context , block : Block [ 'header' ] ) => {
82+ if ( block . height < 17230232 ) return 10n ** 18n
83+ const contract = new curveLpToken . Contract ( ctx , { height : block . height } , CURVE_ETH_OETH_POOL_ADDRESS )
8484 return await contract . get_dy ( 1n , 0n , 1000000000000000000n )
8585}
8686
@@ -240,10 +240,10 @@ export const twoWay = <Base extends MainnetCurrencySymbol, Quote extends Mainnet
240240 async ( ctx : Context , block : Block [ 'header' ] ) => getPrice ( ctx , block ) . then ( ( rate ) => invertRate ( rate , decimals ) ) ,
241241 decimals ,
242242 ] ,
243- } ) as Record < `${ Base } _${ Quote } ` | `${ Quote } _${ Base } ` , [ ( ctx : Context , height : number ) => Promise < bigint > , number ] >
243+ } ) as const
244244
245245export const priceMap : Partial <
246- Record < `${CurrencySymbol } _${CurrencySymbol } `, [ ( ctx : Context , height : number ) => Promise < bigint > , number ] >
246+ Record < `${CurrencySymbol } _${CurrencySymbol } `, [ ( ctx : Context , block : Block [ 'header' ] ) => Promise < bigint > , number ] >
247247> = {
248248 ETH_WETH : [ async ( ) => 1_000_000_000_000_000_000n , 18 ] ,
249249 WETH_ETH : [ async ( ) => 1_000_000_000_000_000_000n , 18 ] ,
0 commit comments