Keydonix / liquid-long

The Unlicense
8 stars 1 forks source link

Upgrades typsecript generator and breaks apart contract methods. #107

Closed MicahZoltu closed 5 years ago

MicahZoltu commented 5 years ago

The most meaningful change here is the breaking apart of the too-large Solidity getCdpsByAddresses method. Along with breaking it apart, I also reduced the the data structure that is returned to only return the base values, the UI can fetch additional data if it needs to or calculate conversions itself.

ALong with breaking apart the function, I also switch a number of different types from uint256 to uint32. The generated typescript will let you use a number instead of a BigNumber if the underlying type is uint32, which notably simplifies working with the contracts so is preferable if we don't actually need a big number (such as for CDP array iterator).

The other big change (touches a lot of files) is upgrading to solidity-typescript-generator v2.0.1 (major version bump). This includes updating maker-contract-interfaces to v3.0.1 to match. This allows us to simplify some of our code by combining the dependencies for both LiquidLong and Maker contracts, since they are generated using the same version of the library. We could, if we wanted, switch over to using fetch instead of ethers at this point, and that is something worth considering in the future. We don't gain much from ethers at this point and we are somewhat constrained by its opinions on things. One thing ethers does do for us is polling for transaction receipts and mining, which we would have to build-out if we wanted to switch to fetch.

Added a function to the client library for estimating closure costs. This is one of the things I removed from the getCdps solidity return value. This lets us (in theory, we don't currently) poll for updates to this rather than receiving it once when we get the CDPs, and then hoping that nothing changes by the time the user clicks close.