Skip to content

Commit

Permalink
fix max redeemable amount in redemption function
Browse files Browse the repository at this point in the history
  • Loading branch information
RickGriff committed May 27, 2020
1 parent 7e3ec1d commit f279ca4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/contracts/model/model_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()

0 comments on commit f279ca4

Please sign in to comment.