Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
[Dump Script] Approve tokens without waiting for prior confirmation (#…
Browse files Browse the repository at this point in the history
…983)

When dumping a lot of tokens it can take quite some time before all approvals are mined. The current behaviour waits for one approval to be mined before issuing the next one.

This PR changes the logic to issue multiple transactions in parallel (while manually doing nonce management). This leads to much shorter runtime for the run script when using it for ~100 tokens.

### Test Plan

Ran it a few times locally while dumping tokens today.
  • Loading branch information
fleupold committed Mar 2, 2022
1 parent 4a51c1d commit da33a66
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/tasks/dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,18 +504,19 @@ async function createAllowances(
{ gasEstimator, requiredConfirmations }: CreateAllowancesOptions,
) {
let lastTransaction: ContractTransaction | undefined = undefined;
let current_nonce = await signer.getTransactionCount();
for (const token of allowances) {
console.log(
`Approving vault relayer to trade token ${displayName(token)}...`,
);
const fee = await gasEstimator.txGasPrice();
lastTransaction = (await token.contract
.connect(signer)
.approve(
vaultRelayer,
constants.MaxUint256,
await gasEstimator.txGasPrice(),
)) as ContractTransaction;
await lastTransaction.wait();
.approve(vaultRelayer, constants.MaxUint256, {
nonce: current_nonce,
...fee,
})) as ContractTransaction;
current_nonce++;
}
if (lastTransaction !== undefined) {
// note: the last approval is (excluded reorgs) the last that is included
Expand Down

0 comments on commit da33a66

Please sign in to comment.