Skip to content

Commit 69e514b

Browse files
committed
fix: give less approvals
1 parent 95c54b1 commit 69e514b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/dev/AccountOpener.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export class AccountOpener {
6666
*/
6767
public async openCreditAccounts(targets: TargetAccount[]): Promise<void> {
6868
const borrower = await this.#prepareBorrower(targets);
69+
70+
for (const c of targets) {
71+
const cm = this.sdk.marketRegister.findCreditManager(c.creditManager);
72+
await this.#approve(c.collateral, cm);
73+
}
74+
6975
for (const target of targets) {
7076
try {
7177
await this.#openAccount(target);
@@ -203,10 +209,6 @@ export class AccountOpener {
203209
if (isAddress(degenNFT) && degenNFT !== ADDRESS_0X0) {
204210
degenNFTS[degenNFT] = (degenNFTS[degenNFT] ?? 0) + 1;
205211
}
206-
207-
for (const t of Object.keys(cm.collateralTokens)) {
208-
await this.#approve(t as Address, cm);
209-
}
210212
}
211213
claimUSD = (claimUSD * 11n) / 10n; // 10% more to be safe
212214

0 commit comments

Comments
 (0)