File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import type {
1212} from "../sdk" ;
1313import {
1414 ADDRESS_0X0 ,
15+ AddressMap ,
1516 childLogger ,
1617 formatBN ,
1718 iDegenNftv2Abi ,
@@ -69,9 +70,17 @@ export class AccountOpener {
6970 ) : Promise < CreditAccountData [ ] > {
7071 await this . #prepareBorrower( targets ) ;
7172
73+ const toApprove = new AddressMap < Set < Address > > ( ) ;
7274 for ( const c of targets ) {
7375 const cm = this . sdk . marketRegister . findCreditManager ( c . creditManager ) ;
74- await this . #approve( c . collateral , cm ) ;
76+ const toApproveOnCM = toApprove . get ( c . creditManager ) ?? new Set ( ) ;
77+ toApproveOnCM . add ( cm . underlying ) ;
78+ }
79+ for ( const [ cmAddr , tokens ] of toApprove . entries ( ) ) {
80+ const cm = this . sdk . marketRegister . findCreditManager ( cmAddr ) ;
81+ for ( const token of tokens ) {
82+ await this . #approve( token , cm ) ;
83+ }
7584 }
7685
7786 for ( let i = 0 ; i < targets . length ; i ++ ) {
You can’t perform that action at this time.
0 commit comments