Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
80b0b48
Created /native in contracts, and related insurance gauge and underwr…
kyzooghost Jul 22, 2022
281d5b8
completed v1 of UnderwritingLocker.sol and IUnderwritingLocker.sol
kyzooghost Jul 23, 2022
89338e4
completed first draft for UnderwritingLockVoter and related interface
kyzooghost Jul 24, 2022
c8557c7
completed first draft for GaugeController.sol and interface
kyzooghost Jul 25, 2022
88fe616
save repo before update @openzeppelin/contracts dependency
kyzooghost Jul 25, 2022
7c17822
fixed compilation bugs to point where notifying of ERC721Enhanced.sol…
kyzooghost Jul 25, 2022
9665129
successful npx hardhat compile
kyzooghost Jul 25, 2022
da7a3cf
replaced require statements with custom errors
kyzooghost Jul 26, 2022
9064d7f
manually linted gauge contract code
kyzooghost Jul 26, 2022
b7ba72f
started writing unit test for UnderwriterLocker, done for createLock,…
kyzooghost Jul 26, 2022
bd9a6c3
merged emergencywithdraw logic into withdraw for UnderwritingLocker.sol
kyzooghost Jul 27, 2022
abd709a
to-do withdraw function tests for underwritingLocker.sol
kyzooghost Jul 27, 2022
919efba
did withdrawInPart unit test for UnderwritingLocker
kyzooghost Jul 27, 2022
1f21919
completed unit tests for withdrawInPartMultiple() for UnderwritingLoc…
kyzooghost Jul 27, 2022
f11176c
completed UnderwritingLocker.test.ts
kyzooghost Jul 28, 2022
6756461
completed setLockManagerMultiple test for UnderwritingLockVoting.sol
kyzooghost Jul 28, 2022
1721350
implemented withdraw burn mechanic into UnderwritingLocker.sol
kyzooghost Jul 28, 2022
48c6169
completed UnderwritingLocker.test.ts with new withdrawal burn and fun…
kyzooghost Jul 29, 2022
ffc3c31
completed UnderwritingLocker.test.ts with new withdrawal burn and fun…
kyzooghost Jul 29, 2022
98b0113
added extra sanity checks for underwritinglocker.test.ts
kyzooghost Jul 29, 2022
3b50f79
added voting premium mechanic to UnderwritingLockVoting.sol
kyzooghost Jul 29, 2022
2162106
added voting premium mechanic to UnderwritingLockVoting.sol
kyzooghost Jul 29, 2022
fd04b7a
completed more vote() function tests for UnderwritingLockVoting.sol
kyzooghost Jul 30, 2022
2174fb0
completed vote() tests for UnderwritingLockVoting.sol
kyzooghost Jul 30, 2022
4fadff6
save state before changing architecture to move processVotes() logic …
kyzooghost Jul 31, 2022
c300599
completed draft for moving processVotes() to GaugeController.sol
kyzooghost Jul 31, 2022
4839995
optimised assembly block for UnderwritingLockVoting.sol
kyzooghost Jul 31, 2022
85cf9b1
optimised assembly block for GaugeController.sol
kyzooghost Jul 31, 2022
6309659
altered underwritinglocker to enable state variable change during vot…
kyzooghost Aug 1, 2022
bbb8248
added chargePremium function to UnderwritingLocker to enable lock sta…
kyzooghost Aug 1, 2022
fcb6d03
fixed few more edge cases for voting and charging premiums
kyzooghost Aug 2, 2022
ebd7bd5
vote() and voteMultiple() integration tests working for UnderwritingL…
kyzooghost Aug 3, 2022
77eb5b9
vote() and voteMultiple() integration tests working for UnderwritingL…
kyzooghost Aug 3, 2022
f285d9b
completed first draft for UnderwritingLockVoting.test.ts
kyzooghost Aug 3, 2022
978c8b3
completed first block for GaugeController.test.ts
kyzooghost Aug 3, 2022
c0d67ee
started revamp to address => multiple votes scheme
kyzooghost Aug 4, 2022
4cbbb29
refactored processGaugeWeights() function on UnderwritingLockVoting.sol
kyzooghost Aug 5, 2022
0180033
more refactoring on address => multiple votes scheme
kyzooghost Aug 5, 2022
edc103c
more refactoring gauge contracts for unbounded loop DDOS resistance a…
kyzooghost Aug 6, 2022
276e017
rewrote UnderwritingLockVoting.test.ts to fit new contract
kyzooghost Aug 7, 2022
d6a242b
added more anti-ddos features, swapped out _sqrt implementation for 4…
kyzooghost Aug 8, 2022
9f49f97
further ddos tests for gauge voting system
kyzooghost Aug 8, 2022
d17cf06
started basic unit tests for GaugeController.test.ts
kyzooghost Aug 8, 2022
3fd168a
fixed commenting and completed basic unit test kit for GaugeController
kyzooghost Aug 9, 2022
0689fdf
fixed subtle indexing bug with saveupdatestate mechanism in GaugeCont…
kyzooghost Aug 9, 2022
326240f
did coverage tests for gauge contracts
kyzooghost Aug 9, 2022
11a6f62
increased unit test coverage % for vanity
kyzooghost Aug 9, 2022
0daeacc
did slither analysis && removed console logs
kyzooghost Aug 10, 2022
7f363ea
did aurora-testnet deploy script for gauge system
kyzooghost Aug 10, 2022
fa633ee
trivial linting changes
kyzooghost Aug 10, 2022
2c815b5
changed burn mechanism to call burn() instead of transfer to address(…
kyzooghost Aug 17, 2022
b02a0c1
added updated role to GaugeController & UnderwritingLockVoting, but s…
kyzooghost Aug 17, 2022
a7abb5b
fixed hardhat testing bug mentioned in previous commit
kyzooghost Aug 17, 2022
8c6eaa9
deploy on goerli
leonardishere Aug 18, 2022
853867c
feat/UwpUwe (#276)
leonardishere Aug 24, 2022
43c799d
Merge branch 'feat/SolaceNative' into feat/NativeGauge
leonardishere Aug 24, 2022
ea2eafc
Feat/nativeGauge (#277)
kyzooghost Aug 24, 2022
ee6f5bf
feat/depositHelper (#278)
leonardishere Aug 24, 2022
1313dac
fix/tests and scripts (#282)
leonardishere Aug 25, 2022
96a38c0
mixed feat/NativeGauge -> feat/SolaceNative merge conflict
kyzooghost Aug 25, 2022
764ec4d
added custom epoch lengths to gauge contracts
kyzooghost Aug 25, 2022
622cd05
added bribeController role to voting contract
kyzooghost Aug 26, 2022
df464fa
feat/upgradeableUwp (#283)
leonardishere Sep 8, 2022
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: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"avoid-suicide": "error",
"avoid-sha3": "warn",
"compiler-version": ["error", "0.8.6"],
"func-visibility": ["warn", { "ignoreConstructors": true } ]
"func-visibility": ["warn", { "ignoreConstructors": true } ],
"not-rely-on-time": "off"
}
}
25 changes: 25 additions & 0 deletions contracts/interfaces/native/GaugeStructs.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.6;

library GaugeStructs {
struct Vote {
uint256 gaugeID;
uint256 votePowerBPS;
}

/// @dev Struct pack into single 32-byte word
/// @param _votingContractsIndex Index for _votingContracts for last incomplete updateGaugeWeights() call.
/// @param _votersIndex Index for _voters[savedIndex_votingContracts] for last incomplete updateGaugeWeights() call.
/// @param _votesIndex Index for _votes[savedIndex_votingContracts][savedIndex_voters] for last incomplete updateGaugeWeights() call.
struct UpdateInfo {
uint80 _votingContractsIndex; // [0:80]
uint88 _votersIndex; // [80:168]
uint88 _votesIndex; // [168:256]
}

struct Gauge {
bool active; // [0:8]
uint248 rateOnLine; // [8:256] Max value we reasonably expect is ~20% or 2e17. We only need log 2 2e17 = ~58 bits for this.
string name;
}
}
78 changes: 78 additions & 0 deletions contracts/interfaces/native/IDepositHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.6;


/**
* @title IDepositHelper
* @author solace.fi
* @notice The process of depositing into Solace Native requires multiple steps across multiple contracts. This helper contract allows users to deposit with a single transaction.
*
* These steps are
* 1. Deposit governance token into [`UWP`](./../../native/UnderwritingPool).
* 2. Deposit [`UWP`](./../../native/UnderwritingPool) into [`UWE`](./../../native/UnderwritingEquity).
* 3. Deposit [`UWE`](./../../native/UnderwritingEquity) into an [`Underwriting Lock`](./../../native/UnderwritingLocker).
*
* These steps can be replaced with [`depositAndLock()`](#depositandlock) or [`depositIntoLock()`](#depositintolock).
*/
interface IDepositHelper {

/***************************************
VIEW FUNCTIONS
***************************************/

/**
* @notice Address of the [underwriting pool](./../../native/UnderwritingPool).
* @return uwp The underwriting pool.
*/
function underwritingPool() external view returns (address uwp);

/**
* @notice Address of [underwriting equity](./../../native/UnderwritingEquity).
* @return uwe The underwriting equity.
*/
function underwritingEquity() external view returns (address uwe);

/**
* @notice Address of [underwriting locker](./../../native/UnderwritingLocker).
* @return locker The underwriting locker.
*/
function underwritingLocker() external view returns (address locker);

/**
* @notice Calculates the amount of [`UWE`](./../../native/UnderwritingEquity) minted for an amount of a token deposited.
* The deposit token may be one of the tokens in [`UWP`](./../../native/UnderwritingPool), the [`UWP`](./../../native/UnderwritingPool) token, or the [`UWE`](./../../native/UnderwritingEquity) token.
* @param depositToken The address of the token to deposit.
* @param depositAmount The amount of the token to deposit.
* @return uweAmount The amount of [`UWE`](./../../native/UnderwritingEquity) that will be minted to the receiver.
*/
function calculateDeposit(address depositToken, uint256 depositAmount) external view returns (uint256 uweAmount);

/***************************************
DEPOSIT FUNCTIONS
***************************************/

/**
* @notice Deposits tokens into [`UWE`](./../../native/UnderwritingEquity) and deposits [`UWE`](./../../native/UnderwritingEquity) into a new [`UWE Lock`](./../../native/UnderwritingLocker).
* @param depositToken Address of the token to deposit.
* @param depositAmount Amount of the token to deposit.
* @param lockExpiry The timestamp the lock will unlock.
* @return lockID The ID of the newly created [`UWE Lock`](./../../native/UnderwritingLocker).
*/
function depositAndLock(
address depositToken,
uint256 depositAmount,
uint256 lockExpiry
) external returns (uint256 lockID);

/**
* @notice Deposits tokens into [`UWE`](./../../native/UnderwritingEquity) and deposits [`UWE`](./../../native/UnderwritingEquity) into an existing [`UWE Lock`](./../../native/UnderwritingLocker).
* @param depositToken Address of the token to deposit.
* @param depositAmount Amount of the token to deposit.
* @param lockID The ID of the [`UWE Lock`](./../../native/UnderwritingLocker) to deposit into.
*/
function depositIntoLock(
address depositToken,
uint256 depositAmount,
uint256 lockID
) external;
}
74 changes: 74 additions & 0 deletions contracts/interfaces/native/IFluxMegaOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.6;

import "./IPriceOracle.sol";

/**
* @title IFluxMegaOracle
* @author solace.fi
* @notice An oracle that consumes data from [Flux](https://fluxprotocol.org) and returns it in a useable format.
*
* [Governance](/docs/protocol/governance) can add or remove price feeds via [`addPriceFeeds()`](#addpricefeeds) and [`removePriceFeeds()`](#removepricefeeds). Users can view price feeds via [`priceFeedForToken(address token)`](#pricefeedfortoken). Users can use the price feeds via [`valueOfTokens()`](#valueoftokens). Users can list price feeds via [`tokensLength()`](#tokenslength) and [`tokenByIndex()`](#tokenbyindex).
*/
interface IFluxMegaOracle is IPriceOracle {

/***************************************
EVENTS
***************************************/

/// @notice Emitted when a price feed is added.
event PriceFeedAdded(address indexed token);
/// @notice Emitted when a price feed is removed.
event PriceFeedRemoved(address indexed token);

/***************************************
VIEW FUNCTIONS
***************************************/

struct PriceFeedData {
address token;
address priceFeed;
uint8 tokenDecimals;
uint8 priceFeedDecimals;
}

/**
* @notice Returns information about the price feed for a token.
* @dev Returns a zero struct if no known price feed.
* @param token The token to query price feed data of.
* @return data Information about te price feed.
*/
function priceFeedForToken(address token) external view returns (PriceFeedData memory data);

/**
* @notice Lists the tokens in the oracle.
* @dev Enumerable `[0,tokensLength]`
* @param index The index to query.
* @return token The address of the token at that index.
*/
function tokenByIndex(uint256 index) external view returns (address token);

/**
* @notice The number of tokens with feeds in this oracle.
* @return len The number of tokens.
*/
function tokensLength() external view returns (uint256 len);

/***************************************
GOVERNANCE FUNCTIONS
***************************************/

/**
* @notice Adds price feeds.
* Can only be called by the current [**governor**](/docs/protocol/governance).
* @param feeds The list of price feeds to add.
*/
function addPriceFeeds(PriceFeedData[] memory feeds) external;

/**
* @notice Removes price feeds.
* Can only be called by the current [**governor**](/docs/protocol/governance).
* @param tokens The list of price feeds to remove.
*/
function removePriceFeeds(address[] memory tokens) external;
}
16 changes: 16 additions & 0 deletions contracts/interfaces/native/IFluxPriceFeed.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.6;


/**
* @title Flux first-party price feed oracle
* @author fluxprotocol.org
* @notice Simple data posting on chain of a scalar value, compatible with Chainlink V2 and V3 aggregator interface
*/
interface IFluxPriceFeed {

/**
* @notice answer from the most recent report
*/
function latestAnswer() external view returns (int256);
}
Loading