Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: version 3.1 #40

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
46fb82d
feat: pyth oracle
Van0k May 7, 2024
af56d74
feat: pyth unit tests
Van0k May 10, 2024
d4caf28
fix: remove package-lock
Van0k May 10, 2024
9a316de
fix: next-related fixes
Van0k May 12, 2024
c86f14d
build: create release channel "next"
lekhovitsky May 12, 2024
d83622d
Merge branch 'next' into pyth-oracle
lekhovitsky May 12, 2024
b452e7d
Merge pull request #37 from Gearbox-protocol/pyth-oracle
0xmikko May 12, 2024
87d69bc
fix: streamlined decimals adjustment
Van0k May 13, 2024
01c5059
Merge branch 'pyth-oracle' of https://github.com/Gearbox-protocol/ora…
Van0k May 13, 2024
d62b0e5
fix: add pyth decimals sanity check
Van0k May 13, 2024
a8e18b8
fix: explicit casting in decimals computation
Van0k May 13, 2024
23e042f
fix: change core-v2 import to core-v3
Van0k May 13, 2024
6a46f9f
Merge pull request #39 from Gearbox-protocol/pyth-oracle
0xmikko May 13, 2024
8f8b710
fix: remove core-v2 dependency
lekhovitsky May 27, 2024
0db0d10
fix: add future price check in pyth price feed `latestRoundData`
Van0k Jun 25, 2024
dbf6701
fix: more pyth price feed validation in `latestRoundData`
Van0k Jun 25, 2024
f8cf181
fix: remove redundant decimals checks from pyth price feed
Van0k Jun 25, 2024
5c01b1f
feat: check price conf width against price in PythPriceFeed
Van0k Jun 28, 2024
5edfa66
revert: remporarily undo latest changes to simplify merge
lekhovitsky Jul 9, 2024
99b87c9
feat: small repo upgrade (#44)
lekhovitsky Jul 9, 2024
5958de9
feat: fixes after Spearbit review (#45)
lekhovitsky Jul 9, 2024
db69cbd
feat: mellow price feed (#42)
Van0k Jul 10, 2024
66ba1f5
feat: remove permissionless bounds updates
lekhovitsky Jul 10, 2024
69f53b8
feat: minor contracts cleanup (#47)
lekhovitsky Jul 10, 2024
eba6518
feat: add serialization
lekhovitsky Jul 10, 2024
8dee3b7
chore: fix deps (#48)
lekhovitsky Jul 16, 2024
d870794
fix: update core-v3 dep, silence warnings
lekhovitsky Jul 17, 2024
c30b421
feat: minor fixes (#49)
lekhovitsky Jul 24, 2024
327e6fe
Merge remote-tracking branch 'origin/main' into next
lekhovitsky Aug 6, 2024
b487bf8
chore: fix merge artifact in `yarn.lock`
lekhovitsky Aug 6, 2024
3a668ba
fix: `PythPriceFeed` microfixes (#52)
lekhovitsky Sep 2, 2024
a2c6323
feat: pendle pt price feed for v3.1
Van0k Sep 2, 2024
7c014fe
chore: licensing + cosmetic changes
Van0k Sep 2, 2024
62d03a9
fix: fix the_same_as price feeds test deployment
Van0k Sep 11, 2024
a14363c
fix: add missing pendle price feed test deployment
Van0k Sep 11, 2024
c177627
chore: reuse dependencies from upstream repos
lekhovitsky Oct 15, 2024
38b3a34
chore: update core dependency
lekhovitsky Oct 15, 2024
593aba9
fix: add syIndex / pyIndex into price computation
Van0k Oct 25, 2024
481c388
Merge pull request #53 from Gearbox-protocol/pendle-pt-pf-3_1
Van0k Nov 19, 2024
67665e2
fix: replace Tokens enum with uint256
Van0k Nov 27, 2024
a953900
feat: add pricing to SY to pendle twap feed
Van0k Nov 27, 2024
e788175
chore: bump sdk-gov
Van0k Nov 27, 2024
370777f
feat: add `serialize` to Pendle price feed
Van0k Dec 3, 2024
9ddf8bf
Merge pull request #56 from Gearbox-protocol/pendle-serialize
Van0k Dec 5, 2024
ecd56f6
Merge pull request #58 from Gearbox-protocol/pendle-price-to-sy-3.1
Van0k Dec 5, 2024
1145591
feat: remove `controller` role
lekhovitsky Dec 23, 2024
951b716
feat: replace `ACLTrait` with `Ownable` in `LPPriceFeed` and update c…
lekhovitsky Jan 8, 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: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Release

on:
push:
branches:
- "main"
branches: ["main", "next"]

env:
HUSKY: 0
Expand Down
23 changes: 19 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
/node_modules
/forge-out
.DS_Store
cache
# Dependencies
node_modules/

# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env

# Logs
*.log
13 changes: 10 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/@gearbox-protocol/core-v3"]
path = lib/@gearbox-protocol/core-v3
url = https://github.com/Gearbox-protocol/core-v3
branch = next
[submodule "lib/@gearbox-protocol/sdk-gov"]
path = lib/@gearbox-protocol/sdk-gov
url = https://github.com/Gearbox-protocol/sdk-gov
[submodule "lib/@solady"]
path = lib/@solady
url = https://github.com/Vectorized/solady
4 changes: 1 addition & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
node_modules
artifacts
cache
types
forge-out
out
5 changes: 5 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"branches": [
{
"name": "main"
},
{
"name": "next",
"channel": "next",
"prerelease": "next"
}
],
"plugins": [
Expand Down
6 changes: 2 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 4,
"eslint.validate": ["javascript", "typescript"],
"files.eol": "\n",
"solidity.formatter": "forge",
"solidity.packageDefaultDependenciesContractsDirectory": "contracts",
"solidity.packageDefaultDependenciesDirectory": "node_modules",
"solidity.compileUsingRemoteVersion": "v0.8.17"
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.23"
}
41 changes: 15 additions & 26 deletions contracts/interfaces/ILPPriceFeed.sol
Original file line number Diff line number Diff line change
@@ -1,47 +1,39 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

import {IPriceFeed} from "@gearbox-protocol/core-v2/contracts/interfaces/IPriceFeed.sol";
import {IPriceFeed} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IPriceFeed.sol";

/// @title LP price feed interface
interface ILPPriceFeed is IPriceFeed {
// ------ //
// EVENTS //
// ------ //

interface ILPPriceFeedEvents {
/// @notice Emitted when new LP token exchange rate bounds are set
event SetBounds(uint256 lowerBound, uint256 upperBound);

/// @notice Emitted when permissionless bounds update is allowed or forbidden
event SetUpdateBoundsAllowed(bool allowed);
}
// ------ //
// ERRORS //
// ------ //

interface ILPPriceFeedExceptions {
/// @notice Thrown when trying to set exchange rate lower bound to zero
error LowerBoundCantBeZeroException();

/// @notice Thrown when exchange rate falls below lower bound during price calculation
/// or new boudns don't contain exchange rate during bounds update
error ExchangeRateOutOfBoundsException();

/// @notice Thrown when trying to call `updateBounds` while it's not allowed
error UpdateBoundsNotAllowedException();

/// @notice Thrown when trying to call `updateBounds` before cooldown since the last update has passed
error UpdateBoundsBeforeCooldownException();

/// @notice Thrown when price oracle's reserve price feed is the LP price feed itself
error ReserveFeedMustNotBeSelfException();
}

/// @title LP price feed interface
interface ILPPriceFeed is IPriceFeed, ILPPriceFeedEvents, ILPPriceFeedExceptions {
function priceOracle() external view returns (address);
// ------- //
// GETTERS //
// ------- //

function lpToken() external view returns (address);
function lpContract() external view returns (address);

function lowerBound() external view returns (uint256);
function upperBound() external view returns (uint256);
function updateBoundsAllowed() external view returns (bool);
function lastBoundsUpdate() external view returns (uint40);

function getAggregatePrice() external view returns (int256 answer);
function getLPExchangeRate() external view returns (uint256 exchangeRate);
Expand All @@ -51,8 +43,5 @@ interface ILPPriceFeed is IPriceFeed, ILPPriceFeedEvents, ILPPriceFeedExceptions
// CONFIGURATION //
// ------------- //

function allowBoundsUpdate() external;
function forbidBoundsUpdate() external;
function setLimiter(uint256 newLowerBound) external;
function updateBounds(bytes calldata updateData) external;
}
2 changes: 1 addition & 1 deletion contracts/interfaces/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(c) Gearbox Foundation, 2023.
(c) Gearbox Foundation, 2024.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
8 changes: 0 additions & 8 deletions contracts/interfaces/aave/IWAToken.sol

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/interfaces/balancer/IBalancerStablePool.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface IBalancerStablePool {
function getRate() external view returns (uint256);
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/balancer/IBalancerVault.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface IBalancerVault {
function getPoolTokens(bytes32 poolId)
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/balancer/IBalancerWeightedPool.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface IBalancerWeightedPool {
function getRate() external view returns (uint256);
Expand Down
8 changes: 0 additions & 8 deletions contracts/interfaces/compound/ICToken.sol

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/interfaces/curve/ICurvePool.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface ICurvePool {
function get_virtual_price() external view returns (uint256);
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/curve/IstETHPoolGateway.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface IstETHPoolGateway {
function pool() external view returns (address);
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/lido/IwstETH.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface IwstETH {
function stETH() external view returns (address);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/mellow/IMellowChainlinkOracle.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
pragma solidity ^0.8.23;

interface IMellowChainlinkOracle {
function baseTokens(address vault) external view returns (address);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/mellow/IMellowVault.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
pragma solidity ^0.8.23;

import {IMellowVaultConfigurator} from "./IMellowVaultConfigurator.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/mellow/IMellowVaultConfigurator.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
pragma solidity ^0.8.23;

import {IMellowChainlinkOracle} from "./IMellowChainlinkOracle.sol";

Expand Down
12 changes: 12 additions & 0 deletions contracts/interfaces/pendle/IPendleMarket.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface IPendleMarket {
function observe(uint32[] calldata secondsAgos) external view returns (uint216[] memory);

function expiry() external view returns (uint256);

function readTokens() external view returns (address, address, address);
}
14 changes: 14 additions & 0 deletions contracts/interfaces/pendle/IPendleTokens.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;

interface IPendleYT {
function doCacheIndexSameBlock() external view returns (bool);
function pyIndexLastUpdatedBlock() external view returns (uint256);
function pyIndexStored() external view returns (uint256);
}

interface IPendleSY {
function exchangeRate() external view returns (uint256);
}
13 changes: 13 additions & 0 deletions contracts/interfaces/pyth/IPyth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

import {PythStructs} from "./PythStructs.sol";

interface IPyth {
function updatePriceFeeds(bytes[] calldata updateData) external payable;
function getPriceUnsafe(bytes32 id) external view returns (PythStructs.Price memory price);
function latestPriceInfoPublishTime(bytes32 priceFeedId) external view returns (uint64);
function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount);
}
13 changes: 13 additions & 0 deletions contracts/interfaces/pyth/PythStructs.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

contract PythStructs {
struct Price {
int64 price;
uint64 conf;
int32 expo;
uint256 publishTime;
}
}
4 changes: 2 additions & 2 deletions contracts/interfaces/yearn/IYVault.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

interface IYVault {
function token() external view returns (address);
Expand Down
Loading
Loading