Conversation
There was a problem hiding this comment.
Mostly small changes. I am going to also just do a run through of all the write commands myself tomorrow just to do a quick double check on them working.
There is one thing we should add now:
- i think we would do well to create an example README in the CLI or at the root of the project with an example CLI command for each CLI command created. this is easier for anyone to review, and recreate these contracts, rather than reading the code and piecing together over a few minutes how to write teh command. can you add this?
And one thing for the future
- i dont think we need to do cast calls on everything. we should use typescript to its advantage. maybe create a typescript type for in
types.tswhich isexport interface Modules. and then we can pass that intoPhotonContractsinterface, which then will exist in `CLIEnvironment. we don’t have to update it now, we can merge this since it works. but i think this is a good future enhancement. it involves a lot less string manipulation.
|
|
||
| export const mineCommand = { | ||
| command: 'mine', | ||
| describe: 'deploy contracts from deployParams.json', |
There was a problem hiding this comment.
describe should be updated. looks like a copy paste error
|
|
||
| export const cdpCommand = { | ||
| command: 'cdp', | ||
| describe: 'Photon protocol modules', |
There was a problem hiding this comment.
this describe message needs to be updated
| startTime.toString().concat(` (${new Date(Number(startTime) * 1000).toLocaleDateString()})`) | ||
| ]) | ||
| table.push(['status', status.toString()]) | ||
| table.push(['Total Collateral', toReadablePrice(totalCollateral)]) |
There was a problem hiding this comment.
it would be helpful to include Total Collateral in ${cliArgs.tokenType} or something like that, just as an indicator what the collateral is. for me it just says 27.228
| table.push(['Total Collateral', toReadablePrice(totalCollateral)]) | ||
| table.push(['Total Debt', toReadablePrice(totalDebt)]) | ||
| table.push(['Collateral Ratio', collRatio.slice(0, -3).concat('%')]) | ||
| table.push(['feesCollected', toReadablePrice(feesCollected)]) |
| 'startTime', | ||
| startTime.toString().concat(` (${new Date(Number(startTime) * 1000).toLocaleDateString()})`) | ||
| ]) | ||
| table.push(['status', status.toString()]) |
There was a problem hiding this comment.
right now I just see status: 1. i think cuz this is a table for displaying reading, we should just replace all the numbers like 1 to their actual status ACTIVE, which an enum
|
|
||
| table.push(['CDP Owner', cdpOwner]) | ||
| table.push(['Debt', toReadablePrice(debt)]) | ||
| table.push(['Collateral', toReadablePrice(collateral)]) |
There was a problem hiding this comment.
as suggested above, this makes it easier to read:
table.push([`Collateral in ${cliArgs.tokenType}`, toReadablePrice(collateral)])
Add CLI Commands to interact with CDP Pool.
Currently only written for
wstETHCDP pool.A generic CDP Pool interaction with different token is coming up.
commands:
basic command
npx ts-node cli/cli -c <networkId> -m <mnemonic> -n <accountNumber>Dictionary:
depositToken = [ steth | weth | eth ]amounts = without decimals. e.g. for 2 ETH = 2, for 1200 PHO = 1200Write commands:
<baseCommand> modules cdp open wsteth <depositToken> <collateralAmount> <debtAmount><baseCommand> modules cdp add-collateral wsteth <depositToken> <collateralAmount><baseCommand> modules cdp remove-collateral wsteth <collateralAmount><baseCommand> modules cdp add-debt wsteth <debtAmount><baseCommand> modules cdp remove-debt wsteth <debtAmount><baseCommand> modules cdp close wsteth<baseCommand> modules cdp liquidate wsteth <cdpOwner>* To be called by liquidator *Read command:
<baseCommand> modules cdp overview wsteth<baseCommand> modules cdp position wsteth <cdpOwner>General notes:
The caller will have to manually get the deposit token, meaning converting ETH to WSTETH/STETH/WETH. If the caller is calling to the mainet fork, the approval to use these token by the wrapper contract will be done automatically, otherwise the caller will have to manually approve the wrapper contract to
transferFrom.The CLI was tested with deposit token as
stETHonly for now. I will further test with other tokens.