Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ auth
├─ TimedRoles — "Timed multiroles authorization mixin"
tokens
├─ ERC1155 — "Simple ERC1155 implementation"
├─ ERC20 — "Simple ERC20 + EIP-2612 implementation"
├─ ERC20 — "Simple ERC20 + EIP-2612 + ERC-8255 implementation"
├─ ERC20Votes — "ERC20 with votes based on ERC5805 and ERC6372"
├─ ERC2981 — "Simple ERC2981 NFT Royalty Standard implementation"
├─ ERC4626 — "Simple ERC4626 tokenized Vault implementation"
Expand Down
95 changes: 90 additions & 5 deletions docs/tokens/erc20.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ERC20

Simple ERC20 + EIP-2612 implementation.
Simple ERC20 + EIP-2612 + ERC-8255 implementation.


<b>Note:</b>
Expand Down Expand Up @@ -47,6 +47,22 @@ error AllowanceUnderflow()

The allowance has underflowed.

### ApprovalDurationTooLong()

```solidity
error ApprovalDurationTooLong()
```

The approval duration is greater than `maxApprovalDuration()`.

### ApprovalExpirationOverflow()

```solidity
error ApprovalExpirationOverflow()
```

The approval expiration timestamp has overflowed.

### InsufficientBalance()

```solidity
Expand Down Expand Up @@ -107,6 +123,16 @@ event Approval(

Emitted when `amount` tokens is approved by `owner` to be used by `spender`.

### ApprovalExpiration(address,address,uint64)

```solidity
event ApprovalExpiration(
address indexed owner, address indexed spender, uint64 expiration
)
```

Emitted when an approval expiration is set.

## Constants

### _PERMIT2
Expand All @@ -122,6 +148,14 @@ Enabled by default. To disable, override `_givePermit2InfiniteAllowance()`.
[Github](https://github.com/Uniswap/permit2)
[Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)

### _MAX_APPROVAL_DURATION

```solidity
uint32 internal constant _MAX_APPROVAL_DURATION = 1 days
```

The default maximum approval duration, in seconds.

## ERC20

### totalSupply()
Expand Down Expand Up @@ -156,6 +190,27 @@ function allowance(address owner, address spender)

Returns the amount of tokens that `spender` can spend on behalf of `owner`.

### allowanceAndExpiration(address,address)

```solidity
function allowanceAndExpiration(address owner, address spender)
public
view
virtual
returns (uint64 expiration, uint256 amount)
```

Returns the stored allowance expiration and amount for `spender` over `owner`.
The amount is returned even if the approval has expired.

### maxApprovalDuration()

```solidity
function maxApprovalDuration() public pure virtual returns (uint32)
```

Returns the maximum approval duration, in seconds.

### approve(address,uint256)

```solidity
Expand All @@ -167,7 +222,21 @@ function approve(address spender, uint256 amount)

Sets `amount` as the allowance of `spender` over the caller's tokens.

Emits a `Approval` event.
Emits `Approval` and `ApprovalExpiration` events.

### approveForDuration(address,uint256,uint32)

```solidity
function approveForDuration(address spender, uint256 amount, uint32 duration)
public
virtual
returns (bool)
```

Sets `amount` as the allowance of `spender` over the caller's tokens
for `duration` seconds. `duration` must not exceed `maxApprovalDuration()`.

Emits `Approval` and `ApprovalExpiration` events.

### transfer(address,uint256)

Expand Down Expand Up @@ -266,7 +335,7 @@ function permit(
Sets `value` as the allowance of `spender` over the tokens of `owner`,
authorized by a signed approval by `owner`.

Emits a `Approval` event.
Emits `Approval` and `ApprovalExpiration` events.

### DOMAIN_SEPARATOR()

Expand Down Expand Up @@ -334,7 +403,23 @@ function _approve(address owner, address spender, uint256 amount)

Sets `amount` as the allowance of `spender` over the tokens of `owner`.

Emits a `Approval` event.
Emits `Approval` and `ApprovalExpiration` events.

### _approve(address,address,uint256,uint32)

```solidity
function _approve(
address owner,
address spender,
uint256 amount,
uint32 duration
) internal virtual
```

Sets `amount` as the allowance of `spender` over the tokens of `owner`
for `duration` seconds.

Emits `Approval` and `ApprovalExpiration` events.

## Hooks To Override

Expand Down Expand Up @@ -375,4 +460,4 @@ function _givePermit2InfiniteAllowance()
Returns whether to fix the Permit2 contract's allowance at infinity.
This value should be kept constant after contract initialization,
or else the actual allowance values may not match with the `Approval` events.
For best performance, return a compile-time constant for zero-cost abstraction.
For best performance, return a compile-time constant for zero-cost abstraction.
Loading