Skip to content

Instantly share code, notes, and snippets.

@MiloTruck
MiloTruck / MockERC20Fee.sol
Created May 30, 2022 18:53
MockERC20 token that implements fee-on transfer.
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "solmate/tokens/ERC20.sol";
contract MockERC20Fee is ERC20 {
// 2% fee for all transfers
uint256 internal feeRate = (2 / 100) * 1 ether;
constructor(
string memory name_,
@MiloTruck
MiloTruck / EnumerableMapTest.sol
Last active June 15, 2023 05:42
Using `delete` on OpenZeppelin's EnumerableSet/EnumerableMap
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
contract EnumerableMapTest is Test {
using EnumerableMap for EnumerableMap.AddressToUintMap;
EnumerableMap.AddressToUintMap map;
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;
library Execution {
function functionCallWithValue(
address to,
uint256 value,
bytes memory data
) internal returns (bytes memory) {
assembly {
@MiloTruck
MiloTruck / M-01.t.sol
Last active August 30, 2023 18:12
PoCs for LUKSO Audit Report
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../../contracts/LSP0ERC725Account/LSP0ERC725Account.sol";
contract Implementation {
// _pendingOwner is at slot 3 for LSP0ERC725Account
bytes32[3] __gap;
address _pendingOwner;
@MiloTruck
MiloTruck / Vault.sol
Created October 13, 2023 03:16
Foundry Snapshots
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
// From https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol
import {ERC20} from './ERC20.sol';
contract Vault is ERC20 {
// Underlying asset
ERC20 public token;
@MiloTruck
MiloTruck / aggregator-risk-idea.md
Created July 11, 2024 14:51 — forked from 0xngmi/aggregator-risk-idea.md
Aggregator with customized user risk profiles

Background

In the current market, yield farmers have only 2 options: either deposit into a yield aggregator that completely manages their money for them, making all the risk assessments and moving their money between protocols, or just run everything on their own, moving their money continuously between protocols, at most using an auto-compounder on a single vault for some automation.

However, not everyone has the same risk profile and thus fully managed aggregators won't fit everyone, while on the other hand there's a big market of people that don't like constantly having to manage their positions and shuffle their funds. These two options are the 2 extremes, either fully managed or DYI.

Because of this I believe there's a market for users that want some automation while being able to set their own risk profile.

Idea

I propose a protocol where users deposit funds along with policies on how those funds can be deployed, and then the protocol optimizes their position within those boundaries and automat