@@ -10,6 +10,7 @@ import {
1010 ERC4626__factory ,
1111 GasRouter__factory ,
1212 HypERC20 ,
13+ HypERC20Collateral ,
1314 HypERC20Collateral__factory ,
1415 HypERC20__factory ,
1516 HypERC4626 ,
@@ -375,8 +376,7 @@ export class EvmHypSyntheticAdapter
375376 }
376377}
377378
378- // Interacts with HypCollateral contracts
379- export class EvmHypCollateralAdapter
379+ class BaseEvmHypCollateralAdapter
380380 extends EvmHypSyntheticAdapter
381381 implements IHypTokenAdapter < PopulatedTransaction >
382382{
@@ -396,22 +396,9 @@ export class EvmHypCollateralAdapter
396396 }
397397
398398 async getWrappedTokenAddress ( ) : Promise < Address > {
399- if ( this . wrappedTokenAddress ) return this . wrappedTokenAddress ;
400-
401- const contractVersion = await this . getContractPackageVersion ( ) ;
402- const hasTokenFeeInterface = isValidContractVersion (
403- contractVersion ,
404- TOKEN_FEE_CONTRACT_VERSION ,
405- ) ;
406-
407- if ( ! hasTokenFeeInterface ) {
408- const erc20CollateralContract = HypERC20Collateral__factory . connect (
409- this . addresses . token ,
410- this . getProvider ( ) ,
411- ) ;
412- this . wrappedTokenAddress = await erc20CollateralContract . wrappedToken ( ) ;
413- } else this . wrappedTokenAddress = await this . collateralContract . token ( ) ;
414-
399+ if ( ! this . wrappedTokenAddress ) {
400+ this . wrappedTokenAddress = await this . collateralContract . token ( ) ;
401+ }
415402 return this . wrappedTokenAddress ! ;
416403 }
417404
@@ -470,6 +457,33 @@ export class EvmHypCollateralAdapter
470457 }
471458}
472459
460+ // Interacts with HypCollateral contracts
461+ export class EvmHypCollateralAdapter
462+ extends BaseEvmHypCollateralAdapter
463+ implements IHypTokenAdapter < PopulatedTransaction >
464+ {
465+ public readonly collateralContract : HypERC20Collateral ;
466+
467+ constructor (
468+ public readonly chainName : ChainName ,
469+ public readonly multiProvider : MultiProtocolProvider ,
470+ public readonly addresses : { token : Address } ,
471+ ) {
472+ super ( chainName , multiProvider , addresses ) ;
473+ this . collateralContract = HypERC20Collateral__factory . connect (
474+ addresses . token ,
475+ this . getProvider ( ) ,
476+ ) ;
477+ }
478+
479+ override async getWrappedTokenAddress ( ) : Promise < Address > {
480+ if ( ! this . wrappedTokenAddress ) {
481+ this . wrappedTokenAddress = await this . collateralContract . wrappedToken ( ) ;
482+ }
483+ return this . wrappedTokenAddress ! ;
484+ }
485+ }
486+
473487export class EvmMovableCollateralAdapter
474488 extends EvmHypCollateralAdapter
475489 implements IMovableCollateralRouterAdapter < PopulatedTransaction >
@@ -620,7 +634,7 @@ export class EvmHypCollateralFiatAdapter
620634}
621635
622636export class EvmHypRebaseCollateralAdapter
623- extends EvmHypCollateralAdapter
637+ extends BaseEvmHypCollateralAdapter
624638 implements IHypTokenAdapter < PopulatedTransaction >
625639{
626640 public override collateralContract : HypERC4626Collateral ;
@@ -637,6 +651,13 @@ export class EvmHypRebaseCollateralAdapter
637651 ) ;
638652 }
639653
654+ override async getWrappedTokenAddress ( ) : Promise < Address > {
655+ if ( ! this . wrappedTokenAddress ) {
656+ this . wrappedTokenAddress = await this . collateralContract . wrappedToken ( ) ;
657+ }
658+ return this . wrappedTokenAddress ! ;
659+ }
660+
640661 override async getBridgedSupply ( ) : Promise < bigint > {
641662 const vault = ERC4626__factory . connect (
642663 await this . collateralContract . vault ( ) ,
0 commit comments