Skip to content

Commit 45f96d8

Browse files
authored
Merge branch 'main' into 441-almf-managed-swap-fee
2 parents 3fa95bd + 4b1946d commit 45f96d8

16 files changed

Lines changed: 764 additions & 109 deletions

chains/plasma/PlasmaConstantsLib.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ pragma solidity ^0.8.28;
44
library PlasmaConstantsLib {
55
address public constant MULTISIG = 0xE929438B5B53984FdBABf8562046e141e90E8099;
66
address public constant PLATFORM = 0xd4D6ad656f64E8644AFa18e7CCc9372E0Cd256f0;
7+
address public constant REVENUE_ROUTER = 0xAf95468B1a624605bbFb862B0FB6e9C73Ad847b8;
8+
address public constant XSTBL_XSTAKING = 0x601572b91DC054Be500392A6d3e15c690140998D;
9+
address public constant RECOVERY = 0x046e7a007C331e0d4DafA66104744dB14a52bBBb;
710

811
// ERC20
12+
address public constant TOKEN_STBL = 0xfdf91362B7E9330F232e500c0236a02B0DE3e492;
13+
address public constant TOKEN_XSTBL = 0xF40D0724599282CaF9dfb66feB630e936bC0CFBE;
914
address public constant TOKEN_USDT0 = 0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb;
1015
address public constant TOKEN_USDE = 0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34;
1116
address public constant TOKEN_SUSDE = 0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2;

guides/AllDeployments.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,20 @@
8686

8787
### Core
8888

89-
* **Platform** `0xd4d6ad656f64e8644afa18e7ccc9372e0cd256f0` [plasmascan](https://plasmascan.to/address/0xd4D6ad656f64E8644AFa18e7CCc9372E0Cd256f0/contract/9745/readProxyContract)
90-
* **Factory** `0x4c5758e3c454a260d98238706ca6f4802cc52746` [plasmascan](https://plasmascan.to/address/0x4C5758e3c454A260D98238706cA6F4802cc52746)
91-
* **MetaVaultFactory** `0xbd5296dc2603942f116b375c8ee373674be86f56` [plasmascan](https://plasmascan.to/address/0xbd5296dc2603942f116b375c8ee373674be86f56)
92-
* **PriceReader** `0xd4af1b538c826e1e90b695314042ab6fd0e7f4aa` [plasmascan](https://plasmascan.to/address/0xd4af1b538c826e1e90b695314042ab6fd0e7f4aa)
93-
* **Swapper** `0x54f22378e03bea25a05a071b60357d31ce535bb9` [plasmascan](https://plasmascan.to/address/0x54f22378e03bea25a05a071b60357d31ce535bb9)
94-
* **HardWorker** `0x73ae48f75ea304ff229d2a1374654672fa8388e7` [plasmascan](https://plasmascan.to/address/0x73ae48f75ea304ff229d2a1374654672fa8388e7)
95-
* **VaultManager** `0x22d031e45a02d6472786b9d7a4fd78f1733d6990` [plasmascan](https://plasmascan.to/address/0x22d031e45a02d6472786b9d7a4fd78f1733d6990)
96-
* **StrategyLogic** `0x5e670b7a1740e8a11aff06335984d696d537b7bc` [plasmascan](https://plasmascan.to/address/0x5e670b7a1740e8a11aff06335984d696d537b7bc)
97-
* **Zap** `0xbc4ff9766074b53c7a4cb91964836c83188f333d` [plasmascan](https://plasmascan.to/address/0xbc4ff9766074b53c7a4cb91964836c83188f333d)
89+
* **Platform** `0xd4d6ad656f64e8644afa18e7ccc9372e0cd256f0` [plasmascan](https://plasmascan.to/address/0xd4D6ad656f64E8644AFa18e7CCc9372E0Cd256f0#readProxyContract)
90+
* **Factory** `0x4c5758e3c454a260d98238706ca6f4802cc52746` [plasmascan](https://plasmascan.to/address/0x4C5758e3c454A260D98238706cA6F4802cc52746#readProxyContract)
91+
* **MetaVaultFactory** `0xbd5296dc2603942f116b375c8ee373674be86f56` [plasmascan](https://plasmascan.to/address/0xbd5296dc2603942f116b375c8ee373674be86f56#readProxyContract)
92+
* **PriceReader** `0xd4af1b538c826e1e90b695314042ab6fd0e7f4aa` [plasmascan](https://plasmascan.to/address/0xd4af1b538c826e1e90b695314042ab6fd0e7f4aa#readProxyContract)
93+
* **Swapper** `0x54f22378e03bea25a05a071b60357d31ce535bb9` [plasmascan](https://plasmascan.to/address/0x54f22378e03bea25a05a071b60357d31ce535bb9#readProxyContract)
94+
* **HardWorker** `0x73ae48f75ea304ff229d2a1374654672fa8388e7` [plasmascan](https://plasmascan.to/address/0x73ae48f75ea304ff229d2a1374654672fa8388e7#readProxyContract)
95+
* **VaultManager** `0x22d031e45a02d6472786b9d7a4fd78f1733d6990` [plasmascan](https://plasmascan.to/address/0x22d031e45a02d6472786b9d7a4fd78f1733d6990#readProxyContract)
96+
* **StrategyLogic** `0x5e670b7a1740e8a11aff06335984d696d537b7bc` [plasmascan](https://plasmascan.to/address/0x5e670b7a1740e8a11aff06335984d696d537b7bc#readProxyContract)
97+
* **Zap** `0xbc4ff9766074b53c7a4cb91964836c83188f333d` [plasmascan](https://plasmascan.to/address/0xbc4ff9766074b53c7a4cb91964836c83188f333d#readProxyContract)
98+
99+
### Tokenomics
100+
101+
* **RevenueRouter** `0xAf95468B1a624605bbFb862B0FB6e9C73Ad847b8` [plasmascan](https://plasmascan.to/address/0xAf95468B1a624605bbFb862B0FB6e9C73Ad847b8#readProxyContract)
102+
* **XStaking** `0x601572b91DC054Be500392A6d3e15c690140998D` [plasmascan](https://plasmascan.to/address/0x601572b91DC054Be500392A6d3e15c690140998D#readProxyContract)
98103

99104
### Periphery
100105

guides/Deploy.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ It is important to verify during deployment. Otherwise, you will have to manuall
66

77
### Plasma
88

9-
`forge script` now show error: `Error: Chain 9745 not supported`.
10-
11-
When deploying Platform via `forge create` we see `Error: Dynamic linking not supported in `create` command - deploy the following library contracts first, then provide the address to link at compile time`.
12-
139
```shell
14-
forge script --rpc-url plasma --slow --broadcast --verify --etherscan-api-key sonic --verifier-url 'https://api.routescan.io/v2/network/mainnet/evm/9745/etherscan' ./script/deploy-core/Deploy.Plasma.s.sol
10+
forge script --rpc-url plasma --slow --broadcast --verify --etherscan-api-key plasma --verifier-url 'https://api.etherscan.io/v2/api?chainid=9745' ./script/deploy-core/Deploy.Plasma.s.sol
11+
```
1512

16-
# verify single
13+
```
14+
# verify on routescan
1715
forge verify-contract --rpc-url plasma --etherscan-api-key sonic --verifier-url 'https://api.routescan.io/v2/network/mainnet/evm/9745/etherscan' --watch 0x70e804364175e23F1c30dFa03BFb19d936E5E81c
1816
```
1917

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
import {Script} from "forge-std/Script.sol";
5+
import {XStaking} from "../../src/tokenomics/XStaking.sol";
6+
7+
contract DeployXStaking is Script {
8+
function run() external {
9+
uint deployerPrivateKey = vm.envUint("PRIVATE_KEY");
10+
vm.startBroadcast(deployerPrivateKey);
11+
new XStaking();
12+
vm.stopBroadcast();
13+
}
14+
15+
function testDeployScript() external {}
16+
}

src/interfaces/IRevenueRouter.sol

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface IRevenueRouter {
1414
event UnitEpochRevenue(uint periodEnded, string unitName, uint stblRevenue);
1515
event ProcessUnitRevenue(uint unitIndex, uint stblGot);
1616
event SetAddresses(address[] addresses);
17-
event SetXShare(uint newShare);
17+
event BuyBackRate(uint bbRate);
1818

1919
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
2020
/* CUSTOM ERRORS */
@@ -34,7 +34,7 @@ interface IRevenueRouter {
3434
address xToken;
3535
address xStaking;
3636
address feeTreasury;
37-
uint xShare;
37+
uint __deprecated_xShare;
3838
uint activePeriod;
3939
uint pendingRevenue;
4040
Unit[] units;
@@ -43,6 +43,10 @@ interface IRevenueRouter {
4343
EnumerableSet.AddressSet assetsAccumulated;
4444
EnumerableMap.AddressToUintMap minSwapAmount;
4545
EnumerableMap.AddressToUintMap maxSwapAmount;
46+
47+
// todo use DAO parameter
48+
uint bbRate;
49+
EnumerableMap.AddressToUintMap pendingRevenueAsset;
4650
}
4751

4852
enum UnitType {
@@ -77,12 +81,12 @@ interface IRevenueRouter {
7781
/// @notice Set max swap amounts for assets
7882
function setMaxSwapAmounts(address[] calldata assets, uint[] calldata maxAmounts) external;
7983

80-
/// @notice Change revenue share for Vaults Unit
81-
function setXShare(uint newShare) external;
82-
8384
/// @notice Set addresses of main-token, xToken, xStaking and feeTreasure token.
8485
function setAddresses(address[] memory addresses_) external;
8586

87+
/// @notice Set buy-back rate for rewards
88+
function setBuyBackRate(uint bbRate) external;
89+
8690
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
8791
/* USER ACTIONS */
8892
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
@@ -144,6 +148,13 @@ interface IRevenueRouter {
144148
/// @notice Get assets that contract hold on balance
145149
function assetsAccumulated() external view returns (address[] memory);
146150

147-
/// @notice Get current xToken revenue share for Vaults Unit
148-
function xShare() external view returns (uint);
151+
/// @notice Buy-back rate for generated revenue
152+
function buyBackRate() external view returns (uint);
153+
154+
/// @notice Asset with pending revenue for distribution
155+
function pendingRevenueAssets() external view returns (address[] memory);
156+
157+
/// @notice Pending revenue in form of asset
158+
/// @param asset Allowed asset address
159+
function pendingRevenueAsset(address asset) external view returns (uint);
149160
}

src/interfaces/IXStaking.sol

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ interface IXStaking {
1111
event Withdraw(address indexed from, uint amount);
1212

1313
event NotifyReward(address indexed from, uint amount);
14-
1514
event ClaimRewards(address indexed from, uint amount);
1615

1716
event NewDuration(uint oldDuration, uint newDuration);
1817

18+
event RewardTokenAllowed(address indexed token, bool allowed);
19+
event NotifyRewardForToken(address indexed token, address indexed from, uint amount);
20+
event ClaimRewardsForToken(address indexed token, address indexed from, uint amount);
21+
22+
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
23+
/* CUSTOM ERRORS */
24+
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
25+
26+
error DaoNotInitialized();
27+
error TokenNotAllowed(address token);
28+
1929
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
2030
/* WRITE FUNCTIONS */
2131
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
@@ -48,12 +58,27 @@ interface IXStaking {
4858
/// Otherwise, the user receives 1 DAO-token for each 1 xToken staked.
4959
function syncDAOBalances(address[] calldata users) external;
5060

61+
/// @notice Allow or disallow reward token
62+
/// @param token Address of reward token
63+
/// @param allowed Allowed state
64+
/// @custom:restricted Only operator
65+
function allowRewardToken(address token, bool allowed) external;
66+
67+
/// @notice Used to notify pending xToken rebases and platform revenue share
68+
/// @custom:restricted Only RevenueRouter or xToken
69+
/// @param token Address of reward token
70+
/// @param amount The amount of main token to be notified
71+
function notifyRewardAmountToken(address token, uint amount) external;
72+
73+
/// @notice Claims pending rewards
74+
/// @param token Address of reward token
75+
function getRewardToken(address token) external;
76+
5177
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
5278
/* VIEW FUNCTIONS */
5379
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
5480

55-
/// @notice Returns the last time the reward was modified or periodFinish if the reward has ended
56-
function lastTimeRewardApplicable() external view returns (uint);
81+
// common data
5782

5883
/// @notice The address of the xToken token (staking/voting token)
5984
/// @return xToken address
@@ -62,6 +87,19 @@ interface IXStaking {
6287
/// @notice Returns the total voting power (equal to total supply in the XStaking)
6388
function totalSupply() external view returns (uint);
6489

90+
/// @notice The duration of notified rewards distribution
91+
function duration() external view returns (uint);
92+
93+
/// @notice Staked amount
94+
/// @param user the address to check
95+
/// @return The staked balance
96+
function balanceOf(address user) external view returns (uint);
97+
98+
// legacy data
99+
100+
/// @notice Returns the last time the reward was modified or periodFinish if the reward has ended
101+
function lastTimeRewardApplicable() external view returns (uint);
102+
65103
/// @notice Last time the rewards system was updated
66104
function lastUpdateTime() external view returns (uint);
67105

@@ -74,9 +112,6 @@ interface IXStaking {
74112
/// @notice Calculates the rewards distributed per second
75113
function rewardRate() external view returns (uint);
76114

77-
/// @notice The duration of notified rewards distribution
78-
function duration() external view returns (uint);
79-
80115
/// @dev Current calculated reward per token
81116
/// @return The return value is scaled (multiplied) by PRECISION = 10 ** 18
82117
function rewardPerToken() external view returns (uint);
@@ -92,8 +127,13 @@ interface IXStaking {
92127
/// @notice User's earned reward
93128
function earned(address account) external view returns (uint);
94129

95-
/// @notice Voting power
96-
/// @param user the address to check
97-
/// @return The staked balance
98-
function balanceOf(address user) external view returns (uint);
130+
// reward tokens data
131+
132+
/// @notice Is token allowed for rewards
133+
function isTokenAllowed(address token) external view returns (bool);
134+
135+
/// @notice User's earned reward of token
136+
/// @param token Address of reward token
137+
/// @param account Address of user
138+
function earnedToken(address token, address account) external view returns (uint);
99139
}

0 commit comments

Comments
 (0)