# PaladinFinance - Notes
We are building a governance lending platform for DeFi governance tokens.
## General Repo Notes
Repo: https://github.com/PaladinFinance/frontendv2
Design: https://www.figma.com/file/VGYFllY0nQfmLP364oTLSd/Paladin-v1?node-id=41%3A0
Deployment: https://inspiring-mirzakhani-252981.netlify.app/
New Deployment: https://goofy-stonebraker-670711.netlify.app/
## To Do
### General
- [x] hamburger menu needs to be removed from desktop screens
- [x] fix link when clicking on the logo
- [x] change the logo (the one currently used is blurry) -> find here : https://drive.google.com/drive/folders/1rVV0tv7jyk7HAQDFgnlYsH8pYruzylCh?usp=sharing
- [x] add MAX button to inputs (withdraw, borrow, supply modals)
### Dashboard
- [x] swap the modals on Dashboard : the one when clicking on an element in "Loan Positions" & the one when clicking on a line in "Deposits"
- [x] voting power box on dashboard needs to be changed to design in figma
- [x] closed loan positions on dashboard shouldn't be clickable
- [x] correct withdraw asset to pal-token asset
- [x] align token symbols in withdraw modal
- [x] the white boxed on the dashboard should be of equal size & titles aligned
### Borrow
- [x] block the 7 next day in the calendar (minimum Borrow time is 7 days currently). The borrow time is calculated in blocks in the contracts. This calendar allows to have a starting time (current time), and an ending time (the choosen date, at 00:00). This time should then be converted to blocks, and the Borrow Rate can then be used to find the required amount of fees to cover the desired time of the Borrow. (-> This is not an issue when the user wants to extend the Borrow)
- [x] add text about security measure to borrow modal (in figma)
### Supply
- [x] fix text in supply modal to "available to deposit"
- [x] align columns on supply page
### Others
- [x] When Borrowing, or Extending : Also, make possible to enter an input of desired fees to pay instead of using the calendar (the desired amount should be more than the minimum required fees -> functions to calculate that in the smart contracts)
- [x] (for a Borrow, with the minimum required fees : add 10% to the required amount, in case the Borrow Rate goes up between display and the actual transaction -> so the transaction doesn't get reverted)
- [x] add info tooltip to borrow modal & extend modal (same one about borrow duration)
### Web3
- [x] make wallet connect work only on Kovan (for testnet purposes)
- [x] Most of the data to fetch from the contracts can be fetched from a palPool (TVL, exchange Rate, Borrow & Supply rates, and user balance in palToken linked to the pool (+ how much it represents in the underlying token))
- [x] The only data not found through this contract is the voting power (of the user or currently available in the pool). To get that data, the ABIs for the token, and use the method to calculate the voting power (for COMP and UNI : COMP_like_token -> getCurrentVotes & for AAVE and stkAAVE : AAVE_tokens.json -> getPowerCurrent (DelegationType is VOTING_POWER))
- [x] If prefered, the total ABI for the token can be used directly (doing both ERC20 functions & voting power/delegation/etc ...)
For Solidity methods, see [CONTRACTS.md](https://github.com/PaladinFinance/frontendv2/blob/master/CONTRACTS.md)
## Estimated Hours
1. - [x] Fully disect repo - 1 hour
2. - [x] Convert to Typescript - 2 hours
3. - [x] Add types
4. - [x] Add linting & Prettier - 1 hour
5. - [x] Add `styled-components` - 3 hours
6. - [x] Add missing public folder files (favicon)
7. - [x] Add CI/CD
8. - [x] Improve responsiveness
9. - [x] [General changes](https://github.com/PaladinFinance/frontendv2/pull/4) - 2 hours
10. - [x] [Dashboard view changes](https://github.com/PaladinFinance/frontendv2/pull/5) - 4 hours
11. - [x] [Borrow view changes](https://github.com/PaladinFinance/frontendv2/pull/5) - 2 hours
12. - [x] [Supply view changes]((https://github.com/PaladinFinance/frontendv2/pull/5)) - 1 hour
13. - [x] [Others changes](https://github.com/PaladinFinance/frontendv2/pull/9) - 3 hours
14. - [x] Switch to `ethers.js` - 2 hours
15. - [x] Web3 changes - 4 hours
16. - [x] Add utility tests - 2 hours
17. - [x] Web3 calculations & testing - 5 hours
Total hours: 32
Total hours with (1 day) buffer: 40
## Data Fetching
### Supply
#### PalPool Contract
- APY: (`supplyRatePerBlock` / `2336000`) / 100
- APY (last 30 days): `APY` / 30
- Daily: `APY` / 365
- Total Value Locked: `balanceOf`
#### Underlying Token Contract
- Balance of underlying token: `balanceOF`
### Deposits
#### PalPool Contract
- PalToken Balance: `balanceOf`
- Total Value Locked: `balanceOf`
- APY: (`supplyRatePerBlock` / `2336000`) / 100
#### Underlying Token Contract
- Balance of underlying token: `balanceOF`
### Loan Positions
- Lists each token:
- `getLoansByBorrower(address borrower) external view returns(address [] memory);`
- `getBorrowDataStored(address)`
- Status:
- `getBorrowDataStored(address __loanPool)`
- Returns object with `bool _closed`
- Voting Power:
- `getBorrowDataStored(address __loanPool)`
- Returns object with `uint _amount`
- Fee:
- `getBorrowDataStored(address __loanPool)`
- Returns object with `_feesUsed`
## Addresses
Controller : `0x038A415f957E0b680D0E122968d741556a8b1070`
Interest Module : `0xd815463E5f8175b1c3D6a9E03718Dd1C90869297`
Basic Delegator : `0xbF33E5408f1EFAc2C848593cC17EF85F1f10aFF7`
AAVE Delegator : `0xF3747630F2525a0cC893c56792f0536cf382432e`
palAAVE Token : `0x4919713016B14c8BE309799f4AC1550B3AfC2ff0`
palAAVE Pool : `0x3cFCaDD2ecd181d6Ff2F3c7229F92F63e15BD92b`
palCOMP Token : `0x5c707Ead982bBCfcf570fa0d41f7C685fAD98efB`
palCOMP Pool : `0xb5611FE646a4A33FA88993A20265BAfA785653df`
palUNI Token : `0x2C7834Bc2f62Ec46De124E98108105d293b592dB`
palUNI Pool : `0xD41A321784B243aF4022f993365ca7E198B9bFd1`
palStkAAVE Token : `0x5926145b65951600C8C7A62246d32E37EDfa578f`
palStkAAVE Pool : `0x90118BeAB64a73283671e64753FF0E17fE0571AD`
## Final Tweaks
- [x] Tweak mobile styles
- [x] Add snackbar for transaction link and status
- [x] Add utility tests
- [x] Refactor code
- [x] Add documentation to README