Skip to content

Commit 2229cd4

Browse files
committed
add Market and PT USDe Feed factories
1 parent fa667ca commit 2229cd4

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

src/factory/FeedSwitchFactory.sol

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import {FeedSwitch} from "src/util/FeedSwitch.sol";
5+
import {USDeNavBeforeMaturityFeed} from "src/feeds/USDeNavBeforeMaturityFeed.sol";
6+
import {NavBeforeMaturityFeed} from "src/feeds/NavBeforeMaturityFeed.sol";
7+
import {PendleNAVFeed} from "src/feeds/PendleNAVFeed.sol";
8+
9+
contract PTUSDeFeedSwitchFactory {
10+
address public constant USDeWrapperFeed = 0xB3C1D801A02d88adC96A294123c2Daa382345058;
11+
address public constant sUSDeWrapper = address(0xD723a0910e261de49A90779d38A94aFaAA028F15);
12+
address public constant sUSDe = address(0x9D39A5DE30e57443BfF2A8307A4256c8797A3497);
13+
uint256 public constant timelockPeriod = 64800;
14+
address public constant guardian = 0x4b6c63E6a94ef26E2dF60b89372db2d8e211F1B7;
15+
16+
mapping(address => bool) public isFromFactory;
17+
18+
event NewFeedSwitch(
19+
address pendlePT, address feedSwitch, address navFeed, address beforeMaturityFeed, address afterMaturityFeed
20+
);
21+
22+
function deployUSDeFeed(address pendlePT, uint256 baseDiscount) external returns (address feedSwitch) {
23+
PendleNAVFeed navFeed = new PendleNAVFeed(pendlePT, baseDiscount);
24+
25+
NavBeforeMaturityFeed beforeMaturityFeed = new NavBeforeMaturityFeed(USDeWrapperFeed, address(navFeed));
26+
27+
feedSwitch = address(
28+
new FeedSwitch(
29+
address(navFeed), address(beforeMaturityFeed), USDeWrapperFeed, timelockPeriod, pendlePT, guardian
30+
)
31+
);
32+
isFromFactory[feedSwitch] = true;
33+
34+
emit NewFeedSwitch(pendlePT, feedSwitch, address(navFeed), address(beforeMaturityFeed), USDeWrapperFeed);
35+
}
36+
37+
function deploySUSDeFeed(address pendlePT, uint256 baseDiscount) external returns (address feedSwitch) {
38+
PendleNAVFeed navFeed = new PendleNAVFeed(pendlePT, baseDiscount);
39+
40+
USDeNavBeforeMaturityFeed beforeMaturityFeed =
41+
new USDeNavBeforeMaturityFeed(sUSDeWrapper, sUSDe, address(navFeed)); // USDeBeforeMaturityFeed: USDe/USD Feed using sUSDe Chainlink feed and sUSDe/USDe rate and NAV
42+
43+
feedSwitch = address(
44+
new FeedSwitch(
45+
address(navFeed), address(beforeMaturityFeed), USDeWrapperFeed, timelockPeriod, pendlePT, guardian
46+
)
47+
);
48+
49+
isFromFactory[feedSwitch] = true;
50+
51+
emit NewFeedSwitch(pendlePT, feedSwitch, address(navFeed), address(beforeMaturityFeed), USDeWrapperFeed);
52+
}
53+
}

src/factory/MarketFactory.sol

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
import "src/Market.sol";
5+
6+
contract MarketFactory {
7+
IOracle public constant ORACLE = IOracle(0xaBe146CF570FD27ddD985895ce9B138a7110cce8);
8+
IDolaBorrowingRights public constant DBR = IDolaBorrowingRights(0xAD038Eb671c44b853887A7E32528FaB35dC5D710);
9+
address public constant GOV = address(0x926dF14a23BE491164dCF93f4c468A50ef659D5B);
10+
address public constant FED = address(0x2b34548b865ad66A2B046cb82e59eE43F75B90fd);
11+
address public constant PAUSE_GUARDIAN = address(0xE3eD95e130ad9E15643f5A5f232a3daE980784cd);
12+
uint256 public constant initialCollateralFactorBps = 5000;
13+
uint256 public constant initialReplenishmentIncentiveBps = 5000;
14+
uint256 public constant initialLiquidationIncentiveBps = 100;
15+
16+
mapping(address => bool) public isFromFactory;
17+
18+
event NewMarket(address collateral, address market);
19+
20+
function deployMarket(address collateral, address escrowImpl, bool callbackOnDeposit)
21+
external
22+
returns (address market)
23+
{
24+
market = address(
25+
new Market(
26+
GOV,
27+
FED,
28+
PAUSE_GUARDIAN,
29+
escrowImpl,
30+
DBR,
31+
IERC20(collateral),
32+
ORACLE,
33+
initialCollateralFactorBps,
34+
initialReplenishmentIncentiveBps,
35+
initialLiquidationIncentiveBps,
36+
callbackOnDeposit
37+
)
38+
);
39+
isFromFactory[market] = true;
40+
emit NewMarket(collateral, market);
41+
}
42+
}

0 commit comments

Comments
 (0)