Skip to content

Commit

Permalink
Merge pull request #178 from gammaswap/upd-poolviewer-zeroliq2
Browse files Browse the repository at this point in the history
publish package
  • Loading branch information
0xDanr committed Jan 19, 2024
2 parents 2611b17 + e10f0bd commit 6ef9b13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions contracts/base/PoolViewer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ contract PoolViewer is IPoolViewer {
/// @inheritdoc IPoolViewer
function loan(address pool, uint256 tokenId) external virtual override view returns(IGammaPool.LoanData memory _loanData) {
_loanData = IGammaPool(pool).getLoanData(tokenId);
if(_loanData.id == 0) {
return _loanData;
}
_loanData.accFeeIndex = _getLoanLastFeeIndex(_loanData);
_loanData.liquidity = _updateLiquidity(_loanData.liquidity, _loanData.rateIndex, _loanData.accFeeIndex);
address refAddr = _loanData.refType == 3 ? _loanData.refAddr : address(0);
Expand Down Expand Up @@ -97,6 +100,9 @@ contract PoolViewer is IPoolViewer {
function _getLoanLastFeeIndex(IGammaPool.LoanData memory _loanData) internal virtual view returns(uint256 accFeeIndex) {
uint256 lastCFMMInvariant;
uint256 lastCFMMTotalSupply;
if(_loanData.poolId == address(0)) {
return 1e18;
}
(, lastCFMMInvariant, lastCFMMTotalSupply) = IGammaPool(_loanData.poolId).getLatestCFMMBalances();
if(lastCFMMTotalSupply == 0) {
return 1e18;
Expand Down Expand Up @@ -178,6 +184,8 @@ contract PoolViewer is IPoolViewer {
data.utilizationRate = _calcUtilizationRate(data.LP_INVARIANT, data.BORROWED_INVARIANT);
data.emaUtilRate = uint40(IShortStrategy(params.shortStrategy).calcUtilRateEma(data.utilizationRate, params.emaUtilRate,
GSMath.max(block.number - params.LAST_BLOCK_NUMBER, params.emaMultiplier)));
} else {
data.lastFeeIndex = 1e18;
}

data.origFee = params.origFee;
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.1.22",
"version": "1.1.23",
"description": "Core smart contracts for the GammaSwap V1 protocol",
"homepage": "https://gammaswap.com",
"scripts": {
Expand Down

0 comments on commit 6ef9b13

Please sign in to comment.