This project is copied from sashimiswap and modified to work with non-mintable tokens.
npm install
npm test
Create a .env
file with keys
MNEMONIC="..."
INFURA_ID="..."
ETHERSCAN_API_KEY="..."
- Deployment to rinkeby is done via Infura.
- Create an Etherscan API key for contract verification.
Forks of this project should also modify config.json
. Decimals aren't considered in the configuration.
Ganache is a personal Ethereum blockchain for development and tests.
truffle migrate -- --network development
To deploy on the Rinkeby Ethereum testnet, make sure your wallet has enough ETH to pay for the GAS.
truffle migrate -- --network rinkeby
truffle run verify -- --network rinkeby
You may also want to verify the ERC20Mock and LPMock contracts on Etherscan.
node_modules/.bin/truffle verify ERC20Mock
node_modules/.bin/truffle verify LPMock
Verification may fail because of rate limits. Just try again.
truffle migrate -- --network mainnet
truffle run verify -- --network mainnet
The account that is used to create the Farm contract should have a sufficient amount of (LTO) ERC20 to fund the contract. Alternatively; to manually fund, remove the 'fund' property from the configuration.
The Farm
contract will distribute ERC20 tokens to participants relative to the number of LP tokens deposited to the
contract. These ERC20 tokens aren't minted. Instead, the contract needs to be funded.
The address of the ERC20 token, the reward per block, and the starting block are specified in the constructor of the
Farm
contract.
The contract needs to be funded before the start block.
To fund the contract, the Farm
must be allowed to withdraw the amount of ERC20 using the approve
method of the ERC20
contract.
Call the fund
method with the appropriate amount The end block is calculated as
endBlock = startBlock + (funds / rewardPerBlock)
It's possible to add funds with the farm is running and increase the end block.
If the end block is reached, the farm is closed and it will no longer be possible to add funds.
Tokens are distributes amount users that has deposited specific LP tokens. These LP tokens are distributed by the Uniswap contract for providing liqidity. Other LP tokens could be used as well.
Each LP token has a specific contract address which can be found on the Uniswap exchange.
Use the add
method to add a liquidity pair for which the farm will pay out a reward.
It's possible to add liquidity pairs at a later time. The reward is shared over all pairs.
The add
method takes an allocPoint
parameter. When adding multiple pairs, this decides the portion of the reward
shared for that LP token.
Example: the farm is configured for 3 pairs with an allocPoint
of resp 6, 12, 18. The
total alloc points is 36. 1/6th of the tokens is distributed under participants that deposited the pair with 6
alloc points: (6 / 36 = 1/6
).
It's possible to change the alloc points at a later time via the update
method.
To participate in farming, users must deposit LP tokens using the deposit
method.
Before using this method, the farm must be allowed to withdraw the LP tokens. This is done via the approve
method on
the LP token contract.
The current deposit can be check using the deposited
method.
Participants can withdraw their LP tokens at any time using the withdraw
method.
Each participant has a pending reward which is hold by the farm. The pending reward can be checked using the pending
method.
Any change to the deposit of the participant (with deposit
or withdraw
), will pay out the pending reward. It's
possible to do a zero withdraw to just receive the pending reward.
Farm: https://testnet.bscscan.com/address/0xa0e3aec3d84911a4e1e95b013453eb27d63bd4cc
IPO MOCK TOKEN: https://testnet.bscscan.com/token/0x5f9e0f75a459453cba8a07519ce85ffc8e03ef47
FARM: https://kovan.etherscan.io/address/0xdcc83498Bd687Dda3e51aA98B0d09795370e08E7
LP MOCK : https://kovan.etherscan.io/address/0x791c567484fE64209C1B819d179fe10797a0f753
LTO MOCK TOKEN : https://kovan.etherscan.io/token/0x5a3D821F02e39c1f74CD3A2AEF2d5F5A94c27321