Transfer recipients will pay unwarranted emergency withdrawal penalties for share positions they legitimately own
The staking contract's ERC20 transfer does not update the per-user stake records, so a recipient of transferred shares has an empty stake list. Even after waiting the full minimum stake period, the recipient cannot use the normal withdrawal and is pushed into the emergency withdrawal path, which charges a 10% penalty.
Originally disclosed on Immunefi
- Disclosed after under an hour
57813 sc critical transfer recipients will pay unwarranted emergency withdrawal penalties for share positions they legitimately own
Submitted on Oct 29th 2025 at 01:41:03 UTC by @Lavender88 for Audit Comp | Belong
- Report ID: #57813
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/periphery/Staking.sol
- Impacts: Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
{% hint style="danger" %} Missing stake-tracking updates on ERC20 transfers can force transfer recipients to use emergency withdrawal (10% penalty) even after waiting the full minStakePeriod. {% endhint %}
Description
Brief / Intro
The missing stake tracking updates on ERC20 transfers will cause a 10% penalty loss for share recipients: they cannot use normal withdrawal even after waiting the full minStakePeriod because the stakes[] array remains empty for transferred shares.
Vulnerability Details
In Staking.sol, the ERC20 transfer() function inherited from Solady's base implementation does not update the stakes[] mapping. When shares are transferred:
balanceOf[]correctly updates (sender decreases, recipient increases)stakes[]does NOT update (recipient remains with empty array)
This desynchronization causes _consumeUnlockedSharesOrRevert() to fail for transfer recipients even after the lock period expires, forcing them into the emergency withdrawal path with its 10% penalty.
Preconditions / Reproduction Steps
{% stepper %} {% step %}
1. Create a locked stake for Alice
Alice calls deposit() to create a stake entry in stakes[A] with locked shares.
{% endstep %}
{% step %}
2. Transfer shares to recipient
Alice calls transfer() to send shares to Bob, who has an empty stakes[B] array.
{% endstep %}
{% step %}
3. Ensure non-zero lock period
minStakePeriod is set to a non-zero value (e.g., default 1 day).
{% endstep %}
{% endstepper %}
Attack Path (example scenario)
Scenario: Innocent Transfer Recipient (Bob) Gets Griefed
- Alice deposits 1000 LONG tokens via
deposit(), receiving 1000 shares
stakes[alice] = [{shares: 1000, timestamp: T}]
balanceOf[alice] = 1000 - Alice transfers 1000 shares to Bob via standard ERC20
transfer()
balanceOf[alice] = 0
balanceOf[bob] = 1000
stakes[alice] = unchanged [{shares: 1000, timestamp: T}]
stakes[bob] = [](empty) - Bob waits full lock period (1 day passes) and calls
redeem(1000, bob, bob)
Execution reaches_consumeUnlockedSharesOrRevert(bob, 1000)which loops throughstakes[bob](empty) => remaining = 1000 => REVERTS withMinStakePeriodNotMet(). - Bob is forced to call
emergencyRedeem(1000, bob, bob)which uses_removeAnySharesFor()and does not checkstakes[]properly. Bob pays 10% penalty: 100 LONG sent to treasury, receives 900 LONG.
Result: Bob loses 100 LONG (10% of his position) despite legitimately holding shares for the required duration.
Impact Details
Transfer recipients suffer an unwarranted 10% loss when attempting to withdraw shares they legitimately own. Examples of affected recipients:
- DEX purchasers
- Gift/transfer recipients
- Liquidity provision reward recipients
This is griefing: damage to users without profit motive for the attacker. Treasury receives unintended penalty funds.
Mitigation
Two suggested mitigations (as proposed by the reporter):
- Option 1: Update
stakes[]on ERC20 transfers to keep stake metadata in sync withbalanceOf[]. - Option 2: Disable transfers entirely (preventing transfer-based desynchronization).
Proof of Concept
function testTransferRecipientGriefed() public {
// Alice stakes 1000 LONG (locked for 1 day)
vm.prank(alice);
uint256 shares = staking.deposit(1000e18, alice);
// Alice transfers shares to Bob
vm.prank(alice);
staking.transfer(bob, shares);
// Bob waits full lock period (1 day + buffer)
vm.warp(block.timestamp + 1 days + 1);
// Bob attempts normal withdrawal - REVERTS
vm.prank(bob);
vm.expectRevert(Staking.MinStakePeriodNotMet.selector);
staking.redeem(shares, bob, bob);
// Bob forced to use emergency withdrawal
uint256 bobBalanceBefore = long.balanceOf(bob);
vm.prank(bob);
staking.emergencyRedeem(shares, bob, bob);
uint256 bobReceived = long.balanceOf(bob) - bobBalanceBefore;
uint256 penalty = long.balanceOf(treasury);
// Verify Bob paid penalty despite waiting full period
assertEq(penalty, 100e18, "Bob paid 10% penalty");
assertEq(bobReceived, 900e18, "Bob lost 100 LONG");
}
References
Context
Belong is a staking product whose core logic lives in Staking.sol, part of the contracts/v2/periphery directory of the audit competition repository. The contract is an ERC20 share token built on Solady's ERC20 base implementation, and it layers a staking model on top of that token: users call deposit() to lock tokens and receive shares, and they call redeem() to burn shares and withdraw once the lock period has elapsed.
The lock period is governed by minStakePeriod. To enforce it, the contract keeps a per-account array, stakes[], recording each stake entry as a share amount and a timestamp. Normal withdrawal goes through _consumeUnlockedSharesOrRevert(), which walks the caller's stakes[] entries and only lets the call proceed if enough shares have been held for at least minStakePeriod. If the caller cannot satisfy that check, the remaining route is emergencyRedeem(), which uses _removeAnySharesFor() and applies a 10% penalty on the withdrawn amount, with the penalty sent to the treasury.
Setup
The report targets a single contract:
https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/periphery/Staking.sol
The proof of concept is a Foundry test (function testTransferRecipientGriefed() public) using vm.prank, vm.warp and vm.expectRevert, so the setup is a standard Foundry environment with the staking contract deployed, a long token handle, a treasury address, and two accounts, alice and bob. The scenario assumes minStakePeriod is non-zero; the report uses the default of 1 day as the example. No other configuration, version or tooling detail is given.
Finding it
The researcher noticed that the ERC20 transfer() function is inherited unchanged from Solady's base implementation and never touches the stakes[] mapping. Shares therefore move between accounts while the stake metadata stays where it was. After a transfer:
balanceOf[]updates correctly: the sender decreases, the recipient increases.stakes[]does not update: the recipient is left with an empty array.
That desynchronisation is the whole bug. The lock check reads stakes[], not balanceOf[], so a recipient who genuinely holds shares has no stake history to point at, and _consumeUnlockedSharesOrRevert() fails for them no matter how long they wait.
Exploitation
Step 1: Create a locked stake for Alice
Alice calls deposit() to create a stake entry in stakes[A] with locked shares.
Step 2: Transfer shares to the recipient
Alice calls transfer() to send shares to Bob, who has an empty stakes[B] array.
Step 3: Ensure a non-zero lock period
minStakePeriod is set to a non-zero value, for example the default of 1 day.
The report walks the scenario through with concrete numbers. Alice deposits 1000 LONG tokens via deposit() and receives 1000 shares:
stakes[alice] = [{shares: 1000, timestamp: T}]
balanceOf[alice] = 1000
Alice then transfers 1000 shares to Bob via the standard ERC20 transfer():
balanceOf[alice] = 0
balanceOf[bob] = 1000
stakes[alice] = unchanged [{shares: 1000, timestamp: T}]
stakes[bob] = [] (empty)
Bob waits the full lock period (1 day passes) and calls redeem(1000, bob, bob). Execution reaches _consumeUnlockedSharesOrRevert(bob, 1000), which loops through stakes[bob] (empty), so remaining stays at 1000 and the call reverts with MinStakePeriodNotMet().
Bob is then forced to call emergencyRedeem(1000, bob, bob), which uses _removeAnySharesFor() and does not check stakes[] properly. Bob pays the 10% penalty: 100 LONG goes to the treasury and he receives 900 LONG.
The proof of concept reproduces exactly this sequence:
function testTransferRecipientGriefed() public {
// Alice stakes 1000 LONG (locked for 1 day)
vm.prank(alice);
uint256 shares = staking.deposit(1000e18, alice);
// Alice transfers shares to Bob
vm.prank(alice);
staking.transfer(bob, shares);
// Bob waits full lock period (1 day + buffer)
vm.warp(block.timestamp + 1 days + 1);
// Bob attempts normal withdrawal - REVERTS
vm.prank(bob);
vm.expectRevert(Staking.MinStakePeriodNotMet.selector);
staking.redeem(shares, bob, bob);
// Bob forced to use emergency withdrawal
uint256 bobBalanceBefore = long.balanceOf(bob);
vm.prank(bob);
staking.emergencyRedeem(shares, bob, bob);
uint256 bobReceived = long.balanceOf(bob) - bobBalanceBefore;
uint256 penalty = long.balanceOf(treasury);
// Verify Bob paid penalty despite waiting full period
assertEq(penalty, 100e18, "Bob paid 10% penalty");
assertEq(bobReceived, 900e18, "Bob lost 100 LONG");
}
The test deposits as Alice, transfers the shares to Bob, warps past the lock period plus one second, and asserts that redeem() reverts with Staking.MinStakePeriodNotMet.selector. It then performs the emergency withdrawal and asserts two outcomes: the treasury holds 100e18 (the 10% penalty) and Bob received 900e18, having lost 100 LONG.
Root cause
The ERC20 transfer() inherited from Solady's base implementation updates balanceOf[] but not stakes[]. The lock enforcement in _consumeUnlockedSharesOrRevert() is driven entirely by the stakes[] array, so a recipient whose shares arrived by transfer has an empty array and can never satisfy the check, even after the full minStakePeriod has passed. The emergency path, _removeAnySharesFor(), does not consult stakes[] properly, so it succeeds and applies the 10% penalty. Nothing in the contract reconciles the two views of ownership, so the desynchronisation persists until the shares are withdrawn through the penalised route.
Impact
Transfer recipients suffer an unwarranted 10% loss when withdrawing shares they legitimately own. The report lists DEX purchasers, gift or transfer recipients, and liquidity provision reward recipients as examples of affected parties. The researcher classifies this as griefing: damage to users with no profit motive for an attacker, with the treasury receiving the unintended penalty funds. The recipient loses 10% of the transferred position when withdrawing through the emergency path.
Fix
The reporter proposed two mitigations:
- Update
stakes[]on ERC20 transfers so that stake metadata stays in sync withbalanceOf[]. - Disable transfers entirely, preventing transfer-based desynchronisation.
The report does not say which option, if any, was adopted.
Variants to test
Hunting notes
The researcher showed impact with a Foundry test that asserts both the revert on the normal path and the exact penalty and net amount on the emergency path.
What happened, in plain words
Belong is a staking product. People put tokens into it and get "shares" back, a bit like handing a coat to a cloakroom and getting a numbered ticket. The ticket is not the coat, but it proves the coat is yours and lets you collect it later. In this product the ticket (the share) is itself a token that can be handed to someone else, and the contract that runs the cloakroom is called Staking.sol.
The contract has two rules that matter here. First, if you want your tokens back the normal way, you must have held the shares for a minimum time, called minStakePeriod. Second, if you cannot meet that minimum, there is an emergency exit, but it charges a 10% penalty: you get back only 90% of what you put in, and the missing 10% goes to the project's treasury (the account that collects fees).
To check the minimum time, the contract keeps a private list for each account, called stakes[], recording how many shares that account staked and when. The problem the researcher found is that when shares are sent from one person to another using the ordinary token transfer, the contract updates the visible balance of both people but forgets to update that private list. The receiver ends up holding real shares but with an empty history. When they later try the normal withdrawal, the contract looks at the empty list, decides they never waited long enough, and refuses. Their only option is the emergency exit, so they lose 10% even though they did nothing wrong and waited the full period.
The researcher rates this critical and calls it griefing: harm done to users without the attacker making any money. The treasury simply collects penalties it was never meant to receive.
The product and the contract
Belong's staking logic lives in one file, Staking.sol, inside the contracts/v2/periphery folder of the audit competition repository. "Periphery" here just means the outer layer of the project, the part users interact with directly.
The contract is an ERC20 token. ERC20 is the common standard for tokens on Ethereum-style blockchains: it defines a fixed set of functions every token must have, such as transfer() (send tokens to someone), balanceOf() (ask how many tokens an address holds) and approve() (let another address spend on your behalf). Because the standard is fixed, developers rarely write these functions from scratch. They build on a library that already implements them. This contract builds on Solady's ERC20 base implementation, a well-known library that provides a lean, gas-efficient version of the standard.
On top of that standard token, the contract adds a staking model:
deposit()locks tokens and gives the caller shares in return.redeem()burns shares and returns the tokens, but only once the lock period has passed.emergencyRedeem()is the escape hatch: it returns tokens immediately but takes a 10% cut.
The lock period is minStakePeriod. To enforce it, the contract keeps a per-account array called stakes[]. Each entry in that array records two things: a share amount and a timestamp (the moment the stake was made). Think of it as a receipt book: every deposit writes a line saying "this many shares, at this time".
Normal withdrawal runs through an internal function, _consumeUnlockedSharesOrRevert(). It walks through the caller's stakes[] entries and only lets the withdrawal proceed if enough shares have been sitting there for at least minStakePeriod. If that check cannot be satisfied, the remaining route is emergencyRedeem(), which uses a different internal function, _removeAnySharesFor(), and applies the 10% penalty, sending that penalty to the treasury.
The setup
The report targets a single contract:
https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/periphery/Staking.sol
This is a link to the exact file on GitHub. Anyone can open it in a browser and read the code, which is how the researcher studied it.
The proof of concept is a Foundry test. Foundry is a toolkit for writing and running automated tests against smart contracts without touching a real blockchain. A test is a small program that sets up a scenario, performs actions, and checks that the results are what you expect. The test in this report is declared as function testTransferRecipientGriefed() public.
Foundry provides special helper commands, called cheatcodes, that let a test bend the rules of the simulated blockchain:
vm.prank(address)makes the next call appear to come from that address, so the test can act as Alice or Bob without needing their private keys.vm.warp(timestamp)jumps the simulated clock forward, so the test can pretend a day has passed instantly.vm.expectRevert(...)tells the test to expect the next call to fail, and to check that it fails for the stated reason.
The setup therefore needs a standard Foundry environment with the staking contract deployed, a handle to the long token, a treasury address, and two accounts, alice and bob. The scenario assumes minStakePeriod is not zero; the report uses the default of 1 day as the example. No other configuration, version or tooling detail is given.
Finding it
The researcher read the contract and noticed something simple: the ERC20 transfer() function is inherited unchanged from Solady's base implementation and never touches the stakes[] array. Shares can therefore move between accounts while the stake records stay exactly where they were.
After a transfer, two views of the world disagree:
balanceOf[]updates correctly: the sender's balance goes down, the recipient's goes up.stakes[]does not update: the recipient is left with an empty array.
That mismatch is the whole bug. The lock check reads stakes[], not balanceOf[]. So a recipient who genuinely holds shares has no stake history to point at, and _consumeUnlockedSharesOrRevert() fails for them no matter how long they wait. It is like a cloakroom that checks your ticket against a handwritten ledger, but the person who hands you the ticket never writes your name in the ledger. You hold a valid ticket, yet the ledger says you never handed anything in.
Exploitation
Step 1: Create a locked stake for Alice
Alice calls deposit() to create a stake entry in stakes[A] with locked shares. This is the ordinary, honest first step: she puts tokens in and the contract writes a receipt line for her.
Step 2: Transfer shares to the recipient
Alice calls transfer() to send shares to Bob, who has an empty stakes[B] array. This is also ordinary behaviour: the token is transferable, so Alice is allowed to give her shares away. The transfer moves the balance but, as established, leaves the receipt book untouched.
Step 3: Ensure a non-zero lock period
minStakePeriod is set to a non-zero value, for example the default of 1 day. Without a lock period there would be nothing to enforce and no penalty to trigger, so this condition is what makes the bug matter.
The report then walks the scenario through with concrete numbers. Alice deposits 1000 LONG tokens via deposit() and receives 1000 shares:
stakes[alice] = [{shares: 1000, timestamp: T}]
balanceOf[alice] = 1000
Line by line: Alice's receipt book now has one entry saying she staked 1000 shares at time T, and her visible balance is 1000 shares. The two agree, as they should right after a deposit.
Alice then transfers 1000 shares to Bob via the standard ERC20 transfer():
balanceOf[alice] = 0
balanceOf[bob] = 1000
stakes[alice] = unchanged [{shares: 1000, timestamp: T}]
stakes[bob] = [] (empty)
Line by line: Alice's balance drops to zero and Bob's rises to 1000, which is correct. But Alice's receipt book still shows her 1000 shares at time T, even though she no longer holds them, and Bob's receipt book is empty, even though he now holds 1000 shares. The balances and the receipts have drifted apart.
Bob waits the full lock period (1 day passes) and calls redeem(1000, bob, bob). The three arguments mean: burn 1000 shares, send the tokens to Bob, and do it on Bob's behalf. Execution reaches _consumeUnlockedSharesOrRevert(bob, 1000), which loops through stakes[bob]. That array is empty, so nothing is consumed and remaining stays at 1000. The check fails and the call reverts with MinStakePeriodNotMet(). "Revert" means the transaction is cancelled and all its effects are undone, as if it never happened. The error name says the minimum staking period was not met, which is technically true from the contract's point of view and completely unfair from Bob's.
Bob is then forced to call emergencyRedeem(1000, bob, bob). This uses _removeAnySharesFor(), which does not check stakes[] properly, so it succeeds. Bob pays the 10% penalty: 100 LONG goes to the treasury and he receives 900 LONG. He has lost 100 LONG, a tenth of his position, purely because the shares reached him by transfer rather than by deposit.
The proof of concept reproduces exactly this sequence:
function testTransferRecipientGriefed() public {
// Alice stakes 1000 LONG (locked for 1 day)
vm.prank(alice);
uint256 shares = staking.deposit(1000e18, alice);
// Alice transfers shares to Bob
vm.prank(alice);
staking.transfer(bob, shares);
// Bob waits full lock period (1 day + buffer)
vm.warp(block.timestamp + 1 days + 1);
// Bob attempts normal withdrawal - REVERTS
vm.prank(bob);
vm.expectRevert(Staking.MinStakePeriodNotMet.selector);
staking.redeem(shares, bob, bob);
// Bob forced to use emergency withdrawal
uint256 bobBalanceBefore = long.balanceOf(bob);
vm.prank(bob);
staking.emergencyRedeem(shares, bob, bob);
uint256 bobReceived = long.balanceOf(bob) - bobBalanceBefore;
uint256 penalty = long.balanceOf(treasury);
// Verify Bob paid penalty despite waiting full period
assertEq(penalty, 100e18, "Bob paid 10% penalty");
assertEq(bobReceived, 900e18, "Bob lost 100 LONG");
}
Line by line:
function testTransferRecipientGriefed() public {declares the test. Foundry will run it automatically and report whether it passes.vm.prank(alice);makes the next call come from Alice.uint256 shares = staking.deposit(1000e18, alice);Alice deposits 1000 tokens (thee18suffix means the number is scaled by 10 to the power of 18, the standard way tokens handle decimals) and the returned share count is stored inshares.vm.prank(alice);again, because each prank applies to one call only.staking.transfer(bob, shares);Alice sends all her shares to Bob. This is the step that leaves Bob's receipt book empty.vm.warp(block.timestamp + 1 days + 1);jumps the simulated clock forward by one day plus one second, so the lock period has definitely elapsed.vm.prank(bob);makes the next call come from Bob.vm.expectRevert(Staking.MinStakePeriodNotMet.selector);tells the test that the next call must fail with that specific error. If it succeeds, the test fails.staking.redeem(shares, bob, bob);Bob tries the normal withdrawal. It reverts, exactly as predicted.uint256 bobBalanceBefore = long.balanceOf(bob);records Bob's token balance before the emergency withdrawal, so the test can measure the difference afterwards.staking.emergencyRedeem(shares, bob, bob);Bob takes the penalised exit.uint256 bobReceived = long.balanceOf(bob) - bobBalanceBefore;works out how many tokens Bob actually gained.uint256 penalty = long.balanceOf(treasury);reads how much the treasury now holds, which is the penalty.assertEq(penalty, 100e18, "Bob paid 10% penalty");checks the treasury received exactly 100 tokens.assertEqmeans "assert equal": if the two values differ, the test fails and prints the message.assertEq(bobReceived, 900e18, "Bob lost 100 LONG");checks Bob received exactly 900 tokens, confirming the 100-token loss.
So the test deposits as Alice, transfers the shares to Bob, warps past the lock period plus one second, and asserts that redeem() reverts with Staking.MinStakePeriodNotMet.selector. It then performs the emergency withdrawal and asserts two outcomes: the treasury holds 100e18 (the 10% penalty) and Bob received 900e18, having lost 100 LONG. The point of asserting exact numbers is to turn a design observation into a measured, reproducible loss.
Root cause
The ERC20 transfer() inherited from Solady's base implementation updates balanceOf[] but not stakes[]. The lock enforcement in _consumeUnlockedSharesOrRevert() is driven entirely by the stakes[] array, so a recipient whose shares arrived by transfer has an empty array and can never satisfy the check, even after the full minStakePeriod has passed. The emergency path, _removeAnySharesFor(), does not consult stakes[] properly, so it succeeds and applies the 10% penalty. Nothing in the contract reconciles the two views of ownership, so the mismatch persists until the shares are withdrawn through the penalised route.
In everyday terms: the contract has two records of who owns what, the balance and the receipt book, and only one of them is updated when shares change hands. Every later decision is made from the receipt book, which is now wrong.
Impact
Transfer recipients suffer an unwarranted 10% loss when withdrawing shares they legitimately own. The report lists DEX purchasers, gift or transfer recipients, and liquidity provision reward recipients as examples of affected parties. A DEX is a decentralised exchange, a service where people swap tokens directly with each other; anyone who buys these shares there becomes a transfer recipient. A gift recipient is simply someone the shares were sent to. A liquidity provision reward recipient is someone paid in these shares for supplying funds to a trading pool.
The researcher classifies this as griefing: damage to users with no profit motive for an attacker, with the treasury receiving the unintended penalty funds. The recipient loses 10% of the transferred position when withdrawing through the emergency path. In other words, the shares do not vanish; the holder just cannot get their full value out through the normal door.
Fix
The reporter proposed two mitigations:
- Update
stakes[]on ERC20 transfers so that stake metadata stays in sync withbalanceOf[]. In plain terms: whenever shares change hands, write the corresponding line in the recipient's receipt book (and adjust the sender's), so both records always agree. - Disable transfers entirely, preventing transfer-based desynchronisation. If shares can never move between accounts, the two records can never drift apart.
The report does not say which option, if any, was adopted.
Variants to test
Hunting notes
The researcher showed impact with a Foundry test that asserts both the revert on the normal path and the exact penalty and net amount on the emergency path.
Glossary
- Blockchain: a shared, tamper-resistant record of transactions maintained by many computers, on which smart contracts run.
- Smart contract: a program stored on a blockchain that runs automatically when called and cannot be changed after deployment.
- ERC20: the common standard that defines how tokens on Ethereum-style blockchains behave, including functions such as
transferandbalanceOf. - Token: a digital unit of value issued on a blockchain, following a standard such as ERC20.
- Share: here, a token representing a stake in the staking contract; it can be redeemed for the underlying tokens.
- Staking: locking tokens in a contract for a period, usually to earn rewards or to support a protocol.
deposit(): the contract function that locks tokens and issues shares in return.redeem(): the contract function that burns shares and returns tokens, allowed only after the lock period.emergencyRedeem(): the escape-hatch function that returns tokens immediately but charges a 10% penalty.minStakePeriod: the minimum time shares must be held before a normal withdrawal is allowed.stakes[]: a per-account array in the contract recording each stake as a share amount and a timestamp.balanceOf[]: the ERC20 record of how many tokens each address holds._consumeUnlockedSharesOrRevert(): the internal function that checksstakes[]and cancels the withdrawal if the lock period is not met._removeAnySharesFor(): the internal function used by the emergency path, which does not checkstakes[]properly.- Treasury: the account that collects fees and penalties for the project.
- Penalty: the 10% cut taken from an emergency withdrawal.
- Revert: cancelling a transaction and undoing all its effects, usually because a check failed.
MinStakePeriodNotMet(): the error the contract raises when the lock period check fails.- Solady: a library providing optimised implementations of common Ethereum patterns, including ERC20.
- Inherit: to build on existing code so that its functions are available without rewriting them.
- Mapping: a key-value data structure in Solidity, similar to a dictionary.
- Array: an ordered list of values in Solidity.
- Desynchronisation: a state where two records that should agree, such as balances and stake metadata, no longer match.
- Griefing: causing harm or annoyance to users without gaining any profit yourself.
- Foundry: a toolkit for writing and running automated tests against smart contracts in a simulated environment.
- Proof of concept (PoC): a small program or set of steps that demonstrates a vulnerability actually works.
- Cheatcode: a special Foundry command, prefixed
vm., that lets a test manipulate the simulated blockchain. vm.prank(address): a cheatcode that makes the next call appear to come from the given address.vm.warp(timestamp): a cheatcode that jumps the simulated clock to a given time.vm.expectRevert(...): a cheatcode that tells the test the next call must fail, optionally with a specific error.assertEq(a, b, message): a test check that fails unless the two values are equal, printing the message if they are not.e18: a shorthand meaning the number is multiplied by 10 to the power of 18, the usual way token amounts handle decimals.selector: the short identifier for a function or error in Solidity, used to refer to it precisely.- Hook: a function the token standard calls automatically during transfers, often used to keep extra records in sync.
transferFrom: the ERC20 function that lets an approved third party move tokens on someone's behalf.- Mint: creating new tokens.
- Burn: destroying tokens.
- DEX: a decentralised exchange, where users swap tokens directly with each other.
- Liquidity provision: supplying funds to a trading pool, often rewarded with tokens.
- Recon: the research phase of an audit, reading code and mapping out how a system works before hunting for bugs.
- Audit competition: a public contest where researchers review a project's code and submit findings for review and possible rewards.