Skip to content

Commit

Permalink
chore: Generate Foundry docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nud3l authored and github-actions[bot] committed Dec 21, 2023
1 parent 8566870 commit 1817d76
Show file tree
Hide file tree
Showing 25 changed files with 1,132 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# TestingErc20
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/TestingErc20.sol)

**Inherits:**
ERC20, ERC20Burnable, Ownable, ERC2771Recipient


## State Variables
### _numDecimals

```solidity
uint8 _numDecimals;
```


## Functions
### constructor


```solidity
constructor(string memory _name, string memory _symbol, uint8 _decimals) ERC20(_name, _symbol);
```

### setTrustedForwarder


```solidity
function setTrustedForwarder(address _forwarder) public onlyOwner;
```

### mint


```solidity
function mint(uint256 amount) external;
```

### _msgSender


```solidity
function _msgSender() internal view override(Context, ERC2771Recipient) returns (address sender);
```

### _msgData


```solidity
function _msgData() internal view override(Context, ERC2771Recipient) returns (bytes calldata);
```

### decimals


```solidity
function decimals() public view virtual override returns (uint8);
```

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BitcoinTx
[Git Source](https://github.com/bob-collective/bob/blob/6feef4b26921a0e62c67cac7076c04271613ba33/src/bridge/BitcoinTx.sol)
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/bridge/BitcoinTx.sol)

Allows to reference Bitcoin raw transaction in Solidity.

