From f279ca437a612279777fa8b963669a0b36867da6 Mon Sep 17 00:00:00 2001 From: Rick Date: Wed, 27 May 2020 23:09:18 +0100 Subject: [PATCH] fix max redeemable amount in redemption function --- packages/contracts/model/model_v2.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/contracts/model/model_v2.py b/packages/contracts/model/model_v2.py index 7e32b2149..237b3cded 100644 --- a/packages/contracts/model/model_v2.py +++ b/packages/contracts/model/model_v2.py @@ -7,11 +7,11 @@ def __init__(self): self.D = 0.7 # base fee decay factor self.T = 1 # weighting for token price in loan issuance - self.F = 10 # weighting for momentum in loan issuance + self.F = 1 # weighting for momentum in loan issuance self.lookback = 5 # Lookback parameter for ETH price momentum - self.max_redemption_fraction = 0.1 # Maximum fraction of supply that can be redeemed in a timestep + self.max_redemption_fraction = 1 # Maximum fraction of supply that can be redeemed in a timestep # time series data class Data: @@ -59,8 +59,11 @@ def get_new_redeemed_amount(data, params): if redeemed < 0: return 0 + elif redeemed < max_redeemable: + return redeemed else: - return max(redeemed, max_redeemable) + return max_redeemable + # Decay base fee correctly def get_new_base_fee(data, redeemed_amount): @@ -165,16 +168,16 @@ def sublinear_ETH_price(last_price, steepness, i): data = Data() # Run the model -for i in range(1, 500): +for i in range(1, 250): last_ETH_price = data.ETH_price[-1] # update exogenous ETH price # ETH_price = last_ETH_price - # ETH_price = randomwalk_ETH_price(last_ETH_price) - # ETH_price = oscillating_ETH_price(500, 50, i) + ETH_price = randomwalk_ETH_price(last_ETH_price) + # ETH_price = oscillating_ETH_price(500, 10, i) # ETH_price = quadratic_ETH_price(500, 10, i) - ETH_price = linear_increasing_ETH_price(last_ETH_price, 0.3) + # ETH_price = linear_increasing_ETH_price(last_ETH_price, 10) # ETH_price = linear_decreasing_ETH_price(last_ETH_price, 1) # ETH_price = sublinear_ETH_price(last_ETH_price, 10, i) @@ -246,4 +249,7 @@ def sublinear_ETH_price(last_price, steepness, i): # plt.plot(data.momentum) # plt.plot(data.token_demand) +params_string = f'Parameters: D={params.D} T={params.T} F={params.F} L={params.lookback} r_max={params.max_redemption_fraction}' +plt.figtext(0.5, 0.05, params_string, ha="center", fontsize=10) + plt.show() \ No newline at end of file