Skip to content

Commit e4884a0

Browse files
Perpetual tranche v1.1.0 updates (#126)
* Updated math lib in perp * comment updates * code cleanup, function always checks for deposit bond rather than one passed in the param * allowing address(0) to be keeper * rollover whitelist * tested perp upgrade on testnet * moved event to interface as it does not alter the storage layout * added helper method to perp to calculate value of tranches held in the system * unit test to ensure winddown * Apply suggestions from code review Co-authored-by: Brandon Iles <brandon@fragments.org> * deployed to goerli * bumped up solidity version * renamed roller vairable * moved only owner methods out of the interface definition * Added natspec comments to the interface * using math libraries inline * making authorizeRoller idempotent --------- Co-authored-by: Brandon Iles <brandon@fragments.org>
1 parent 73dc4ff commit e4884a0

27 files changed

+779
-119
lines changed

spot-contracts/.openzeppelin/goerli.json

Lines changed: 406 additions & 13 deletions
Large diffs are not rendered by default.

spot-contracts/.solhint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"func-visibility": ["warn", { "ignoreConstructors": true }],
66
"reason-string": ["warn", { "maxLength": 64 }],
77
"not-rely-on-time": "off",
8-
"max-states-count": ["warn", 16]
8+
"max-states-count": ["warn", 17]
99
}
1010
}

spot-contracts/contracts/BondIssuer.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.17;
2+
pragma solidity ^0.8.18;
33

44
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
55
import { EnumerableSetUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";

spot-contracts/contracts/PerpetualTranche.sol

Lines changed: 143 additions & 40 deletions
Large diffs are not rendered by default.

spot-contracts/contracts/RouterV1.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.17;
2+
pragma solidity ^0.8.18;
33

44
import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
55
import { SafeCastUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";

spot-contracts/contracts/_interfaces/IPerpetualTranche.sol

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,6 @@ interface IPerpetualTranche is IERC20Upgradeable {
1414
//--------------------------------------------------------------------------
1515
// Events
1616

17-
/// @notice Event emitted when the keeper is updated.
18-
/// @param prevKeeper The address of the previous keeper.
19-
/// @param newKeeper The address of the new keeper.
20-
event UpdatedKeeper(address prevKeeper, address newKeeper);
21-
22-
/// @notice Event emitted when the bond issuer is updated.
23-
/// @param issuer Address of the issuer contract.
24-
event UpdatedBondIssuer(IBondIssuer issuer);
25-
26-
/// @notice Event emitted when the fee strategy is updated.
27-
/// @param strategy Address of the strategy contract.
28-
event UpdatedFeeStrategy(IFeeStrategy strategy);
29-
30-
/// @notice Event emitted when the pricing strategy is updated.
31-
/// @param strategy Address of the strategy contract.
32-
event UpdatedPricingStrategy(IPricingStrategy strategy);
33-
34-
/// @notice Event emitted when the discount strategy is updated.
35-
/// @param strategy Address of the strategy contract.
36-
event UpdatedDiscountStrategy(IDiscountStrategy strategy);
37-
38-
/// @notice Event emitted when maturity tolerance parameters are updated.
39-
/// @param min The minimum maturity time.
40-
/// @param max The maximum maturity time.
41-
event UpdatedTolerableTrancheMaturity(uint256 min, uint256 max);
42-
43-
/// @notice Event emitted when the supply caps are updated.
44-
/// @param maxSupply The max total supply.
45-
/// @param maxMintAmtPerTranche The max mint amount per tranche.
46-
event UpdatedMintingLimits(uint256 maxSupply, uint256 maxMintAmtPerTranche);
47-
48-
/// @notice Event emitted when the mature value target percentage is updated.
49-
/// @param matureValueTargetPerc The new target percentage.
50-
event UpdatedMatureValueTargetPerc(uint256 matureValueTargetPerc);
51-
5217
/// @notice Event emitted when the applied discount for a given token is set.
5318
/// @param token The address of the token.
5419
/// @param discount The discount factor applied.
@@ -108,6 +73,7 @@ interface IPerpetualTranche is IERC20Upgradeable {
10873
/// @notice Checks if the given `trancheIn` can be rolled out for `tokenOut`.
10974
/// @param trancheIn The tranche token deposited.
11075
/// @param tokenOut The reserve token to be redeemed.
76+
/// @return If the given pair is a valid rollover.
11177
function isAcceptableRollover(ITranche trancheIn, IERC20Upgradeable tokenOut) external returns (bool);
11278

11379
/// @notice The strategy contract with the fee computation logic.
@@ -131,24 +97,35 @@ interface IPerpetualTranche is IERC20Upgradeable {
13197
function feeToken() external view returns (IERC20Upgradeable);
13298

13399
/// @notice Total count of tokens held in the reserve.
100+
/// @return The reserve token count.
134101
function getReserveCount() external returns (uint256);
135102

136103
/// @notice The token address from the reserve list by index.
137104
/// @param index The index of a token.
105+
/// @return The reserve token address.
138106
function getReserveAt(uint256 index) external returns (IERC20Upgradeable);
139107

140108
/// @notice Checks if the given token is part of the reserve.
141109
/// @param token The address of a token to check.
110+
/// @return If the token is part of the reserve.
142111
function inReserve(IERC20Upgradeable token) external returns (bool);
143112

144113
/// @notice Fetches the reserve's tranche token balance.
145114
/// @param tranche The address of the tranche token held by the reserve.
115+
/// @return The ERC-20 balance of the reserve tranche token.
146116
function getReserveTrancheBalance(IERC20Upgradeable tranche) external returns (uint256);
147117

118+
/// @notice Calculates the reserve's tranche token value.
119+
/// @param tranche The address of the tranche token held by the reserve.
120+
/// @return The "value" of the reserve tranche balance held by the reserve.
121+
function getReserveTrancheValue(IERC20Upgradeable tranche) external returns (uint256);
122+
148123
/// @notice Computes the price of each perp token, i.e) reserve value / total supply.
124+
/// @return The average price per perp token.
149125
function getAvgPrice() external returns (uint256);
150126

151127
/// @notice Fetches the list of reserve tokens which are up for rollover.
128+
/// @return The list of reserve tokens up for rollover.
152129
function getReserveTokensUpForRollover() external returns (IERC20Upgradeable[] memory);
153130

154131
/// @notice Computes the amount of perp tokens minted when `trancheInAmt` `trancheIn` tokens

spot-contracts/contracts/_utils/BondHelpers.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.17;
2+
pragma solidity ^0.8.18;
33

44
import { SafeCastUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
55

spot-contracts/contracts/_utils/SignedMathHelpers.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.17;
2+
pragma solidity ^0.8.18;
33

44
/**
55
* @title SignedMathHelpers

spot-contracts/contracts/strategies/BasicFeeStrategy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.17;
2+
pragma solidity ^0.8.18;
33

44
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
55
import { SafeCastUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";

spot-contracts/contracts/strategies/CDRPricingStrategy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.17;
2+
pragma solidity ^0.8.18;
33

44
import { TrancheHelpers } from "../_utils/BondHelpers.sol";
55

0 commit comments

Comments
 (0)