Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
b8e6526
add CurveDolaLPHelperDynamic
0xtj24 Nov 22, 2024
4964e65
add DolasUSDe tests
0xtj24 Nov 22, 2024
93b65e5
simplify _addLiquidity for dynamic array
0xtj24 Nov 22, 2024
db08147
add DolasUSDs LP tests, add initial ALE test refactor
0xtj24 Nov 27, 2024
f5998d1
add DolascrvUSD LP tests
0xtj24 Nov 28, 2024
c218c88
update BorrowController test setup
0xtj24 Nov 28, 2024
07ad3f5
add sDOLA-scrvUSD markets tests
0xtj24 Dec 12, 2024
9c6ce4f
add ALE sDOLA LP helper
0xtj24 Dec 12, 2024
2f41fa5
add ALE tests for sDOLA-scrvUSD markets
0xtj24 Dec 12, 2024
ef665eb
update config file
0xtj24 Dec 12, 2024
abfaf46
use interface
0xtj24 Dec 12, 2024
16114e5
update natspec
0xtj24 Dec 12, 2024
cc2a55d
add YearnV2 deployed vault sDola-scrvUSD test, add fuzz tests
0xtj24 Dec 13, 2024
d671a3e
add initial PendlePTHelper and fork test
0xtj24 Dec 19, 2024
e6fed9d
Merge branch 'dev' into feat/pendle-pt-helper
0xtj24 Dec 19, 2024
4d6e58c
rm unused import
0xtj24 Dec 19, 2024
12c5327
update natspec
0xtj24 Dec 19, 2024
1646d74
update natspec
0xtj24 Dec 20, 2024
712fa6d
more natspec update
0xtj24 Dec 20, 2024
af6107c
fix typos
0xtj24 Dec 20, 2024
20e7b77
add safety check for stucked Pendle tokens
0xtj24 Dec 20, 2024
2cf4856
add Pendle PT helper fuzz tests
0xtj24 Dec 26, 2024
f646dce
rm unused import in test
0xtj24 Dec 26, 2024
419181f
add initial PendlePTHelper update, add ALEPendle, update tests
0xtj24 Jan 7, 2025
6a9df68
use selector check for PendlePTHelper, add tests
0xtj24 Jan 9, 2025
2f084d6
update natspec
0xtj24 Jan 9, 2025
f140324
store maturity for gas optimization
0xtj24 Jan 9, 2025
d1f67f9
add Events
0xtj24 Jan 10, 2025
b858075
update natspec
0xtj24 Jan 10, 2025
713b3e4
apply review feedback
0xtj24 Jan 15, 2025
e8611f5
add refundExcess internal function
0xtj24 Jan 15, 2025
1d87b03
add minOut check for buy and sell DBR
0xtj24 Jan 20, 2025
3cc6e03
revert if helper or buySellToken not set
0xtj24 Jan 20, 2025
b05b6f4
fix updateMarketHelper logic, add test
0xtj24 Jan 28, 2025
1c04da4
use BytesLib library in PendlePTHelper
0xtj24 Jan 30, 2025
fb836b0
add Dola-DeUSD market and ALE tests
0xtj24 Feb 13, 2025
ce13367
fix old test
0xtj24 Feb 13, 2025
7650d9f
add Feed and Escrow tests, update market test with CL feed
0xtj24 Feb 14, 2025
89bf3fb
fix typo
0xtj24 Feb 14, 2025
5dd5b66
rm spender from ALEPendle, update tests
0xtj24 Feb 28, 2025
3945ec0
introduce ALEV2, update ERC4626Helper and YVYCRVHelper, update tests
0xtj24 Mar 4, 2025
6c05ba2
update CurveDolaLPHelper and tests
0xtj24 Mar 6, 2025
5e7c94c
update CurveDolaLPHelperDynamic and tests
0xtj24 Mar 6, 2025
36180d4
Merge branch 'feat/sDOLA-scrvUSD' into feat/pendle-pt-helper
0xtj24 Mar 6, 2025
37268a7
update CurveSDolaLPHelperDynamic and tests
0xtj24 Mar 7, 2025
c085b9d
add USDe before maturity with NAV, add tests with NAV
0xtj24 Mar 12, 2025
d90491a
add maturity check and test
0xtj24 Mar 12, 2025
8c2c4ae
update natspec
0xtj24 Mar 12, 2025
49f8efb
add multiple proxy support for ALEV2, update tests
0xtj24 Mar 18, 2025
5625279
Merge branch 'dev' into feat/dola-deUsd
08xmt Mar 24, 2025
7a13fb8
Merge branch 'dev' into feat/pt-sude
08xmt Mar 24, 2025
aa97bd9
use PendleNAVFeed returning block.timestamp
0xtj24 Mar 27, 2025
8690cf0
Merge branch 'feat/pt-sude' of github.com-work_user2:InverseFinance/F…
0xtj24 Mar 27, 2025
c80d052
fix sdeUSD test
0xtj24 Mar 27, 2025
84c1f35
add test for staleness in Market tests
0xtj24 Mar 27, 2025
4640e8c
update staleness test for Markets
0xtj24 Mar 28, 2025
3c8163d
use deployed contracts for PendlePTsUSDe29May25
0xtj24 Mar 28, 2025
272e9c6
add initial ALEV2 and helpers addresses in tests
0xtj24 Apr 1, 2025
8a97b69
Merge branch 'feat/pt-sude' into feat/pendle-pt-helper
0xtj24 Apr 1, 2025
7ec0bcc
use latest block for SDola-scrvUSD tests, update ALEPendlePT tests
0xtj24 Apr 1, 2025
5c7d7ce
uncomment assertions
0xtj24 Apr 1, 2025
4110616
add ALE PT USDe 29May25 test
0xtj24 Apr 3, 2025
5455f32
Feat: Dola-USR markets (#112)
0xtj24 Apr 8, 2025
0e7c2d7
Merge branch 'feat/dola-deUsd' into feat/pendle-pt-helper
0xtj24 Apr 8, 2025
a18c1f6
update Dola-DeUSD and Dola-USR ALE tests
0xtj24 Apr 8, 2025
6b4f16c
update setMarket function
0xtj24 Apr 11, 2025
ebc76db
update tests with latest deployments
0xtj24 Apr 11, 2025
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate.git
[submodule "lib/bytes-utils"]
path = lib/bytes-utils
url = [email protected]:GNSPS/solidity-bytes-utils.git
1 change: 1 addition & 0 deletions lib/bytes-utils
Submodule bytes-utils added at c43328
45 changes: 45 additions & 0 deletions src/feeds/PendleNAVFeed.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

contract PendleNAVFeed {
uint256 private constant SECONDS_PER_YEAR = 365 days;
uint256 private constant ONE = 1e18;

address public immutable PT;
uint256 public immutable maturity;
uint256 public immutable baseDiscountPerYear; // 100% = 1e18

constructor(address _pt, uint256 _baseDiscountPerYear) {
require(_baseDiscountPerYear <= 1e18, "invalid discount");
require(_pt != address(0), "zero address");

PT = _pt;
maturity = PTExpiry(PT).expiry();
baseDiscountPerYear = _baseDiscountPerYear;
}

function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
{
uint256 timeLeft = (maturity > block.timestamp) ? maturity - block.timestamp : 0;
uint256 discount = getDiscount(timeLeft);

require(discount <= ONE, "discount overflow");

return (0, int256(ONE - discount), 0, block.timestamp, 0);
}

function decimals() external pure returns (uint8) {
return 18;
}

function getDiscount(uint256 timeLeft) public view returns (uint256) {
return (timeLeft * baseDiscountPerYear) / SECONDS_PER_YEAR;
}
}

interface PTExpiry {
function expiry() external view returns (uint256);
}
88 changes: 88 additions & 0 deletions src/feeds/USDeNavBeforeMaturityFeed.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import {IChainlinkBasePriceFeed} from "src/interfaces/IChainlinkFeed.sol";
import {IERC4626} from "lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol";

interface INavFeed {
function maturity() external view returns (uint256);
function decimals() external view returns (uint8);
function latestRoundData()
external
view
returns (uint80, int256, uint256, uint256, uint80);
}
/// @title USDeFeed Before Maturity using NAV
/// @notice A contract to get the USDe price using sUSDe Chainlink Wrapper feed and sUSDe/USDe rate and NAV
contract USDeNavBeforeMaturityFeed {
error DecimalsMismatch();
error MaturityPassed();

IChainlinkBasePriceFeed public immutable sUSDeFeed;
IERC4626 public immutable sUSDe;
INavFeed public immutable navFeed;

string public description;

constructor(address _sUSDeFeed, address _sUSDe, address _navFeed) {
sUSDeFeed = IChainlinkBasePriceFeed(_sUSDeFeed);
sUSDe = IERC4626(_sUSDe);
navFeed = INavFeed(_navFeed);
if (sUSDeFeed.decimals() != 18 || sUSDe.decimals() != 18 || navFeed.decimals() != 18)
revert DecimalsMismatch();
if(navFeed.maturity() <= block.timestamp) revert MaturityPassed();
description = string(
abi.encodePacked(
"USDe/USD Feed using sUSDe Chainlink feed and sUSDe/USDe rate with NAV"
)
);
}

/**
* @return roundId The round ID of sUSDe Chainlink price feed
* @return USDeUsdPrice The latest USDe price in USD using NAV
* @return startedAt The timestamp when the latest round of Chainlink price feed started
* @return updatedAt The timestamp when the latest round of Chainlink price feed was updated
* @return answeredInRound The round ID in which the answer was computed
*/
function latestRoundData()
public
view
returns (uint80, int256, uint256, uint256, uint80)
{
(
uint80 roundId,
int256 sUSDePrice,
uint startedAt,
uint updatedAt,
uint80 answeredInRound
) = sUSDeFeed.latestRoundData();

uint256 sUSDeToUSDeRate = sUSDe.convertToAssets(1e18);

// divide sUSDe/USD by sUSDe/USDe rate to get USDe/USD price
int256 USDeUsdPrice = (sUSDePrice * 1e18) / int256(sUSDeToUSDeRate);

(,int256 navDiscountedPrice,,,)= navFeed.latestRoundData();
int256 usdeDiscountPrice = (USDeUsdPrice * navDiscountedPrice) / 1e18;

return (roundId, usdeDiscountPrice, startedAt, updatedAt, answeredInRound);
}

/**
@notice Retrieves the latest USDe price
@return price The latest USDe price
*/
function latestAnswer() external view returns (int256) {
(, int256 price, , , ) = latestRoundData();
return price;
}

/**
* @notice Retrieves number of decimals for the price feed
* @return decimals The number of decimals for the price feed
*/
function decimals() public pure returns (uint8) {
return 18;
}
}
48 changes: 48 additions & 0 deletions src/interfaces/IMultiMarketConvertHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//SPDX-License-Identifier: None
pragma solidity ^0.8.0;

interface IMultiMarketConvertHelper {
struct Permit {
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}

function convertToCollateral(
address user,
uint256 amount,
bytes calldata data
) external returns (uint256 collateralAmount);

function convertToCollateral(
uint256 amount,
address recipient,
bytes calldata data
) external returns (uint256 collateralAmount);

function convertToCollateralAndDeposit(
uint256 amount,
address recipient,
bytes calldata data
) external returns (uint256 collateralAmount);

function convertFromCollateral(
address user,
uint256 amount,
bytes calldata data
) external returns (uint256);

function convertFromCollateral(
uint256 amount,
address recipient,
bytes calldata data
) external returns (uint256);

function withdrawAndConvertFromCollateral(
uint256 amount,
address recipient,
Permit calldata permit,
bytes calldata data
) external returns (uint256 underlyingAmount);
}
47 changes: 47 additions & 0 deletions src/interfaces/IPendleHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//SPDX-License-Identifier: None
pragma solidity ^0.8.0;

interface IPendleHelper {
struct Permit {
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}

function convertToCollateral(
address user,
uint256 amount,
bytes calldata data
) external returns (uint256 collateralAmount);

function convertToCollateral(
uint256 amount,
bytes calldata data
) external returns (uint256 collateralAmount);

function convertToCollateralAndDeposit(
uint256 amount,
address recipient,
bytes calldata data
) external returns (uint256 collateralAmount);

function convertFromCollateral(
address user,
uint256 amount,
bytes calldata data
) external returns (uint256);

function convertFromCollateral(
uint256 amount,
address recipient,
bytes calldata data
) external returns (uint256);

function withdrawAndConvertFromCollateral(
uint256 amount,
address recipient,
Permit calldata permit,
bytes calldata data
) external returns (uint256 underlyingAmount);
}
Loading