Coder Social home page Coder Social logo

compoundloop's People

Contributors

danielzlotin avatar gadcl avatar ordd avatar talkol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

aleanos casuwu

compoundloop's Issues

test - low liquidity exit situation

enter with $5M, check liquidity
low liquidity = 10% of start liquidity
loop jump 1 month forward until < low liquidity
exit
verify state, iterations, gas

TK code review

getAccountLiquidity()

  1. Run require(accrueInterest() == 0, "accrue interest failed") before getAccountLiquidity and remove the view from the function. We can call it with call static. I didn't find an easier way to get the most recent liquidity with latest interest inside.

  2. Recommend to return the first arg as well (uint error) to know that getAccountLiquidity didn't fail.

repayBorrow()

  1. why not do a simple wrapper that receives arg repayAmount and just passes it onwards? these are emergency functions, ideally they shouldn't hold any logic.

  2. Assuming according to (1) we remove the logic, the code will once again compile (right now it doesn't compile due to the last emit using an undeclared variable).

enterPosition()

  1. The argument amountIn is strange.. let's say the account holds $1M USDC and we choose amountIn = $100K USDC.. in the loop we're going to set amountInCurr to the full balance anyways and mint the entire amount. I recommend to remove this argument and always enter all USDC to the position.

  2. When calling getAccountLiquidity, it will be nicer to examine the error and the shortfall as well and require that they make sense (both are zero).

exitPosition()

  1. When calling getAccountLiquidity, it will be nicer to examine the error and the shortfall as well and require that they make sense (both are zero).

  2. I'm not 100% certain that in all edge conditions, accountLiquidity/collateralFactor is exactly enough for redeemUnderlying (it is checked in comptroller.redeemAllowed and I didn't go through all the code). What if we introduce a fraction similar to enterPositions' uint amountToBorrowNum_ / uint amountToBorrowDenom_ that instead of redeeming 100% of the available liquidity, will redeem some percentage of the available liquidity. We will usually run it on 100%, but if we get strange errors we can reduce the percentage to 90%.

Write 3 e2e tests with fork on ganache

  1. Full flow sanity:
    1.a. enterPosition with $1M USDC (min $10K)
    1.b. exitPosition
    1.c. transfer the $1M USDC out to the owner
    1.d. claim COMP and transfer COMP out to the owner

  2. Multiple enters:
    2.a. enterPosition with $1M USDC (min $10K)
    2.b. Transfer new $20K USDC to the contract (to simulate COMP that was sold)
    2.c. enterPosition again with the $20K USDC
    2.d. exitPosition
    2.e. transfer the $1M+$20K out to the owner

  3. Manual exit (simulate recovery in case exitPosition fails for some unknown reason):
    3.a. enterPosition with $1M USDC (min $10K)
    3.b. Manual loop calling repayBorrow and friend functions to fully exit without calling exitPosition
    3.c. transfer the $1M USDC out to the owner

I have some example similar forked tests I wrote for ycrv strategy example that might be useful - https://github.com/defi-org-code/ycrv-strategy-test/blob/master/test/index.test.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.