Skip to content

Instantly share code, notes, and snippets.

View kanthgithub's full-sized avatar
👨‍💻

lakshmi kanth kanthgithub

👨‍💻
  • India
View GitHub Profile
@kanthgithub
kanthgithub / async.md
Created December 6, 2024 04:32 — forked from chriseth/async.md
Async Solidity Contracts

Having seen @pirapira's sketch of Bamboo ( https://github.com/pirapira/bamboo/ ), which proposed to add better control about the "smart contract program flow", even across calls, I thought that this should certainly be added to Solidity, and actually, it might even be possible now to a certain degree using inline assembly.

The problem is that with many functions in a contract, it is not always clear which can be called at which stage in the contract's lifetime. Certain smart contracts would be easier to understand if written as follows:

@kanthgithub
kanthgithub / MerkleDistributor.sol
Created July 12, 2024 03:01
multipool-merkel-rewards
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
interface IERC20 {
function transfer(address recipient, uint256 amount)
external
returns (bool);
@kanthgithub
kanthgithub / MinHeap.MD
Last active March 31, 2024 10:16
OrderBook-Offchain

MinHeap for AskOrder Storage

  • let's walk through the step-by-step process of how a tree is constructed in a heap, specifically focusing on a minHeap used for managing ask orders. We'll use a simple example to illustrate the process from the ground up, ensuring to cover how elements are added and how the heap maintains its essential properties.

Basics of a MinHeap

A minHeap is a binary tree that satisfies two properties: Shape Property: It's a complete binary tree; that is, all levels are fully filled except possibly the last level, which is filled from left to right. MinHeap Property: Every node is less than or equal to its children. Constructing a MinHeap: Step-by-Step Let's construct a minHeap from an initial blank state, adding elements one at a time. We're managing ask orders, so the heap is organized by price.

@kanthgithub
kanthgithub / git-fork-contribution-self-guide.MD
Last active March 22, 2024 20:03
git-fork-contribution-self-guide

New Feature on Fork Repo

  • create a new branch for each new feature or bug fix you're working on.
  • This keeps your work organized and separated from the main code base. Here's how you can do it:
  1. make sure you're on the main branch and it's up-to-date with the upstream repository:
git checkout main
git pull upstream main
@kanthgithub
kanthgithub / lakshmi-kanth-defi-coverletter.MD
Last active March 22, 2024 20:11
lakshmi-kanth-defi-coverletter

Summary of DeFi Project Experience & Open source

Developer Experience Gist

  1. 4+ years of Smart contract and Web3 Backend Engineering
  2. 14 years of Backend Engineering - Banking, Fintech Products, Integration

Driving Factor in Web3 and DeFi

  1. I am a DeGen and a user/developer obsessed builder with attention to detail
@kanthgithub
kanthgithub / slither-report-direct-staking.MD
Created March 7, 2024 05:57
slither-report-direct-staking

➜ direct_stake git:(main) ✗ slither .

'npx hardhat clean' running (wd: /Users/kanth/Documents/defi/staking/direct_stake) 'npx hardhat clean --global' running (wd: /Users/kanth/Documents/defi/staking/direct_stake) 'npx hardhat compile --force' running (wd: /Users/kanth/Documents/defi/staking/direct_stake)

INFO:Detectors: LynxDirectStaking._deposit(bytes,bytes,bytes32) (contracts/0.8.24/LynxDirectStaking.sol#423-462) sends eth to arbitrary user Dangerous calls:

@kanthgithub
kanthgithub / blur-nft-close-loan-transaction-anatomy.MD
Last active February 25, 2024 09:54
blur-nft-close-loan-transaction-anatomy
@kanthgithub
kanthgithub / HandleUserOpsWithPayMaster.ts
Created January 20, 2024 02:34
Example to handle a userOp via Paymaster
const { ethers } = require("hardhat");
const { JsonRpcProvider } = require("@ethersproject/providers");
const {
EntryPointAddress,
SCAddress,
VerifyingPaymasterAddress,
PayMaster_PRV_KEY,
POOL_PRV_KEY,
} = require("./data.js");
@kanthgithub
kanthgithub / auction-dht.js
Last active January 7, 2024 11:38
hyperswarm-dht-rpc-server-startup-issue
const crypto = require('crypto');
const DHT = require('@hyperswarm/dht');
const Hyperbee = require('hyperbee');
const Hypercore = require('hypercore');
const sodium = require('sodium-native');
const HyperswarmRPC = require('@hyperswarm/rpc');
const AuctionHandler = require('../auction/auction-handler');
const BidHandler = require('../auction/bid-handler');
class Peer {
@kanthgithub
kanthgithub / marinade-stake.ts
Created December 20, 2023 13:52
script used to stake on marinade (solana)
import { Marinade, MarinadeConfig } from '@marinade.finance/marinade-ts-sdk'
import { config } from 'dotenv';
import { Keypair, Connection, PublicKey, clusterApiUrl } from '@solana/web3.js';
import bs58 from 'bs58';
config();
const SECRET_KEY: string = process.env.PRIVATE_KEY!;
const secretKeyBytes: Uint8Array = new Uint8Array(bs58.decode(SECRET_KEY));
const wallet: Keypair = Keypair.fromSecretKey(secretKeyBytes);