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

veION UI #669

Open
wants to merge 172 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
168ae6f
rough createlock, withdraw and checkpoint monitoring
jourdanDunkley Aug 27, 2024
a8d1465
can now lock up multiple different lps in one veNFT
jourdanDunkley Aug 30, 2024
3a386db
lock up multiple assets in one veNFT
jourdanDunkley Aug 30, 2024
ce39e33
removed unused comment
jourdanDunkley Aug 30, 2024
ca68395
removed test
jourdanDunkley Aug 30, 2024
571dc79
create lock
jourdanDunkley Sep 4, 2024
86d2552
multiple lp stakes
jourdanDunkley Sep 4, 2024
c258454
test checks all relevant state changes, prefixed storage vars with s_…
jourdanDunkley Sep 4, 2024
b71960f
added test for testing multiple locks within same week
jourdanDunkley Sep 5, 2024
c9217b4
added increase amount and increase unlock time functions and tests
jourdanDunkley Sep 5, 2024
bc9b372
withdraw
jourdanDunkley Sep 5, 2024
26cb012
added merge function
jourdanDunkley Sep 5, 2024
f93a0c0
added and tested lock permanent, unlock permanent, merge, split
jourdanDunkley Sep 5, 2024
19fa2cd
added boost calculation
jourdanDunkley Sep 6, 2024
a843b2e
tested boost after creating lock and increasing lock time
jourdanDunkley Sep 6, 2024
18e2505
began implementing stake strategy logic
jourdanDunkley Sep 9, 2024
2fc1d5a
allows for staking of lp at the same time a lock is created
jourdanDunkley Sep 9, 2024
5f2c38a
added staking lp logic
jourdanDunkley Sep 9, 2024
949f0a4
added emissions claiming for staked lp
jourdanDunkley Sep 10, 2024
f3434b4
additional testing for lp staking
jourdanDunkley Sep 10, 2024
f74820c
early withdrawals now attract a fee
jourdanDunkley Sep 10, 2024
b4b389b
veion page
shikhar360 Sep 13, 2024
a9c2b7b
Merge branch 'development' into feat/veION
rhlsthrm Sep 13, 2024
ab3d6e9
frontpage
shikhar360 Sep 16, 2024
6b1e02b
voting contract
jourdanDunkley Sep 16, 2024
bcb5c20
Add veION Flywheel
antisaa Sep 17, 2024
93b17ab
fix build
antisaa Sep 17, 2024
2da0003
Connect Gauge with Voter
antisaa Sep 17, 2024
606f519
Merge branch 'development' into feat/veion
shikhar360 Sep 18, 2024
641b43c
rip grammer mistakes
shikhar360 Sep 18, 2024
f0f246f
little grammer fix
shikhar360 Sep 18, 2024
348662e
added bribing logic
jourdanDunkley Sep 19, 2024
ff5a6e8
Switch to voting for market + side & add utilization to Voter
antisaa Sep 20, 2024
b46c0ab
added other pages
shikhar360 Sep 23, 2024
7e5ed0a
Cleanup Voter
antisaa Sep 23, 2024
9a76520
rearranged functions for better organization
jourdanDunkley Sep 24, 2024
d79b996
basic popup
shikhar360 Sep 25, 2024
8897450
added success state
shikhar360 Sep 25, 2024
d71d0d1
Fix utilization
antisaa Sep 25, 2024
486aa64
added governance page
shikhar360 Sep 25, 2024
3e4762b
added myveionRows
shikhar360 Sep 26, 2024
aa92fd0
added delegate
shikhar360 Sep 30, 2024
943621d
Merge branch 'development' into feat/veion
shikhar360 Sep 30, 2024
8fdc799
extend page and claim popup added
shikhar360 Sep 30, 2024
fe96ebf
multi lp voting
jourdanDunkley Oct 1, 2024
95b7df6
resolved conflicts
jourdanDunkley Oct 1, 2024
4914c21
Merge branch 'development' into feat/veion
shikhar360 Oct 3, 2024
bf471a7
mobile screen fix
shikhar360 Oct 3, 2024
e2e27e4
renamed delegate
shikhar360 Oct 3, 2024
2743635
build fix
shikhar360 Oct 3, 2024
559df50
build fix
shikhar360 Oct 3, 2024
3bc1395
eliminated most nested looping, created relevant internal functions a…
jourdanDunkley Oct 3, 2024
eee492e
started to transition BribeRewards to be multi lp compliant
jourdanDunkley Oct 4, 2024
ad44a53
added manage popup
shikhar360 Oct 4, 2024
fc5861e
Add emissions manager
antisaa Oct 7, 2024
2ed4630
added voting page
shikhar360 Oct 7, 2024
62fdc8d
revamped staking system using custodial contract wallets
jourdanDunkley Oct 7, 2024
1a30531
Merge branch 'feat/veION' of https://github.com/ionicprotocol/monorep…
jourdanDunkley Oct 7, 2024
0251d22
continued work on briberewards, fixed stack too deep issues, contract…
jourdanDunkley Oct 8, 2024
051fabb
feat: generated
rhlsthrm Oct 8, 2024
e212a78
added interaction for claim and getveion
shikhar360 Oct 10, 2024
08c478e
mpo logic
jourdanDunkley Oct 10, 2024
c6c7a83
Merge branch 'feat/veION' of https://github.com/ionicprotocol/monorep…
jourdanDunkley Oct 10, 2024
b457b79
removed utilization as a guage
jourdanDunkley Oct 10, 2024
2251726
bribe calculation based on weekly lp pricing
jourdanDunkley Oct 10, 2024
0dafd1a
consolidated boost logic for all boost types: duration, event and aer…
jourdanDunkley Oct 10, 2024
bbfa73d
delegation logic
jourdanDunkley Oct 13, 2024
b96b2fe
support for locking additional asset
jourdanDunkley Oct 13, 2024
3650bdf
edge cases for withdraw, merge, split
jourdanDunkley Oct 14, 2024
d4d0b8b
function for getting total veION locked value per user
jourdanDunkley Oct 15, 2024
652d64d
Add 2,5% LP case and user reporting
antisaa Oct 15, 2024
0f92a44
Merge branch 'feat/veION' into feat/veion-ui
vidvidvid Oct 21, 2024
806d3df
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 21, 2024
c1109cb
set up shadcn
vidvidvid Oct 21, 2024
7c2c072
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 22, 2024
975dd00
fix imports
vidvidvid Oct 22, 2024
bb5ae61
refactor veion page to shadcn
vidvidvid Oct 22, 2024
e4502ee
fix ui
vidvidvid Oct 22, 2024
20c5165
ui update
vidvidvid Oct 22, 2024
44df7e1
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 24, 2024
e7ff10e
veion ui updates
vidvidvid Oct 24, 2024
36e357e
add veion/incentives page
vidvidvid Oct 24, 2024
24a97e2
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 24, 2024
7818d8a
main ui
vidvidvid Oct 25, 2024
da8c286
add liquidity dialog
vidvidvid Oct 25, 2024
de7a5b2
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 25, 2024
f55e666
rename and lint
vidvidvid Oct 25, 2024
b1a5cc4
get veion dialog
vidvidvid Oct 25, 2024
7e396d0
add network dropdown on get veion dialog
vidvidvid Oct 25, 2024
8aa5e9f
fix date slider
vidvidvid Oct 25, 2024
f769848
migrate ion dialog
vidvidvid Oct 25, 2024
7f0aec8
make NetworkSelect static
vidvidvid Oct 25, 2024
dd9bc74
improve tables
vidvidvid Oct 25, 2024
fb1fc3b
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 25, 2024
b72e8a1
improve myIon and delegate ui
vidvidvid Oct 25, 2024
279817b
ui fixes to governance page
vidvidvid Oct 25, 2024
0284ac8
lint
vidvidvid Oct 25, 2024
c31a47d
voting page
vidvidvid Oct 25, 2024
f5d9678
add network switcher and pending votes only switch
vidvidvid Oct 25, 2024
3eb50ef
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 28, 2024
d7ba5a0
manage dialog
vidvidvid Oct 28, 2024
369b255
improve governance header
vidvidvid Oct 28, 2024
031089b
universal claim
vidvidvid Oct 28, 2024
8856873
extend veion dialog
vidvidvid Oct 28, 2024
857605a
refactor and reuse precision slider
vidvidvid Oct 29, 2024
13b1360
reuse lock duration picker
vidvidvid Oct 29, 2024
f80c594
add emissions link
vidvidvid Oct 29, 2024
7bfe56d
rename label
vidvidvid Oct 29, 2024
c222ddd
feat: contracts build
rhlsthrm Oct 29, 2024
4d6da8d
lint fix
vidvidvid Oct 29, 2024
f368540
organise files
vidvidvid Oct 29, 2024
adfaf62
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 30, 2024
9d8159a
add toast
vidvidvid Oct 30, 2024
17306b8
export veIONContracts from sdk
vidvidvid Oct 30, 2024
89e2c82
set up useManageMyVeion and prepare increaseAmount fn
vidvidvid Oct 30, 2024
c5db612
set up calls for manage dialog
vidvidvid Oct 30, 2024
bc9962d
prepare useContractWrite and refactor useManageMyVeION
vidvidvid Oct 30, 2024
674477b
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 30, 2024
41302af
smol fix
vidvidvid Oct 30, 2024
f00213d
add, withdraw, lock
vidvidvid Oct 31, 2024
1fbd129
Merge branch 'development' into feat/veion-ui
vidvidvid Oct 31, 2024
a6a885a
set up universal claim
vidvidvid Oct 31, 2024
125ec30
set up extend and claim
vidvidvid Oct 31, 2024
a6e2e37
set up undelegate
vidvidvid Oct 31, 2024
4bbf471
set up market vote
vidvidvid Nov 1, 2024
96a8b02
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 1, 2024
efad6df
improve add, withdraw & lock
vidvidvid Nov 1, 2024
b9f4fb4
lint
vidvidvid Nov 1, 2024
48c781a
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 3, 2024
a546c78
fetch address balances & improve ui/ux
vidvidvid Nov 3, 2024
39345e2
unify ui & fix values. improve MaxDeposit
vidvidvid Nov 3, 2024
8e3dc03
update emission status ui
vidvidvid Nov 3, 2024
b707028
improvie /veion ui
vidvidvid Nov 4, 2024
b997f7b
improve incentives
vidvidvid Nov 4, 2024
c211bd4
improve network dropdown
vidvidvid Nov 4, 2024
1b20f63
wip
vidvidvid Nov 4, 2024
f12a9bd
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 4, 2024
0ef0193
prepare total, staked & locked values
vidvidvid Nov 5, 2024
cbd4b7d
simplify context
vidvidvid Nov 5, 2024
609ceb5
submodule issue fix
Nov 5, 2024
d90cb91
submodule issue fix
Nov 5, 2024
1fa8b19
netlify fix
Nov 5, 2024
759f099
netlify fix
Nov 5, 2024
1f30468
netlify fix
Nov 5, 2024
d13b8dc
fetch my and delegate veion lp
vidvidvid Nov 5, 2024
17a0628
Merge remote-tracking branch 'origin/feat/veion-ui' into feat/veion-ui
vidvidvid Nov 5, 2024
3b56dbe
build fix
vidvidvid Nov 5, 2024
f5ab810
Remove stale submodule configuration for packages/sdk/lib/contracts
Nov 5, 2024
342b0a2
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 6, 2024
dd7fa87
set up vote table & data
vidvidvid Nov 6, 2024
95327b3
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 7, 2024
b2d93fe
fix vote table inputs
vidvidvid Nov 7, 2024
045aa9c
set skeletons for table
vidvidvid Nov 7, 2024
2dfc463
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 7, 2024
6e948d6
add loaders to common table
vidvidvid Nov 7, 2024
97ce81a
fix build
vidvidvid Nov 7, 2024
fee96ff
unify universal claim
vidvidvid Nov 7, 2024
e769972
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 7, 2024
d29f4bb
improve universal claim ui
vidvidvid Nov 7, 2024
607b9bd
fix filtering
vidvidvid Nov 8, 2024
b14786d
simplify voting
vidvidvid Nov 8, 2024
956861e
Merge branch 'development' into feat/veion-ui
vidvidvid Nov 28, 2024
4a5efbd
fix
vidvidvid Nov 28, 2024
f4f1eff
Merge branch 'development' into feat/veion-ui
vidvidvid Dec 5, 2024
674c605
fix tables
vidvidvid Dec 5, 2024
46370b6
create dashboard supply table component
vidvidvid Dec 11, 2024
3911e2e
Merge branch 'development' into feat/dashboard-design-update
vidvidvid Dec 24, 2024
20631e6
rename
vidvidvid Dec 24, 2024
7c08a9c
move components to a single folder
vidvidvid Dec 24, 2024
9a5ba70
Merge branch 'development' into feat/veion-ui
vidvidvid Dec 24, 2024
dff6c4e
fix usestore
vidvidvid Dec 24, 2024
88a2439
Merge branch 'feat/dashboard-design-update' into feat/veion-ui
vidvidvid Dec 24, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/package-contracts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ jobs:

