11import {
2- // ERC20_2612Service,
2+ ERC20_2612Service ,
33 ERC20Service ,
44 EthereumTransactionTypeExtended ,
55 V3MigrationHelperService ,
@@ -18,6 +18,7 @@ import { selectedUserReservesForMigration } from './v3MigrationSelectors';
1818export type V3MigrationSlice = {
1919 //STATE
2020 selectedMigrationAssets : Record < string , boolean > ;
21+ migrationServiceInstances : Record < string , V3MigrationHelperService > ;
2122 timestamp : number ;
2223 // ACTIONS
2324 generatePermitPayloadForMigrationAsset : (
@@ -45,6 +46,7 @@ export const createV3MigrationSlice: StateCreator<
4546> = ( set , get ) => {
4647 return {
4748 selectedMigrationAssets : { } ,
49+ migrationServiceInstances : { } ,
4850 timestamp : 0 ,
4951 generatePermitPayloadForMigrationAsset : async ( { amount, underlyingAsset, deadline } ) => {
5052 const user = get ( ) . account ;
@@ -121,7 +123,7 @@ export const createV3MigrationSlice: StateCreator<
121123 const selectedReservers = selectedUserReservesForMigration ( get ( ) , get ( ) . timestamp ) ;
122124 const permits = selectedReservers . map ( ( { reserve } , index ) => ( {
123125 aToken : reserve . aTokenAddress ,
124- value : reserve . totalLiquidity ,
126+ value : reserve . totalLiquidity + 1000 ,
125127 deadline,
126128 signedPermit : signatures [ index ] ,
127129 } ) ) ;
@@ -141,7 +143,16 @@ export const createV3MigrationSlice: StateCreator<
141143 return '0x01ce9bbcc0418614a8bba983fe79cf77211996f2' ;
142144 } ,
143145 getMigrationServiceInstance : ( ) => {
144- return new V3MigrationHelperService ( get ( ) . jsonRpcProvider ( ) , get ( ) . getMigratorAddress ( ) ) ;
146+ const address = get ( ) . getMigratorAddress ( ) ;
147+ const migratorInstance = get ( ) . migrationServiceInstances [ address ] ;
148+ if ( migratorInstance ) {
149+ return migratorInstance ;
150+ }
151+ const provider = get ( ) . jsonRpcProvider ( ) ;
152+ const migratorAddress = get ( ) . getMigratorAddress ( ) ;
153+ const newMigratorInstance = new V3MigrationHelperService ( provider , migratorAddress ) ;
154+ // TODO: don't forget to add maping here
155+ return newMigratorInstance ;
145156 } ,
146157 _testMigration : async ( ) => {
147158 const someAddress = await get ( ) . getMigrationServiceInstance ( ) . testDeployment ( ) ;
0 commit comments