Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add scLUSD strategy #77

Merged
merged 12 commits into from
Jun 6, 2023
Merged

add scLUSD strategy #77

merged 12 commits into from
Jun 6, 2023

Conversation

coolhill
Copy link
Contributor

@coolhill coolhill commented May 17, 2023

scLUSD: Deposit LUSD which will be deposited into the Liquity Stability Pool. Recieve scLUSD shares which appreciate over time and can be redeemed for LUSD. A keeper bot regularly reinvests profits which consists of discounted ETH on liquidations and Liquity community issuance ($LQTY). Strategy has exposure to Liquity, 0x exchange routing protocol and a combination oracle consiting of Chainlink ETH/USD and the Chainlink LUSD/USD price feeds.

  • deploy scripts

src/liquity/scLiquity.sol Fixed Show fixed Hide fixed
src/liquity/scLiquity.sol Fixed Show fixed Hide fixed
src/liquity/scLiquity.sol Fixed Show fixed Hide fixed
src/liquity/scLiquity.sol Fixed Show fixed Hide fixed
src/liquity/scLiquity.sol Fixed Show fixed Hide fixed
src/liquity/scLiquity.sol Fixed Show fixed Hide fixed
src/liquity/scLiquity.sol Fixed Show fixed Hide fixed
@coolhill coolhill requested review from fyang1024, dxganta and brkomir May 22, 2023 14:14
README.md Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
@fyang1024 fyang1024 self-requested a review May 24, 2023 01:46
Copy link
Contributor

@fyang1024 fyang1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggested a couple of changes

Copy link
Contributor

@brkomir brkomir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few improvement suggestions. Also, we are doing only unit tests for this strategy, adding a few simple (happy path) fork tests would be nice.

src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
stabilityPool.provideToSP(depositAmount, address(0));
}

function harvest(uint256 _lqtyAmount, bytes calldata _lqtySwapData, uint256 _ethAmount, bytes calldata _ethSwapData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no slippage control for the two potential swaps this function performs, consider adding "_amountOutMin" parameter and revert execution if the amount received is below min

src/liquity/scLiquity.sol Show resolved Hide resolved
// float is not allowed to be greater than 25% of the total
// invested since liquidation rewards can be dilluted by savy
// just-in-time depositors
uint256 float = asset.balanceOf(address(this));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asset.balanceOf(address(this)) is repeated multiple times in the contract, consider refactoring this as an internal function

Comment on lines +77 to +81
function depositIntoStrategy() external {
_depositIntoStrategy();
}

function _depositIntoStrategy() internal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having an external function to expose internal functionality without any added functionality seems unnecessary, consider changing the internal _depositIntoStrategy to public

Co-authored-by: Fei Yang <fyang1024@gmail.com>
Co-authored-by: brkomir <91959886+brkomir@users.noreply.github.com>
src/liquity/scLiquity.sol Outdated Show resolved Hide resolved
Comment on lines +84 to +98
function _depositIntoStrategy() internal {
uint256 float = asset.balanceOf(address(this));
uint256 targetFloat = totalAssets().mulWadDown(floatPercentage);

if (float <= targetFloat) return; // nothing to invest

uint256 depositAmount = float - targetFloat;

// needed otherwise counted as profit during harvest
totalInvested += depositAmount;

stabilityPool.provideToSP(depositAmount, address(0));

emit DepositedIntoStrategy(depositAmount);
}

Check notice

Code scanning / Slither

Reentrancy vulnerabilities

Reentrancy in scLiquity._depositIntoStrategy() (src/liquity/scLiquity.sol#84-98): External calls: - stabilityPool.provideToSP(depositAmount,address(0)) (src/liquity/scLiquity.sol#95) Event emitted after the call(s): - DepositedIntoStrategy(depositAmount) (src/liquity/scLiquity.sol#97)
@coolhill coolhill merged commit 8030661 into main Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants