Skip to content

Instantly share code, notes, and snippets.

View dhruvinparikh's full-sized avatar
💭
😈 | Building cool stuff at @FraxFinance | Breaking stuff

Dhruvin Parikh dhruvinparikh

💭
😈 | Building cool stuff at @FraxFinance | Breaking stuff
View GitHub Profile
@dhruvinparikh
dhruvinparikh / LZEndpointDollar.sol
Created February 23, 2026 20:24
Native Alt token Supported by LZ on tempo mainnet
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import { IERC20 } from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import { EnumerableSet } from "lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol";
import { IERC20Metadata } from "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { ReentrancyGuardTransient } from "lib/openzeppelin-contracts/contracts/utils/ReentrancyGuardTransient.sol";
import { Ownable2StepUpgradeable } from "lib/openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol";
import { ERC20PermitUpgradeable } from "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
require("dotenv").config("./.env")
const { Chain, Common, Hardfork } = require('@ethereumjs/common')
const { FeeMarketEIP1559Transaction } = require('@ethereumjs/tx')
const { bytesToHex } = require('@ethereumjs/util')
const axios = require("axios")
async function main() {
const common = new Common({ chain: Chain.Sepolia, hardfork: Hardfork.Cancun })
const txData = {

Generating PGP Keys

Install GPG (GnuPG):

  • On Linux, you can install GPG via your package manager. For example, on Debian-based systems, you can use sudo apt-get install gnupg.

Generate Your Key Pair:

  • Open a terminal or command prompt and run the following command:
gpg --full-generate-key
@dhruvinparikh
dhruvinparikh / dai-permit.js
Created February 1, 2024 17:00
DAI Permit from inspect window via metamask
from : "" // holder address
message = {
holder: from,
spender: "0x3d573f130125E1a510b65f2aD258ec4f88Ca7023",
nonce: 0, // update nonce
expiry: 1706806653, // update expiry
allowed: true,
};
msgParams = JSON.stringify({
@dhruvinparikh
dhruvinparikh / gist:65dce4c9ceeae201d51015bf19616a68
Last active November 23, 2023 22:09
UniswapV2 Swap Fee Math
getAmountOut
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
(_tokenOutReserves * _tokenInReserves)
amountOut = _tokenOutReserves - -------------------------------------
(_tokenOutReserves + _amountTokenIn)
@dhruvinparikh
dhruvinparikh / ConcurrentApiCalls.sh
Created May 12, 2023 23:17
Concurrently hits server with API calls
#!/bin/bash
# function to start the instances
start_instances() {
for i in {1..5}; do
node ./multicalls.js &
sleep 10
done
}
@dhruvinparikh
dhruvinparikh / admin.sql
Created May 6, 2022 20:19
Admin sql commands
SELECT * FROM pg_stat_activity;
SELECT pg_cancel_backend(15762);
SELECT pg_terminate_backend(15762);
select c.oid,pg_catalog.pg_total_relation_size(c.oid) as total_rel_size,pg_catalog.pg_relation_size(c.oid) as rel_size
FROM pg_class c WHERE c.relnamespace=$1
select * from pg_class;
@dhruvinparikh
dhruvinparikh / rm-duplicate.sql
Created May 6, 2022 20:17
Remove duplicate block number rows
delete from "alphaPROD".public."fhusd3CRV_data" a using "alphaPROD".public."fhusd3CRV_data" b where a.id < b.id and a.block = b.block;
delete from "alphaPROD".public."3Crv_data" a using "alphaPROD".public."3Crv_data" b where a.id < b.id and a.block = b.block;
delete from "alphaPROD".public."aAAVE_data" a using "alphaPROD".public."aAAVE_data" b where a.id < b.id and a.block = b.block;
delete from "alphaPROD".public."aBAT_data" a using "alphaPROD".public."aBAT_data" b where a.id < b.id and a.block = b.block;
delete from "alphaPROD".public."aBUSD_data" a using "alphaPROD".public."aBUSD_data" b where a.id < b.id and a.block = b.block;
@dhruvinparikh
dhruvinparikh / vacuum-script.sql
Created May 6, 2022 20:15
SQL to perform vacuum on postgresql
vacuum full "alphaPROD".public."fhusd3CRV_data";
vacuum full "alphaPROD".public."3Crv_data";
vacuum full "alphaPROD".public."aAAVE_data";
vacuum full "alphaPROD".public."aBAT_data";
vacuum full "alphaPROD".public."aBUSD_data";
// SPDX-License-Identifier:MIT
pragma solidity ^0.8.10;
contract ABIEncoding {
function fun(bool _x, uint _y) public pure returns(bytes4 _data) {
// _data = this.fun.selector;
_data = bytes4(keccak256("fun(bool,uint256)"));
}