Skip to content

Instantly share code, notes, and snippets.

View voith's full-sized avatar
👨‍🎓
Building on top of Ethereum

Voith voith

👨‍🎓
Building on top of Ethereum
View GitHub Profile
@voith
voith / IParaswapV6.sol
Created September 9, 2024 20:09
Paraswap contract interface
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.6.10;
pragma experimental ABIEncoderV2;
struct GenericData {
address srcToken;
address destToken;
uint256 fromAmount;
uint256 toAmount;
uint256 quotedAmount;
@voith
voith / ForkTestHack.t.sol
Created August 15, 2024 21:30
Forge test to show how funds were stolen in trx: 0x2498dede022399f734edecd58484c7adad5b2a127f1fa1fda655dade86a1a8f3
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.6.10;
pragma experimental ABIEncoderV2;
import "forge-std/Test.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {TokenExchangeSetIssuer} from "contracts/extensions/TokenExchangeSetIssuer.sol";
import {BasicIssuanceModule} from "contracts/modules/BasicIssuanceModule.sol";
import {ISetToken} from "contracts/interfaces/ISetToken.sol";
@voith
voith / TransferMainnetToBase.s.sol
Last active August 13, 2024 22:43
forge script for transferring tokens from mainnet to base using CCIP
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Script.sol";
import "forge-std/console.sol";
import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/utils/SafeERC20.sol";
@voith
voith / chainlink_data_streams.py
Last active August 14, 2024 13:05
Python script for fetching multiple feed data from chainlink's data streams api
@voith
voith / FlokiTaxAdjust.sol
Created July 18, 2024 15:01
Floki tax adjustment
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.17;
import "forge-std/Test.sol";
import "forge-std/console.sol";
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
@voith
voith / gas_price_feed.py
Last active December 18, 2023 18:07
Snippet for creating a gas price in USDC feed
ORACLE_ABI = """[{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"},{"internalType":"address","name":"_accessController","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int256","name":"current","type":"int256"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"updatedAt","type":"uint256"}],"name":"AnswerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":true,"internalType":"address","name":"startedBy","type":"address"},{"indexed":false,"internalType":"uint256","name":"startedAt","type":"uint256"}],"name":"NewRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","
@voith
voith / BeaconProxyTest.t.sol
Last active August 31, 2023 21:37
A basic demo of the BeaconProxy pattern in solidity with usage demonstrated using foundry tests
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;
import "forge-std/Test.sol";
import "forge-std/console.sol";
import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
@voith
voith / read_private_var.sol
Last active August 24, 2023 12:55
Snippet for reading private variables using foundry
function testReadPrivateVars() external {
for(uint i=0; i < 100; i++){
console.logBytes32(vm.load(address, bytes32(i)));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract ChainlinkTCAPAggregatorV3 {
struct RoundData {
uint80 roundId;
uint80 answeredInRound;
int256 answer;
uint256 startedAt;
uint256 updatedAt;
@voith
voith / redbeat_run_tasks.py
Created June 6, 2023 12:16
Script to run redbeat tasks
from collections import namedtuple
from rebate_program.celery import app # get the celery app object from your project
from redbeat.schedulers import RedBeatScheduler, acquire_distributed_beat_lock
beat = RedBeatScheduler(app)
Sender = namedtuple('sender', ['scheduler'])
sender = Sender(beat)
acquire_distributed_beat_lock(sender)
print(beat.schedule)