Skip to content

Commit

Permalink
Fix first rewards update for Genesis vault
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi committed Jul 29, 2023
1 parent 479daf6 commit e0c3f3f
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 70 deletions.
13 changes: 13 additions & 0 deletions abi/IRewardEthToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalRewards",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
144 changes: 79 additions & 65 deletions abi/IVaultsRegistry.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "factory",
"type": "address"
}
],
"name": "FactoryAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "factory",
"type": "address"
}
],
"name": "FactoryRemoved",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand All @@ -50,11 +24,17 @@
{
"indexed": true,
"internalType": "address",
"name": "impl",
"name": "factory",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "isSupported",
"type": "bool"
}
],
"name": "VaultImplAdded",
"name": "VaultFactoryUpdated",
"type": "event"
},
{
Expand All @@ -63,25 +43,35 @@
{
"indexed": true,
"internalType": "address",
"name": "impl",
"name": "implementation",
"type": "address"
}
],
"name": "VaultImplRemoved",
"type": "event"
},
{
"inputs": [
},
{
"internalType": "address",
"name": "factory",
"type": "address"
}
],
"name": "addFactory",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"components": [
{
"internalType": "bool",
"name": "canUpgradeTo",
"type": "bool"
},
{
"internalType": "bool",
"name": "canMintOsToken",
"type": "bool"
},
{
"internalType": "bool",
"name": "canBurnOsToken",
"type": "bool"
}
],
"indexed": false,
"internalType": "struct IVaultsRegistry.VaultImplConfig",
"name": "config",
"type": "tuple"
}
],
"name": "VaultImplConfigUpdated",
"type": "event"
},
{
"inputs": [
Expand All @@ -96,19 +86,6 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newImpl",
"type": "address"
}
],
"name": "addVaultImpl",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand All @@ -134,9 +111,14 @@
"internalType": "address",
"name": "factory",
"type": "address"
},
{
"internalType": "bool",
"name": "isSupported",
"type": "bool"
}
],
"name": "removeFactory",
"name": "updateVaultFactory",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand All @@ -145,11 +127,33 @@
"inputs": [
{
"internalType": "address",
"name": "impl",
"name": "implementation",
"type": "address"
}
],
"name": "removeVaultImpl",
},
{
"components": [
{
"internalType": "bool",
"name": "canUpgradeTo",
"type": "bool"
},
{
"internalType": "bool",
"name": "canMintOsToken",
"type": "bool"
},
{
"internalType": "bool",
"name": "canBurnOsToken",
"type": "bool"
}
],
"internalType": "struct IVaultsRegistry.VaultImplConfig",
"name": "config",
"type": "tuple"
}
],
"name": "updateVaultImplementation",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand All @@ -158,12 +162,22 @@
"inputs": [
{
"internalType": "address",
"name": "impl",
"name": "implementation",
"type": "address"
}
],
"name": "vaultImpls",
"name": "vaultImplConfigs",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
},
{
"internalType": "bool",
"name": "",
"type": "bool"
},
{
"internalType": "bool",
"name": "",
Expand Down
5 changes: 5 additions & 0 deletions contracts/interfaces/IRewardEthToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ interface IRewardEthToken {
*/
function totalAssets() external view returns (uint256);

/**
* @dev Function for retrieving the total rewards amount.
*/
function totalRewards() external view returns (uint128);

/**
* @dev Function for getting the total penalty.
*/
Expand Down
7 changes: 7 additions & 0 deletions contracts/vaults/ethereum/EthGenesisVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,16 @@ contract EthGenesisVault is Initializable, EthVault, IEthGenesisVault {
function updateState(
IKeeperRewards.HarvestParams calldata harvestParams
) public override(IVaultState, VaultState) {
bool isCollateralized = IKeeperRewards(_keeper).isCollateralized(address(this));

// process total assets delta since last update
int256 totalAssetsDelta = _harvestAssets(harvestParams);

if (!isCollateralized) {
// it's the first harvest, deduct rewards accumulated so far in legacy pool
totalAssetsDelta -= SafeCast.toInt256(_rewardEthToken.totalRewards());
}

// fetch total assets controlled by legacy pool
uint256 legacyPrincipal = _rewardEthToken.totalAssets() - _rewardEthToken.totalPenalty();

Expand Down
5 changes: 0 additions & 5 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ const config: HardhatUserConfig = {
etherscan: {
apiKey: BLOCK_EXPLORER_KEY,
},
docgen: {
outputDir: 'docs',
pages: 'files',
exclude: ['mocks', 'interfaces', 'base', 'libraries'],
},
}

export default config

0 comments on commit e0c3f3f

Please sign in to comment.