This repository has been archived by the owner on Nov 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
SophonFarmingState.sol
92 lines (72 loc) · 3.27 KB
/
SophonFarmingState.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface BridgeLike {
function deposit(
address _l2Receiver,
address _l1Token,
uint256 _amount,
uint256 _l2TxGasLimit,
uint256 _l2TxGasPerPubdataByte,
address _refundRecipient
) external payable returns (bytes32 l2TxHash);
}
contract SophonFarmingState {
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
address l2Farm; // Address of the farming contract on Sophon chain
uint256 amount; // total amount of LP tokens earning yield from deposits and boosts
uint256 boostAmount; // total boosted value purchased by users
uint256 depositAmount; // remaining deposits not applied to a boost purchases
uint256 allocPoint; // How many allocation points assigned to this pool. Points to distribute per block.
uint256 lastRewardBlock; // Last block number that points distribution occurs.
uint256 accPointsPerShare; // Accumulated points per share, times 1e18. See below.
string description; // Description of pool.
}
// Info of each user.
struct UserInfo {
uint256 amount; // Amount of LP tokens the user is earning yield on from deposits and boosts
uint256 boostAmount; // Boosted value purchased by the user
uint256 depositAmount; // remaining deposits not applied to a boost purchases
uint256 rewardSettled; // Reward settled.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of points
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accPointsPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accPointsPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
enum PredefinedPool {
sDAI, // MakerDAO (sDAI)
wstETH, // Lido (wstETH)
weETH // ether.fi (weETH)
}
mapping(PredefinedPool => uint256) public typeToId;
// held proceeds from booster sales
mapping(uint256 => uint256) public heldProceeds;
uint256 public boosterMultiplier;
// Points created per block.
uint256 public pointsPerBlock;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint;
// The block number when point mining starts.
uint256 public startBlock;
// The block number when point mining ends.
uint256 public endBlock;
bool internal _initialized;
mapping(address => bool) public poolExists;
uint256 public endBlockForWithdrawals;
BridgeLike public bridge;
mapping(uint256 => bool) public isBridged;
}