Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pyk/singleton
Simple and reusable singleton smart contract that supports ERC3156
https://github.com/pyk/singleton
erc20 erc3156 ethereum solidity
Last synced: about 1 month ago
JSON representation
Simple and reusable singleton smart contract that supports ERC3156
- Host: GitHub
- URL: https://github.com/pyk/singleton
- Owner: pyk
- Created: 2023-08-03T23:24:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-17T04:41:52.000Z (over 1 year ago)
- Last Synced: 2024-10-27T11:26:04.558Z (3 months ago)
- Topics: erc20, erc3156, ethereum, solidity
- Language: Solidity
- Homepage:
- Size: 10.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Singleton
Singleton ERC20 vault contract with flash loan support.
## Features
- ✅ Compatible with any ERC20
- ✅ Reduce gas fees on ERC20 transfer via internal transfer
- ✅ Support ERC3156 (Flash Loan) with custom fees & recipient## Get started
Install and use directly on your project:
```sh
forge install pyk/singleton
```Example usage:
```sol
import {Singleton} from "singleton/Singleton.sol";contract MyVault is Singleton {
constructor(adddress owner, uint256 fees) Singleton(owner, fees) {
//
}
}
```Or deploy directly using the factory:
- Ethereum (_To be deployed_)
- Arbitrum (_To be deployed_)
- Optimism (_To be deployed_)
- Base (_To be deployed_)## Tests
Run test using the following command:
```sh
forge test --fork-url ETH_RPC_URL
``````
[⠢] Compiling...
No files changed, compilation skippedRunning 12 tests for test/Singleton.t.sol:SingletonTest
[PASS] testDeposit() (gas: 219034)
[PASS] testDepositWithCustomAccount() (gas: 220687)
[PASS] testDepositWithZeroAmount() (gas: 162848)
[PASS] testFlashLoanFee() (gas: 220030)
[PASS] testFlashLoanMax() (gas: 217064)
[PASS] testFlashLoanWithBorrowerNotRepaid() (gas: 689035)
[PASS] testFlashLoanWithInvalidBorrower() (gas: 383503)
[PASS] testFlashLoanWithValidBorrower() (gas: 714253)
[PASS] testTransfer() (gas: 239685)
[PASS] testWithdraw() (gas: 241137)
[PASS] testWithdrawWithAmountGreaterThanBalance() (gas: 220333)
[PASS] testWithdrawWithCustomRecipient() (gas: 245264)
Test result: ok. 12 passed; 0 failed; 0 skipped; finished in 3.38s
Ran 1 test suites: 12 tests passed, 0 failed, 0 skipped (12 total tests)
```