Skip to content

Commit

Permalink
get dust for multiple claims
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Jun 28, 2024
1 parent eec0a6c commit b66de94
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
8 changes: 8 additions & 0 deletions gas-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Summary:
│ Claiming FRI (FeeToken: FRI) │ '1.188.000.000.192' │ 0 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │
│ Claiming external FRI (FeeToken: FRI) │ '1.620.000.000.256' │ 0 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │
│ Get dust FRI (FeeToken: FRI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │
│ Get dust 2 (FeeToken: WEI) │ '2.772.000.000.320' │ 0.011 │ 2772000000000 │ 77 │ 71 │ 3 │ 4 │ 'steps' │ 5 │ 320 │ 'BLOB' │
│ Get dust 3 (FeeToken: WEI) │ '3.960.000.000.384' │ 0.0158 │ 3960000000000 │ 110 │ 101 │ 4 │ 6 │ 'steps' │ 6 │ 384 │ 'BLOB' │
│ Get dust 4 (FeeToken: WEI) │ '5.112.000.000.448' │ 0.0204 │ 5112000000000 │ 142 │ 130 │ 5 │ 8 │ 'steps' │ 7 │ 448 │ 'BLOB' │
│ Get dust 5 (FeeToken: WEI) │ '6.264.000.000.512' │ 0.025 │ 6264000000000 │ 174 │ 160 │ 6 │ 9 │ 'steps' │ 8 │ 512 │ 'BLOB' │
└───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘
Resources:
┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐
Expand All @@ -43,4 +47,8 @@ Resources:
│ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913 │
│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │
│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │
│ Get dust 2 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 83 │ 0 │ 856 │ 28376 │
│ Get dust 3 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 117 │ 0 │ 1232 │ 40167 │
│ Get dust 4 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 151 │ 0 │ 1608 │ 51958 │
│ Get dust 5 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 185 │ 0 │ 1984 │ 63749 │
└───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘
34 changes: 31 additions & 3 deletions scripts/profile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { CallData } from "starknet";
import {
buildGiftCallData,
calculateEscrowAddress,
claimDust,
claimExternal,
claimInternal,
defaultDepositTestSetup,
deployer,
executeActionOnAccount,
manager,
randomReceiver,
setDefaultTransactionVersionV3,
Expand Down Expand Up @@ -38,11 +42,11 @@ await profiler.profile(
await strkContract.transfer(randomReceiver(), 1),
);

const receiver = "0x42";
const { factory } = await setupGiftProtocol();

for (const { giftTokenContract, unit } of tokens) {
for (const useTxV3 of [false, true]) {
const receiver = "0x42";
const { factory } = await setupGiftProtocol();

// Profiling deposit
const { txReceipt, gift, giftPrivateKey } = await defaultDepositTestSetup({
factory,
Expand Down Expand Up @@ -86,5 +90,29 @@ for (const { giftTokenContract, unit } of tokens) {
}
}

const limits = [2, 3, 4, 5];
for (const limit of limits) {
const claimDustCalls = [];
for (let i = 0; i < limit; i++) {
const { gift, giftPrivateKey } = await defaultDepositTestSetup({
factory,
overrides: {
giftTokenAddress: ethContract.address,
},
});

await claimInternal({ gift, receiver, giftPrivateKey: giftPrivateKey });
const claimDustCallData = CallData.compile([buildGiftCallData(gift), receiver]);
const call = executeActionOnAccount("claim_dust", calculateEscrowAddress(gift), claimDustCallData);

claimDustCalls.push(call);
}

await profiler.profile(
`Get dust ${limit} (FeeToken: ${manager.tokens.unitTokenContract(false)})`,
await deployer.execute(claimDustCalls),
);
}

profiler.printSummary();
profiler.updateOrCheckReport();

0 comments on commit b66de94

Please sign in to comment.