Skip to content

Commit d039b11

Browse files
committed
Add stablecoin pool
1 parent 9c61b88 commit d039b11

File tree

2 files changed

+1041
-0
lines changed

2 files changed

+1041
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// SPDX-License-Identifier: LGPL-3.0-only
2+
pragma solidity 0.8.28;
3+
4+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
7+
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
8+
import {LiquidityPool} from "./LiquidityPool.sol";
9+
10+
/// @title A version of the liquidity pool contract that supports multiple assets for borrowing.
11+
/// It's possible to borrow any tokens that are present in the pool.
12+
/// @author Tanya Bushenyova <[email protected]>
13+
contract LiquidityPoolStablecoin is LiquidityPool {
14+
using SafeERC20 for IERC20;
15+
16+
error WithdrawProfitDenied();
17+
18+
constructor(
19+
address liquidityToken,
20+
address admin,
21+
address mpcAddress_
22+
) LiquidityPool(liquidityToken, admin, mpcAddress_) {
23+
return;
24+
}
25+
26+
function _borrowLogic(address /*borrowToken*/, uint256 /*amount*/, address /*target*/) internal override {
27+
return;
28+
}
29+
30+
function _withdrawProfitLogic(IERC20 token) internal override returns (uint256) {
31+
uint256 assetBalance = ASSETS.balanceOf(address(this));
32+
uint256 deposited = totalDeposited;
33+
require(assetBalance >= deposited, WithdrawProfitDenied());
34+
if (token == ASSETS) return assetBalance - deposited;
35+
return token.balanceOf(address(this));
36+
}
37+
}

0 commit comments

Comments
 (0)