1- import { EthAddress , AssetValue } from '@aztec/sdk' ;
1+ import { AssetValue , EthAddress } from '@aztec/sdk' ;
2+ import { StaticJsonRpcProvider } from '@ethersproject/providers' ;
23import 'isomorphic-fetch' ;
4+ import { IERC4626__factory , IERC20Metadata__factory } from '../../typechain-types/index.js' ;
35
4- import { StaticJsonRpcProvider } from '@ethersproject/providers' ;
56import { AuxDataConfig , AztecAsset , BridgeDataFieldGetters , SolidityType , UnderlyingAsset } from '../bridge-data.js' ;
67
78export class EulerRedemptionBridgeData implements BridgeDataFieldGetters {
89 protected constructor ( protected ethersProvider : StaticJsonRpcProvider ) { }
9- migrators = new Map < EthAddress , EthAddress > ( ) ; // Get contract addresses of the migrators
10-
10+ minTokenOut = {
11+ 0 : 99n * 10n ** 16n , // ETH
12+ 1 : 96n * 10n ** 16n , // DAI
13+ 2 : 99n * 10n ** 16n , // WSTETH
14+ 5 : 99n * 10n ** 16n , // weWETH
15+ 6 : 99n * 10n ** 16n , // weWSTETH
16+ 7 : 96n * 10n ** 16n , // weDAI
17+ } ;
1118 getInteractionPresentValue ?( interactionNonce : number , inputValue : bigint ) : Promise < AssetValue [ ] > {
1219 throw new Error ( 'Method not implemented.' ) ;
1320 }
@@ -19,7 +26,7 @@ export class EulerRedemptionBridgeData implements BridgeDataFieldGetters {
1926 outputAssetB : AztecAsset ,
2027 ) : Promise < bigint [ ] > {
2128 // Minimum of underlying token output per erc4626 input.
22- return [ 99n * 10n ** 16n ] ;
29+ return Promise . resolve ( [ this . minTokenOut [ outputAssetA . id ] ] ) ;
2330 }
2431
2532 auxDataConfig : AuxDataConfig [ ] = [
@@ -40,7 +47,7 @@ export class EulerRedemptionBridgeData implements BridgeDataFieldGetters {
4047 auxData : bigint ,
4148 inputValue : bigint ,
4249 ) : Promise < bigint [ ] > {
43- return [ ( inputValue * 99n ) / 100n ] ;
50+ return Promise . resolve ( [ ( inputValue * auxData ) / 10n ** 18n ] ) ;
4451 }
4552
4653 getExpiration ?( interactionNonce : number ) : Promise < bigint > {
@@ -51,26 +58,41 @@ export class EulerRedemptionBridgeData implements BridgeDataFieldGetters {
5158 throw new Error ( 'Method not implemented.' ) ;
5259 }
5360
54- getAPR ? ( yieldAsset : AztecAsset ) : Promise < number > {
55- return 0 ;
61+ getAPR ( yieldAsset : AztecAsset ) : Promise < number > {
62+ return Promise . resolve ( 0 ) ;
5663 }
5764
58- getMarketSize ? (
65+ getMarketSize (
5966 inputAssetA : AztecAsset ,
6067 inputAssetB : AztecAsset ,
6168 outputAssetA : AztecAsset ,
6269 outputAssetB : AztecAsset ,
6370 auxData : bigint ,
6471 ) : Promise < AssetValue [ ] > {
65- return [ { asset : inputAssetA , value : 0n } ] ;
72+ return Promise . resolve ( [ { assetId : inputAssetA . id , value : 0n } ] ) ;
6673 }
6774
6875 getInteractionAPR ?( interactionNonce : number ) : Promise < number [ ] > {
6976 throw new Error ( 'Method not implemented.' ) ;
7077 }
7178
72- getUnderlyingAmount ?( asset : AztecAsset , amount : bigint ) : Promise < UnderlyingAsset > {
73- throw new Error ( 'Method not implemented.' ) ;
79+ async getUnderlyingAmount ( share : AztecAsset , amount : bigint ) : Promise < UnderlyingAsset > {
80+ const vault = IERC4626__factory . connect ( share . erc20Address . toString ( ) , this . ethersProvider ) ;
81+ const assetAddress = EthAddress . fromString ( await vault . asset ( ) ) ;
82+
83+ const tokenContract = IERC20Metadata__factory . connect ( assetAddress . toString ( ) , this . ethersProvider ) ;
84+ const namePromise = tokenContract . name ( ) ;
85+ const symbolPromise = tokenContract . symbol ( ) ;
86+ const decimalsPromise = tokenContract . decimals ( ) ;
87+ const underlyingAmount = ( amount * this . minTokenOut [ share . id ] ) / 10n ** 18n ;
88+
89+ return {
90+ address : assetAddress ,
91+ name : await namePromise ,
92+ symbol : await symbolPromise ,
93+ decimals : await decimalsPromise ,
94+ amount : underlyingAmount ,
95+ } ;
7496 }
7597
7698 getTermAPR ?( underlying : AztecAsset , auxData : bigint , inputValue : bigint ) : Promise < number > {
0 commit comments