diff --git a/contracts/interfaces/cpmm/ICPMMGammaPool.sol b/contracts/interfaces/cpmm/ICPMMGammaPool.sol index 3672e33..e45be55 100644 --- a/contracts/interfaces/cpmm/ICPMMGammaPool.sol +++ b/contracts/interfaces/cpmm/ICPMMGammaPool.sol @@ -28,4 +28,8 @@ interface ICPMMGammaPool { /// @dev set maximum total APY charged by GammaPool to borrowers /// @param _maxTotalAPY - new maximum total APY charged to GammaPool borrowers function setMaxTotalAPY(uint256 _maxTotalAPY) external; + + /// @dev get maximum total APY charged by GammaPool to borrowers + /// @return _maxTotalAPY - maximum total APY charged to GammaPool borrowers + function getMaxTotalAPY() external view returns(uint256); } diff --git a/contracts/pools/CPMMGammaPool.sol b/contracts/pools/CPMMGammaPool.sol index bad9ad1..16a7162 100644 --- a/contracts/pools/CPMMGammaPool.sol +++ b/contracts/pools/CPMMGammaPool.sol @@ -78,9 +78,8 @@ contract CPMMGammaPool is GammaPool, GammaPoolExternal, ICPMMGammaPool { abi.decode(callStrategy(rebalanceStrategy, abi.encodeCall(ICPMMRebalanceStrategy._setMaxTotalAPY, _maxTotalAPY)), ()); } - /// @dev See {IGammaPoolExternal-liquidateExternally} - function liquidateExternally(uint256 tokenId, uint128[] calldata amounts, uint256 lpTokens, address to, bytes calldata data) - external override virtual returns(uint256 loanLiquidity, uint256[] memory refund) { - return (0, new uint256[](0)); + /// @dev See {ICPMMGammaPool-getMaxTotalAPY} + function getMaxTotalAPY() external virtual override view returns(uint256) { + return s.getUint256(uint256(keccak256("MAX_TOTAL_APY"))); } } diff --git a/contracts/pools/VaultGammaPool.sol b/contracts/pools/VaultGammaPool.sol index 63f278b..a41f3b4 100644 --- a/contracts/pools/VaultGammaPool.sol +++ b/contracts/pools/VaultGammaPool.sol @@ -24,13 +24,14 @@ contract VaultGammaPool is CPMMGammaPool, IVaultGammaPool { } /// @dev See {IVaultGammaPool-getReservedBalances} - function getReservedBalances() external virtual override view returns(uint256 reservedBorrowedInvariant, uint256 reservedLPTokens) { - reservedBorrowedInvariant = s.getUint256(uint256(IVaultGammaPool.StorageIndexes.RESERVED_BORROWED_INVARIANT)); - reservedLPTokens = s.getUint256(uint256(IVaultGammaPool.StorageIndexes.RESERVED_LP_TOKENS)); + function getReservedBalances() external virtual override view returns(uint256, uint256) { + return(s.getUint256(uint256(IVaultGammaPool.StorageIndexes.RESERVED_BORROWED_INVARIANT)), + s.getUint256(uint256(IVaultGammaPool.StorageIndexes.RESERVED_LP_TOKENS))); } - /// @dev See {IGammaPool-liquidateWithLP} - function liquidateWithLP(uint256 tokenId) external virtual override returns(uint256 loanLiquidity, uint256[] memory refund) { + /// @dev See {IGammaPoolExternal-liquidateExternally} + function liquidateExternally(uint256 tokenId, uint128[] calldata amounts, uint256 lpTokens, address to, bytes calldata data) + external override virtual returns(uint256 loanLiquidity, uint256[] memory refund) { return (0, new uint256[](0)); } @@ -41,9 +42,8 @@ contract VaultGammaPool is CPMMGammaPool, IVaultGammaPool { /// @dev See {GammaPoolERC4626-maxAssets} function maxAssets(uint256 assets) internal view virtual override returns(uint256) { - uint256 reservedLpTokenBalance = s.getUint256(uint256(IVaultGammaPool.StorageIndexes.RESERVED_LP_TOKENS)); uint256 lpTokenBalance = s.LP_TOKEN_BALANCE; // CFMM LP tokens in GammaPool that have not been borrowed - lpTokenBalance = lpTokenBalance - GSMath.min(reservedLpTokenBalance, lpTokenBalance); + lpTokenBalance = lpTokenBalance - GSMath.min(s.getUint256(uint256(IVaultGammaPool.StorageIndexes.RESERVED_LP_TOKENS)), lpTokenBalance); if(assets < lpTokenBalance){ // limit assets available to withdraw to what has not been borrowed return assets; } diff --git a/package.json b/package.json index 3bb1b15..8a9ff61 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gammaswap/v1-implementations", - "version": "1.2.12", + "version": "1.2.13", "description": "Pool and strategies implementation contracts for GammaSwap V1 protocol", "homepage": "https://gammaswap.com", "scripts": { @@ -71,7 +71,7 @@ "typescript": "^4.7.4" }, "dependencies": { - "@gammaswap/v1-core": "^1.2.12", + "@gammaswap/v1-core": "^1.2.13", "@openzeppelin/contracts": "^4.7.0" } } diff --git a/yarn.lock b/yarn.lock index d35b37c..b14f881 100644 --- a/yarn.lock +++ b/yarn.lock @@ -449,10 +449,10 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" -"@gammaswap/v1-core@^1.2.12": - version "1.2.12" - resolved "https://npm.pkg.github.com/download/@gammaswap/v1-core/1.2.12/414f66123c7bc2f1b231c06e559f5d509d8abf49#414f66123c7bc2f1b231c06e559f5d509d8abf49" - integrity sha512-ti59W/jM5/VxLcEj9IP3Qhz6NirNMEqt7HIJNme1QAfD2SThPE+KF1pzfLwNlRYJnyZ2iP3Ye0cItwS2bYEsgQ== +"@gammaswap/v1-core@^1.2.13": + version "1.2.13" + resolved "https://npm.pkg.github.com/download/@gammaswap/v1-core/1.2.13/26f6719af9d6665640ade967b896fc2e3c0ec232#26f6719af9d6665640ade967b896fc2e3c0ec232" + integrity sha512-MqbWW584MMVmm6+iMToyxn7wp5F1dpwFohMp531qokrRHJ8qyC0Kj6l2v2klxsWvFHVe9qi9Vm3HeUFg7YuwoA== dependencies: "@openzeppelin/contracts" "^4.7.0"