Expand Down Expand Up @@ -95,6 +95,20 @@ function getTxOutputValue(
|`processInfo`|`TxOutputsProcessingInfo`|TxOutputsProcessingInfo identifying output starting index and the number of outputs.|


### reverseEndianness


```solidity
function reverseEndianness(bytes32 b) internal pure returns (bytes32 txHash);
```

### ensureTxInputSpendsUtxo


```solidity
function ensureTxInputSpendsUtxo(bytes memory _vin, BitcoinTx.UTXO memory utxo) internal pure;
```

## Structs
### Info
Represents Bitcoin transaction data.
Expand All @@ -121,6 +135,18 @@ struct Proof {
}
```

### UTXO
Represents info about an unspent transaction output.


```solidity
struct UTXO {
bytes32 txHash;
uint32 txOutputIndex;
uint64 txOutputValue;
}
```

### TxOutputsProcessingInfo
Represents temporary information needed during the processing of
the Bitcoin transaction outputs. This structure is an internal one
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BridgeState
[Git Source](https://github.com/bob-collective/bob/blob/6feef4b26921a0e62c67cac7076c04271613ba33/src/bridge/BridgeState.sol)
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/bridge/BridgeState.sol)


## Structs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IRelay
[Git Source](https://github.com/bob-collective/bob/blob/6feef4b26921a0e62c67cac7076c04271613ba33/src/bridge/IRelay.sol)
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/bridge/IRelay.sol)

Contains only the methods needed by tBTC v2. The Bitcoin relay
provides the difficulty of the previous and current epoch. One
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# WitnessTx
[Git Source](https://github.com/bob-collective/bob/blob/6feef4b26921a0e62c67cac7076c04271613ba33/src/bridge/WitnessTx.sol)
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/bridge/WitnessTx.sol)


## State Variables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Erc20Minter
[Git Source](https://github.com/bob-collective/bob/blob/6feef4b26921a0e62c67cac7076c04271613ba33/src/faucet/Erc20Minter.sol)
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/faucet/Erc20Minter.sol)

**Inherits:**
Ownable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Erc20Mintable
[Git Source](https://github.com/bob-collective/bob/blob/6feef4b26921a0e62c67cac7076c04271613ba33/src/faucet/Erc20Minter.sol)
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/faucet/Erc20Minter.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# PimlicoERC20Paymaster
[Git Source](https://github.com/bob-collective/bob/blob/9dd94230dd2abcab7dfb659e986743be10093c68/src/paymasters/AccountAbstraction/AATokenPaymaster.sol)

**Inherits:**
BasePaymaster

An ERC-4337 Paymaster contract by Pimlico which is able to sponsor gas fees in exchange for ERC20 tokens.
The contract refunds excess tokens if the actual gas cost is lower than the initially provided amount.
It also allows updating price configuration and withdrawing tokens by the contract owner.
The contract uses an Oracle to fetch the latest token prices.

*Inherits from BasePaymaster.*


## State Variables
### priceDenominator

```solidity
uint256 public constant priceDenominator = 1e6;
```


### REFUND_POSTOP_COST

```solidity
uint256 public constant REFUND_POSTOP_COST = 40000;
```


### token

```solidity
IERC20 public immutable token;
```


### tokenDecimals

```solidity
uint256 public immutable tokenDecimals;
```


### tokenOracle

```solidity
IOracle public immutable tokenOracle;
```


### nativeAssetOracle

```solidity
IOracle public immutable nativeAssetOracle;
```


### previousPrice

```solidity
uint192 public previousPrice;
```


### priceMarkup

```solidity
uint32 public priceMarkup;
```


### priceUpdateThreshold

```solidity
uint32 public priceUpdateThreshold;
```


## Functions
### constructor

Initializes the PimlicoERC20Paymaster contract with the given parameters.


```solidity
constructor(
IERC20 _token,
IEntryPoint _entryPoint,
IOracle _tokenOracle,
IOracle _nativeAssetOracle,
address _owner,
uint8 _tokenDecimals
) BasePaymaster(_entryPoint);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_token`|`IERC20`|The ERC20 token used for transaction fee payments.|
|`_entryPoint`|`IEntryPoint`|The EntryPoint contract used in the Account Abstraction infrastructure.|
|`_tokenOracle`|`IOracle`|The Oracle contract used to fetch the latest token prices.|
|`_nativeAssetOracle`|`IOracle`|The Oracle contract used to fetch the latest native asset (ETH, Matic, Avax, etc.) prices.|
|`_owner`|`address`|The address that will be set as the owner of the contract.|
|`_tokenDecimals`|`uint8`||


### updateConfig

Updates the price markup and price update threshold configurations.


```solidity
function updateConfig(uint32 _priceMarkup, uint32 _updateThreshold) external onlyOwner;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_priceMarkup`|`uint32`|The new price markup percentage (1e6 = 100%).|
|`_updateThreshold`|`uint32`|The new price update threshold percentage (1e6 = 100%).|


### withdrawToken

Allows the contract owner to withdraw a specified amount of tokens from the contract.


```solidity
function withdrawToken(address to, uint256 amount) external onlyOwner;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`to`|`address`|The address to transfer the tokens to.|
|`amount`|`uint256`|The amount of tokens to transfer.|


### updatePrice

Updates the token price by fetching the latest price from the Oracle.


```solidity
function updatePrice() external;
```

### _validatePaymasterUserOp

Validates a paymaster user operation and calculates the required token amount for the transaction.


```solidity
function _validatePaymasterUserOp(UserOperation calldata userOp, bytes32, uint256 requiredPreFund)
internal
override
returns (bytes memory context, uint256 validationResult);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`userOp`|`UserOperation`|The user operation data.|
|`<none>`|`bytes32`||
|`requiredPreFund`|`uint256`|The amount of tokens required for pre-funding.|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`context`|`bytes`|The context containing the token amount and user sender address (if applicable).|
|`validationResult`|`uint256`|A uint256 value indicating the result of the validation (always 0 in this implementation).|


### _postOp

Performs post-operation tasks, such as updating the token price and refunding excess tokens.

*This function is called after a user operation has been executed or reverted.*


```solidity
function _postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) internal override;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`mode`|`PostOpMode`|The post-operation mode (either successful or reverted).|
|`context`|`bytes`|The context containing the token amount and user sender address.|
|`actualGasCost`|`uint256`|The actual gas cost of the transaction.|


### fetchPrice

Fetches the latest price from the given Oracle.

*This function is used to get the latest price from the tokenOracle or nativeAssetOracle.*


```solidity
function fetchPrice(IOracle _oracle) internal view returns (uint192 price);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_oracle`|`IOracle`|The Oracle contract to fetch the price from.|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`price`|`uint192`|The latest price fetched from the Oracle.|


## Events
### ConfigUpdated

```solidity
event ConfigUpdated(uint32 priceMarkup, uint32 updateThreshold);
```

### UserOperationSponsored

```solidity
event UserOperationSponsored(address indexed user, uint256 actualTokenNeeded, uint256 actualGasCost);
```

Loading

0 comments on commit 1817d76

Please sign in to comment.