Skip to content

Instantly share code, notes, and snippets.

View ArpitxGit's full-sized avatar
🎯
Focusing

dungexn ArpitxGit

🎯
Focusing
View GitHub Profile
@ArpitxGit
ArpitxGit / AvatarCollection.sol
Created February 22, 2023 06:34
Dynamic NFT Collection
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract AvatarCollection {
struct Avatar {
uint id;
string name;
string imageURI;
address owner;
}

The goal is to

  • Continuously monitor the impermanent loss incurred for a position in Uniswap V3
  • And if there is a loss, we need to exit the position
  • It has to be 100% automated (the end user should not be expected to be online signing the transaction when the liquidity is pulled out)

Monitoring a position

We can use the Uniswap V3's subgraph to know a position's details like tokens, price at the time of providing liquidity, etc. We will also know the current tick in the pool.

@ArpitxGit
ArpitxGit / Readme.md
Created December 5, 2022 10:52
Merkle Tree
  • MERKLE TREE:

Merkle trees are a fundamental data structure in distributed systems and blockchain technology. They are used to efficiently and securely verify the integrity of data, and they have become a key building block for many decentralized applications.
In the context of solidity, a merkle tree is a tree-like data structure that is used to store and verify the integrity of data in a smart contract. Solidity is a programming language for writing smart contracts on the Ethereum blockchain, and it provides support for implementing and using merkle trees.
A merkle tree is constructed by taking a set of data items, called leaves, and hashing them to produce a set of intermediate nodes. The intermediate nodes are then hashed together to produce another set of nodes, and this process is repeated until a single root node is produced. The root node is called the merkle root, and it is a unique identifier for the entire tree.

Merkle trees have several benefits and advantages, which make them a valua

@ArpitxGit
ArpitxGit / Gateway.sol
Created December 4, 2022 11:43
NFT Bridge for Starknet
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "./IStarknetCore.sol";
contract Gateway {
uint256 public endpointGateway;
IStarknetCore public starknetCore;
uint256 constant ENDPOINT_GATEWAY_SELECTOR =
@ArpitxGit
ArpitxGit / TimeLock.sol
Created August 3, 2022 22:45
Delaying Transaction with Time Lock
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
/*
Contract to Delay Transaction
"for security puposes or taking fail safe measuers
as users trust contract more than anything."
1. You are going to broadcast a transaction
that you are going to execute,
@ArpitxGit
ArpitxGit / EIP4973.sol
Last active June 23, 2022 06:42
SoulBound/AccountBount Token
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.6;
/*
Compiliing reference implmentation of EIP4973
By accumulating all mentioned interfaces
And solving few errors
*/
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IERC721Metadata} from "./IERC721Metadata.sol";
@ArpitxGit
ArpitxGit / PaymentSplitter.sol
Created June 20, 2022 22:31
Smart Contract to Split Payments
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
//contract for splitting payments
contract PaymentSplitter {
//array for holding addresses, public, payable
address payable [] public recipients;
//lastly adding event for use in application
@ArpitxGit
ArpitxGit / README.txt
Last active May 29, 2021 10:08
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS