-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8566870
commit 1817d76
Showing
25 changed files
with
1,132 additions
and
18 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
docs/docs/contracts/src/src/TestingErc20.sol/contract.TestingErc20.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/docs/contracts/src/src/bridge/BridgeState.sol/library.BridgeState.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/docs/contracts/src/src/bridge/IRelay.sol/interface.IRelay.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/docs/contracts/src/src/bridge/WitnessTx.sol/library.WitnessTx.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/docs/contracts/src/src/faucet/Erc20Minter.sol/contract.Erc20Minter.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/docs/contracts/src/src/faucet/Erc20Minter.sol/interface.Erc20Mintable.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
229 changes: 229 additions & 0 deletions
229
...sters/AccountAbstraction/AATokenPaymaster.sol/contract.PimlicoERC20Paymaster.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` | ||
|
Oops, something went wrong.