-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.py
26 lines (21 loc) · 1.1 KB
/
variables.py
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
import numpy as np
def init_variables(lambda_stake: float, lambda_collateral: float, lambda_borrow: float, lambda_slash: float, size: int, T_max: int):
stakes = np.zeros(((T_max, size)))
stakes[0] = np.random.exponential(lambda_stake, size)
collateral = np.random.beta(1, lambda_collateral, size)
borrow = np.random.beta(1, lambda_borrow, size)
slash = np.random.beta(1, lambda_slash, size)
loans = np.zeros((T_max, size), dtype=float)
phi = np.zeros((T_max, size), dtype=float)
return stakes, collateral, borrow, slash, loans, phi
def from_demand_to_borrowing_array(borrow: np.ndarray, T_max: int) -> np.ndarray:
return np.random.binomial(1, borrow, (T_max, len(borrow)))
def from_slashing_probability_to_slashing_array(slash: np.ndarray, T_max: int) -> np.ndarray:
return np.random.binomial(1, slash, (T_max, len(slash)))
def getBlockReward(T_max: int) -> np.ndarray:
init = np.ones(T_max)
for i in range(10):
init[i * T_max // 10: min((i + 1) * T_max // 10, T_max)] = 110 - i * 10
return init
def init_stakes_issued(size: int):
return np.zeros(size)