Deployed at goerli:
- address: 0x7F645349D81888904a146F0b52F48Ef189356D84
- address: 0xA4434dD27255f3A21e0829792832414CDD5f9a9C
npm install --save-dev hardhat
npx hardhat
npx hardhat compile
For understand the SafeMoon project, 1st we should understand the uniswap, and in this repo we explain the uniswap and provide some resources for more details.
explain the followings topics link:
- Centralized Exchange(CEX) and Decentralized Exchange(DEX)
- Market Maker
- Automated Market Maker(AMM)
- Constant Product Formula (k=x*y)
- Uniswap V2 Main Features
- Token Swap
- Liquidity Providing
- Provide two tokens to mint LP token
- Stake LP token
- Unstake LP token
- Burn LP token back to two tokens
- Oracle
- Flash Loans
There are two repositories which both contains two main smart contracts:
- Core
- Periphery
Core is for storing values(tokens) and managing them. It contains two smart contracts, Pair and Factory.
-
Pair: Smart contract that implements functionality for swapping, minting and burning tokens.
-
Factory: Creating and tracking pairs
Periphery, obviously, contains smart contract to interact with Core. It also contains two smart contracts, Router and Library
-
Router: Interacting with the core. Provides functionalities such as swapETHForExactTokens, swapExactETHForTokens, etc.
-
Library: Some functionalities like getReserves, getAmountIn, getAmountOut, etc.
explain the followings topics link:
- Pair
- Mint
- FeeOn and mintFee
- Burn
- Swap
- Swapping Fee
SafeMoon link
SafeMoon use the best math for the tokonomic. It's distribute the reward among all token holders
without transfering the tokens.
SafeMoon use the refelection
amount that will gradually decrease whenever the transaction will happen.
It's does not have any mint
and burn
method for minting the new tokens and for burning the existing tokens.
It's set their supplay 1 Quadrillion and transfer all tokens to the owner at their deployment time.
But their supplay will be gradually increase because when they give the reward to their token holders they actully mint the new token by using the math that they will use for transfering/give the reward.
Because thy use the refelection
that refelection will decrease after each transaction and this refelection
will impact on their total supplay and this the total mathematics.
And user can also burn their tokens by transfering the liqudity pool. It's did't have any burn
method but the tokens that will transfer to the liqudity pool
they can consider as the burn
.
And after each transaction some percentage of tokens will be burn as the form of liqudity fee and some percentage of token will mint as the form of reward using the refelection
amount.
And may be: When the refelection
amount will become 0 then no more token will be mint no reward will be transfer to the holders.
But when i read the code again i found require(rAmount <= _rTotal)
in tokenFromReflection(uint256 rAmount)
method
and found require(tAmount <= _tTotal)
in reflectionFromToken(uint256 tAmount, bool deductTransferFee)
method that
may be prevent the total supplay to croos the token total supplay limit.
1. orignal safeMoon contract that we copy from their [given](https://github.com/safemoonprotocol/Safemoon.sol/blob/main/Safemoon.sol) github rep can find [here](./contracts/SafeMoon.sol).
- and we also add comments and explain the safemoon contract and remove some unuse code which can found here.
-
interface IERC20: use for erc20 tokens.
-
library SafeMath: use for safe arithmetic operation.
-
abstract contract Context: use for get "msg.sender" and "msg.data".
-
library Address: use for collection of functions related to the address type
-
contract Ownable is Context: use for do some owner related operations (transferOwnership, onlyOwner, owner, etc).
-
interface IUniswapV2Factory: use for create liqudity pair eith "SafeMoon and WETH"
-
interface IUniswapV2Pair: this will not use in SafeMoon but when we create new liqudity pair that pair contract will be the instance of this interface.
-
interface IUniswapV2Router01: use for use the uniswap function
addLiquidityETH
. -
interface IUniswapV2Router02 is IUniswapV2Router01: use for the the uniswap function
swapExactTokensForETHSupportingFeeOnTransferTokens
. -
SafeMoon is Context, IERC20, Ownable: this is the actuall safemoon contract in which implement the app "SafeMoon" tokonomic.