- name: Run forge tests locally
run: yarn workspace @ionicprotocol/contracts forge test -vv --no-match-contract '${{ env.EXCLUDE_TESTS }}|${{ env.FLAKY_TESTS }}|${{ env.SLOW_TESTS }}'
continue-on-error: true # Skip the job on test failure
continue-on-error: true # Skip the job on test failure
60 changes: 30 additions & 30 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
[submodule "packages/contracts/lib/forge-std"]
path = packages/contracts/lib/forge-std
url = https://github.com/brockelmore/forge-std
[submodule "packages/contracts/lib/openzeppelin-contracts-upgradeable"]
path = packages/contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "packages/contracts/lib/solmate"]
path = packages/contracts/lib/solmate
url = https://github.com/rari-capital/solmate
[submodule "packages/contracts/lib/openzeppelin-contracts"]
path = packages/contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "packages/contracts/lib/pyth-sdk-solidity"]
path = packages/contracts/lib/pyth-sdk-solidity
url = https://github.com/pyth-network/pyth-sdk-solidity
[submodule "packages/contracts/lib/solidity-bytes-utils"]
path = packages/contracts/lib/solidity-bytes-utils
url = https://github.com/GNSPS/solidity-bytes-utils
[submodule "packages/contracts/lib/ops"]
path = packages/contracts/lib/ops
url = https://github.com/gelatodigital/ops
[submodule "packages/contracts/lib/adrastia-periphery"]
path = packages/contracts/lib/adrastia-periphery
url = https://github.com/adrastia-oracle/adrastia-periphery
[submodule "packages/contracts/lib/devtools"]
path = packages/contracts/lib/devtools
url = https://github.com/LayerZero-Labs/devtools
[submodule "packages/contracts/lib/layerzero-v2"]
path = packages/contracts/lib/layerzero-v2
url = https://github.com/LayerZero-Labs/layerzero-v2
[submodule "packages/contracts/lib/forge-std"]
path = packages/contracts/lib/forge-std
url = https://github.com/brockelmore/forge-std
[submodule "packages/contracts/lib/openzeppelin-contracts-upgradeable"]
path = packages/contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "packages/contracts/lib/solmate"]
path = packages/contracts/lib/solmate
url = https://github.com/rari-capital/solmate
[submodule "packages/contracts/lib/openzeppelin-contracts"]
path = packages/contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "packages/contracts/lib/pyth-sdk-solidity"]
path = packages/contracts/lib/pyth-sdk-solidity
url = https://github.com/pyth-network/pyth-sdk-solidity
[submodule "packages/contracts/lib/solidity-bytes-utils"]
path = packages/contracts/lib/solidity-bytes-utils
url = https://github.com/GNSPS/solidity-bytes-utils
[submodule "packages/contracts/lib/ops"]
path = packages/contracts/lib/ops
url = https://github.com/gelatodigital/ops
[submodule "packages/contracts/lib/adrastia-periphery"]
path = packages/contracts/lib/adrastia-periphery
url = https://github.com/adrastia-oracle/adrastia-periphery
[submodule "packages/contracts/lib/devtools"]
path = packages/contracts/lib/devtools
url = https://github.com/LayerZero-Labs/devtools
[submodule "packages/contracts/lib/layerzero-v2"]
path = packages/contracts/lib/layerzero-v2
url = https://github.com/LayerZero-Labs/layerzero-v2
14 changes: 14 additions & 0 deletions cache/solidity-files-cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"_format": "ethers-rs-sol-cache-3",
"paths": {
"artifacts": "out",
"build_infos": "out\\build-info",
"sources": "src",
"tests": "test",
"scripts": "script",
"libraries": [
"lib"
]
},
"files": {}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"dependencies": {
"@next/react-dev-overlay": "^14.1.4",
"@resolver-engine/core": "^0.3.3",
"@tanstack/react-table": "^8.20.5",
"lucide-react": "^0.454.0",
"next": "^14.2.4"
},
"scripts": {
Expand Down
141 changes: 141 additions & 0 deletions packages/contracts/contracts/EmissionsManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

import { ERC20 } from "solmate/tokens/ERC20.sol";
import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";

import { Ownable2StepUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol";
import { IonicFlywheelCore } from "./ionic/strategies/flywheel/IonicFlywheelCore.sol";
import { IonicComptroller } from "./compound/ComptrollerInterface.sol";
import { BasePriceOracle } from "./oracles/BasePriceOracle.sol";
import { ICErc20 } from "./compound/CTokenInterfaces.sol";
import { PoolDirectory } from "./PoolDirectory.sol";
import {IEmissionsManager} from "./IEmissionsManager.sol";
import { IveION } from "./veION/interfaces/IveION.sol";

interface Oracle {
function getUnderlyingPrice(address) external returns (uint256);
}

contract EmissionsManager is IEmissionsManager, Ownable2StepUpgradeable {
using SafeTransferLib for ERC20;

address poolLens;
address protocalAddress;
PoolDirectory public fpd;
ERC20 rewardToken;
IveION veION;
mapping(address => bool) isBlacklisted;

function initialize(PoolDirectory _fpd, address _protocalAddress, ERC20 _rewardToken) public initializer {
__Ownable2Step_init();
protocalAddress = _protocalAddress;
fpd = _fpd;
rewardToken = _rewardToken;
}

function setVeIon(IveION _veIon) external onlyOwner {
veION = _veIon;
}

function _getUserTotalCollateral(address _user) internal view returns(uint256) {
uint256 totalColateralInETH = 0;
(, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();
for (uint256 i = 0; i < pools.length; i++) {
IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);
BasePriceOracle oracle = comptroller.oracle();
ICErc20[] memory cTokens = comptroller.getAssetsIn(_user);
for (uint256 j = 0; j < cTokens.length; j++) {
uint256 supplyBalance = cTokens[j].balanceOfUnderlying(_user);
uint256 collateralInETH = supplyBalance * oracle.getUnderlyingPrice(cTokens[j]) / 1e18;
totalColateralInETH += collateralInETH;
}
}
return totalColateralInETH;
}

function getUserTotalCollateral(address _user) external view returns(uint256) {
return _getUserTotalCollateral(_user);
}

function checkCollateralRatio(address _user) internal view returns(bool) {
uint256 userCollateralValue = _getUserTotalCollateral(_user);
uint256 userLPValue = veION.getTotalEthValueOfTokens(_user);
if (userLPValue * 1000 / userCollateralValue >= 25) {
return true;
}
else return false;
}

function reportUser(address _user) external returns(bool) {
if (!checkCollateralRatio(_user)) {
isBlacklisted[_user] = true;
blacklistUserAndClaimEmissions(_user);
return true;
}
else return false;
}

function whitelistUser(address _user) external returns(bool) {
if (checkCollateralRatio(_user)) {
isBlacklisted[_user] = false;
(, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();
for (uint256 i = 0; i < pools.length; i++) {
IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);
ICErc20[] memory cTokens = comptroller.getAssetsIn(_user);
for (uint256 j = 0; j < cTokens.length; j++) {
address[] memory flywheelAddresses = comptroller.getAccruingFlywheels();
for (uint256 k = 0; k < flywheelAddresses.length; k++) {
IonicFlywheelCore flywheel = IonicFlywheelCore(flywheelAddresses[k]);
if (address(flywheel.rewardToken()) == address(rewardToken)) {
flywheel.whitelistUser(ERC20(address(cTokens[j])), _user);
flywheel.accrue(ERC20(address(cTokens[j])), _user);
}
}
}
}
return true;
}
else return false;
}

function isUserBlacklisted(address _user) external view returns (bool) {
return isBlacklisted[_user];
}

function blacklistUserAndClaimEmissions(address user) public returns (uint256 rewardsClaimed) {
uint256 balanceBefore = ERC20(rewardToken).balanceOf(address(this));
(, PoolDirectory.Pool[] memory pools) = fpd.getActivePools();
for (uint256 i = 0; i < pools.length; i++) {
IonicComptroller comptroller = IonicComptroller(pools[i].comptroller);
ERC20[] memory markets;
{
ICErc20[] memory cerc20s = comptroller.getAllMarkets();
markets = new ERC20[](cerc20s.length);
for (uint256 j = 0; j < cerc20s.length; j++) {
markets[j] = ERC20(address(cerc20s[j]));
}
}

address[] memory flywheelAddresses = comptroller.getAccruingFlywheels();
for (uint256 k = 0; k < flywheelAddresses.length; k++) {
IonicFlywheelCore flywheel = IonicFlywheelCore(flywheelAddresses[k]);
if (address(flywheel.rewardToken()) == address(rewardToken)) {
for (uint256 m = 0; m < markets.length; m++) {
flywheel.accrue(markets[m], user);
flywheel.updateBlacklistBalances(markets[m], user);
}
flywheel.takeRewardsFromUser(user, address(this));
}
}
}

uint256 balanceAfter = ERC20(rewardToken).balanceOf(address(this));
uint256 totalClaimed = balanceAfter - balanceBefore;
if (totalClaimed > 0) {
rewardToken.safeTransferFrom(address(this), msg.sender, totalClaimed * 80 / 100);
rewardToken.safeTransferFrom(address(this), protocalAddress, totalClaimed * 20 / 100);
}
return totalClaimed;
}
}
6 changes: 6 additions & 0 deletions packages/contracts/contracts/IEmissionsManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

interface IEmissionsManager {
function isUserBlacklisted(address _user) external returns (bool);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ contract IonicFlywheel is IonicFlywheelCore, IIonicFlywheel {
bool public constant isFlywheel = true;

function flywheelPreSupplierAction(address market, address supplier) external {
_updateBlacklistBalances(ERC20(market), supplier);
accrue(ERC20(market), supplier);
}

function flywheelPreBorrowerAction(address market, address borrower) external {}

function flywheelPreTransferAction(address market, address src, address dst) external {
_updateBlacklistBalances(ERC20(market), src);
_updateBlacklistBalances(ERC20(market), dst);
accrue(ERC20(market), src, dst);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contract IonicFlywheelBorrow is IonicFlywheelCore, IIonicFlywheel {
function flywheelPreSupplierAction(address market, address supplier) external {}

function flywheelPreBorrowerAction(address market, address borrower) external {
_updateBlacklistBalances(ERC20(market), borrower);
accrue(ERC20(market), borrower);
}

Expand Down
Loading
Loading