Skip to content

avichalp/solidity-contracts

Repository files navigation

Contracts

This repo contains a collection of solidity contracts to experiment with different projects on EVM based chains.

The contracts are compiled and tested using hardhat or Foundry. This repo also uses typechain to generate Typescript types for the solidity contracts, which makes it convenient for writing tests and scripts in JS/TS.

  1. Simple Staking is a staking pool that allows users to deposit and withdraw ETH or native tokens of other EVM chains. It also allows an admin to add funds to this contract to distribute the rewards to incentivize the depositors. The rewards that an individual depositor receives are proportional to their deposited stake.

  2. The Staking Token contract is similar to Simple Staking but also mints ERC20 tokens for the depositors. Later, the depositors can later redeem their sTokens for the native tokens they deposited plus the rewards accrued.

  3. Discrete GDA is an implementation of fixed rate gradual dutch autuion for NFTs. It works by holding a virtual Dutch auction for each token being sold. These auctions behave just like regular dutch auctions, with the ability for batches of auctions to be cleared efficiently. In a discrete GDA, every auction in a batch starts at the same time (T) but each successive (virtual) auction in a batch having a higher starting price. The price for every auction decays exponentially according to some decay function.

  4. Continuous GDA contract is an implementation of fixed rate continuous dutch auctions. They work by imcrementally (at a fixed rate) minting new tokens. The emissions are broken into an infinite series of virtual auctions. If a user tries purchase more tokens than available according to the emission rate and the elapsed time the transaction reverts.

  5. Math Utils A collection of utilities including muldiv, log2, ln, exp, pow etc. It works on fixed point fractional numbers such 59x18 and 60x18 (i.e. last 18 digits are reserved for decimals). Implementations are inspired from various posts written on the topic by Remco Bloemen, Mikhail Vladimirov, Alberto Cuesta Cañada and Paul Razvan Berg. These utilities are functional but not gas optimized yet.

Usage
Run tests
npm run test
Generate Typescript types for the solidity contracts
npm run types
Foundry tests
forge test -vvvv --ffi

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published