Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/strategies/base/BaseRepayStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ abstract contract BaseRepayStrategy is BaseRebalanceStrategy {
uint256 lpInvariant = convertLPToInvariant(newLPBalance, lastCFMMInvariant, lastCFMMTotalSupply);
s.LP_INVARIANT = uint128(lpInvariant);

unchecked {
// _lpTokenPaid is derived from lpTokenBorrowedPlusInterest
s.LP_TOKEN_BORROWED_PLUS_INTEREST = lpTokenBorrowedPlusInterest - GSMath.min(lpTokenBorrowedPlusInterest, _lpTokenPaid);
// _lpTokenPaid is derived from lpTokenBorrowedPlusInterest
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLPRoundUp(borrowedInvariant, lastCFMMTotalSupply, lastCFMMInvariant);

unchecked {
// LP_TOKEN_BORROWED = sum(lpTokenPrincipal of all loans)
lpTokenBorrowed = lpTokenBorrowed - GSMath.min(lpTokenBorrowed, lpTokenPrincipal);
}
Expand Down Expand Up @@ -169,7 +169,7 @@ abstract contract BaseRepayStrategy is BaseRebalanceStrategy {
borrowedInvariant = borrowedInvariant - GSMath.min(borrowedInvariant, writeDownAmt);
}

s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLP(borrowedInvariant, s.lastCFMMTotalSupply, s.lastCFMMInvariant);
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLPRoundUp(borrowedInvariant, s.lastCFMMTotalSupply, s.lastCFMMInvariant);
s.BORROWED_INVARIANT = uint128(borrowedInvariant);

// Loan's liquidity debt is written down to its available collateral liquidity debt
Expand Down
2 changes: 1 addition & 1 deletion contracts/strategies/base/BaseStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ abstract contract BaseStrategy is AppStorage, AbstractRateModel {
s.lastCFMMFeeIndex = uint64(calcIntraBlockCFMMFeeIndex(s.lastCFMMFeeIndex, lastCFMMFeeIndex));
lastFeeIndex = 1e18;
accFeeIndex = s.accFeeIndex;
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLP(borrowedInvariant, lastCFMMTotalSupply, lastCFMMInvariant);
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLPRoundUp(borrowedInvariant, lastCFMMTotalSupply, lastCFMMInvariant);
s.LP_INVARIANT = uint128(convertLPToInvariant(s.LP_TOKEN_BALANCE, lastCFMMInvariant, lastCFMMTotalSupply));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract contract ExternalLiquidationStrategy is IExternalLiquidationStrategy, B
if(liquiditySwapped > loanLiquidity) {
uint256 swapFee = calcExternalSwapFee(liquiditySwapped, loanLiquidity) / 2;
uint256 borrowedInvariant = s.BORROWED_INVARIANT + swapFee;
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLP(borrowedInvariant, s.lastCFMMTotalSupply, s.lastCFMMInvariant);
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLPRoundUp(borrowedInvariant, s.lastCFMMTotalSupply, s.lastCFMMInvariant);
s.BORROWED_INVARIANT = uint128(borrowedInvariant);
loanLiquidity += swapFee;
_loan.liquidity = uint128(loanLiquidity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract contract ExternalRebalanceStrategy is IExternalRebalanceStrategy, BaseE
if(liquiditySwapped > loanLiquidity) {
uint256 fee = calcExternalSwapFee(liquiditySwapped, loanLiquidity);
uint256 borrowedInvariant = s.BORROWED_INVARIANT + fee;
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLP(borrowedInvariant, s.lastCFMMTotalSupply, s.lastCFMMInvariant);
s.LP_TOKEN_BORROWED_PLUS_INTEREST = convertInvariantToLPRoundUp(borrowedInvariant, s.lastCFMMTotalSupply, s.lastCFMMInvariant);
s.BORROWED_INVARIANT = uint128(borrowedInvariant);
loanLiquidity = loanLiquidity + fee;
_loan.liquidity = uint128(loanLiquidity);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gammaswap/v1-core",
"version": "1.2.14",
"version": "1.2.15",
"description": "Core smart contracts for the GammaSwap V1 protocol",
"homepage": "https://gammaswap.com",
"scripts": {
Expand Down
Loading