Bullionix / Bullionix_phase1

Bullionix framework - laying the foundations.
GNU General Public License v3.0
0 stars 0 forks source link

Complete unit testing for Bullionix721.sol #2

Open VexyCats opened 5 years ago

VexyCats commented 5 years ago

Bullionix721.sol is finished but needs unit testing done to provide 100% coverage.

Some tests have already been added - but not actually tested. Meaning they probably don't work on truffle -test, until some tweaking is done.

Whats the function of Bullionix721.sol?

Bullionix721.sol is a smart contract, that allows for staking of an ERC20 token (DGX) to an NFT (ERC-721). This lets a user send DGX to Bullionix721.sol, and in return they get an NFT that tracks the amount staked to it. They can burn their NFT and get back their DGX whenever they want.

  1. Create a new series - the owner of the contract can add new gold token series - such as a rare vitalik series, that requires 10 DGX (example numbers), or a common Crypto Series, that takes only 1 DGX.
  2. Staking - Users will call the stake function after they have approved the contract to move the required DGX amount. Once calling stake, the DGX balance is sent to the smart contract and upon successful balance changes - the user is given an NFT that tracks the staked amount minus the fees.
  3. User Withdrawals - users can burn their NFTs and get back their DGX that they staked (minus the DGX fees, and our fees).
  4. IsOnline/Owner Withdrawal - Isonline is just a flag to toggle the functionality of the contract in case of a black swan event. Owner Withdrawal is for the owner of the contract to withdrawal the fees collected in the contract.
  5. Fees - fees are set during create new series - there are two fees, the amount of DGX to stake, and the fee for bullionix. For example, the vitalik series that takes 10 DGX is the DGXCost variable, and the fee would be set by the owner as the amount Bullionix would profit from each NFT made. So in the vitalik example - it would be 10 DGXCost, Fee of 0.5 DGX. (dummy numbers).

DummyToken is deployed to act as DGX during the testing/testnet.

DGX contract has two fees that happen on any ERC20 transfer:

  1. transfer fees - a small fee taken everytime DGX is moved. This means, we need to calculate the fee, and check that the amount sent to Bullionix is (properAmount - DGXtransferFee)
  2. demurrage fees (storage fees) - not activated YET, but will be - so we need to check that the demurrage fee is properly calculated before staking and withdrawals. Demurrage is calculated via (rate/base) per day. You can see an example of the rate and base in the dummyToken.sol.

They have a kovan DGX contract on the testnet at: 0xaed4fc9663420ec8a6c892065bba49c935581dce

And the main contract for the mainnet is at: 0xbb246ee3fa95b88b3b55a796346313738c6e0150

This, above ^, is just to let you understand the flow of the smart contract to help with testing.

Testing needs to be done to cover the entire scope of the smart contract, not just what was mentioned above.

Write Unit Testing to provide 100% coverage

Bullionx721.js is the test file.

Test need to cover the functionality of the Bullionix721.sol smart contract, as well as the other contracts used to mimic the DGX contract.

If you have any questions feel free to ask them or reach out on gitcoin.

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.5 ETH (91.48 USD @ $182.96/ETH) attached to it.

gitcoinbot commented 4 years ago

@vishesh-gupta Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

viraj124 commented 4 years ago

@VexyCats thinking of working on this bounty, I have some queries what's black swan even?

viraj124 commented 4 years ago

mentioned in isOnline functionality

VexyCats commented 4 years ago

Hey there, would love to have you work on it!

Black swan event is when something tragic happens, like compete failure of something, or catastrophic bugs. Where turning the smart contracts functionality offline is needed to prevent all users from losing funds.

Anything that would cause all users to lose funds - or anything such as DGX being hacked or losing its peg to the gold value would be considered black swan events.

gitcoinbot commented 4 years ago

@sanchaymittal Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

computerpoet commented 4 years ago

Right now the contracts don't compile.

import './ERC721Full.sol'; import './Ownable.sol'; import './IERC721Enumerable.sol'; import './IERC721Metadata.sol'; import './ERC721MetadataMintable.sol'; import './SafeMath.sol';

Those contracts are not included in the repository, and the import to openzeppelin was removed in Commit: 3cc5439310a3adf93b601e9dac7411ce788d0a1e [3cc5439].

gitcoinbot commented 4 years ago

@sanchaymittal Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

VexyCats commented 4 years ago

@DaLN You need to run npm install before hand in order to get the openzeppelin contracts.

computerpoet commented 4 years ago

I did, issue is that with the last commit, the import reference files in the same folder as your contracts, not the open-zeppelin ones.

VexyCats commented 4 years ago

Oh. Thank you. I've pushed a fix to the import statements. Compiles now with truffle.

gitcoinbot commented 4 years ago

@sanchaymittal Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of this issue was increased to 1.0 ETH (147.85 USD @ $147.85/ETH) .

computerpoet commented 4 years ago

Thanks @VexyCats !