Check out the Issue Explorer
Looking to fund some work? You can submit a new Funded Issue here.
## Before you `start work`
Please read our contribution [guidelines](https://docs.marketprotocol.io/#contributing) and if there is a bounty involved please also see [here](https://docs.marketprotocol.io/#gitcoin-and-bounties)
If you have ongoing work from other bounties with us where funding has not been released, please do not pick up a new issue. We would like to involve as many contributors as possible and parallelize the work flow as much as possible.
Please make sure to comment in the issue here immediately after starting work so we know your plans for implementation and a timeline.
Please also note that in order for work to be accepted, all code must be accompanied by test cases as well.
### User Story
As a user, I would hope that all possible validations are done off chain, prior to creating an on chain transaction that is going to cost gas even if it reverts / fails
### Why Is this Needed?
*Summary*: Help with validation and error messaging.
[comment]: # (Feature or Bug? i.e Type: Bug)
*Summary*: validate as much as possible before calling `depositCollateralAsync` or `withdrawCollateralAsync`
### Definition of Done
#### For `depositCollateralAsync`
- [ ] Ensure caller is enabled for contract by calling mktTokenContract.isUserEnabledForContract() if not return MarketError.UserNotEnabledForContract
- [ ] Ensure caller has sufficient ERC20 token balance, if not return a MarketError.InsufficientBalance error
- [ ] Ensure caller has called ERC20.approve() for sufficient amount to allow for transaction to succeed, if not return a if not return a MarketError.InsufficientApproval error
- [ ] Add tests for all scenarios and ensure proper errors are returned
#### For `withdrawCollateralAsync`
- [ ] Ensure user has sufficient balance in the collateral pool to withdraw, if not return MarketError.InsufficientBalance error
- [ ] Add test for this scenario to ensure proper error is returned
### Additional Information
The MarketError object has been created, but isn't released in a npm package yet - see here
For the time being, we can dupliacte the enum in this repo as needed for testing / dev - cc @eswarasai