Hatch, token vesting works in Organization setup
This commit is contained in:
parent
f6a9f8011f
commit
e07fcf5c7d
36
hatch.py
36
hatch.py
|
|
@ -58,39 +58,45 @@ class TokenBatch:
|
||||||
return 1.0
|
return 1.0
|
||||||
|
|
||||||
class Organization:
|
class Organization:
|
||||||
def __init__(self, total_hatch_raise, funding_pool_fraction, token_supply_millions, exit_tribute=0):
|
def __init__(self, total_hatch_raise, token_supply, funding_pool_fraction=0.2, exit_tribute=0):
|
||||||
# a fledgling organization starts out in the hatching phase. After the hatch phase ends, money from new investors will only go into the collateral pool.
|
# a fledgling organization starts out in the hatching phase. After the hatch phase ends, money from new investors will only go into the collateral pool.
|
||||||
# Essentials
|
# Essentials
|
||||||
self.funding_pool_fraction = funding_pool_fraction
|
self.funding_pool_fraction = funding_pool_fraction
|
||||||
self._collateral_pool = (1-funding_pool_fraction) * total_hatch_raise # (1-0.35) -> 0.65 * total_hatch_raise = 65% collateral, 35% funding
|
self._collateral_pool = (1-funding_pool_fraction) * total_hatch_raise # (1-0.35) -> 0.65 * total_hatch_raise = 65% collateral, 35% funding
|
||||||
self._funding_pool = funding_pool_fraction * total_hatch_raise # 0.35 * total_hatch_raise = 35%
|
self._funding_pool = funding_pool_fraction * total_hatch_raise # 0.35 * total_hatch_raise = 35%
|
||||||
self._token_supply = token_supply_millions
|
self._token_supply = token_supply
|
||||||
self._hatch_tokens = token_supply_millions # hatch_tokens keeps track of the number of tokens that were created when hatching, so we can calculate the unlocking of those
|
self._hatch_tokens = token_supply # hatch_tokens keeps track of the number of tokens that were created when hatching, so we can calculate the unlocking of those
|
||||||
self.bonding_curve = AugmentedBondingCurve(self._collateral_pool, token_supply_millions)
|
self.bonding_curve = AugmentedBondingCurve(self._collateral_pool, token_supply)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
self.exit_tribute = exit_tribute
|
self.exit_tribute = exit_tribute
|
||||||
|
|
||||||
def deposit(self, dai_millions):
|
def deposit(self, dai):
|
||||||
"""
|
"""
|
||||||
Deposit DAI after the hatch phase. This means all the incoming deposit goes to the collateral pool.
|
Deposit DAI after the hatch phase. This means all the incoming deposit goes to the collateral pool.
|
||||||
"""
|
"""
|
||||||
tokens, realized_price = self.bonding_curve.deposit(dai_millions, self._collateral_pool, self._token_supply)
|
tokens, realized_price = self.bonding_curve.deposit(dai, self._collateral_pool, self._token_supply)
|
||||||
self._token_supply += tokens
|
self._token_supply += tokens
|
||||||
self._collateral_pool += dai_millions
|
self._collateral_pool += dai
|
||||||
return tokens, realized_price
|
return tokens, realized_price
|
||||||
|
|
||||||
def burn(self, tokens_millions):
|
def burn(self, tokens):
|
||||||
"""
|
"""
|
||||||
Burn tokens, with/without an exit tribute.
|
Burn tokens, with/without an exit tribute.
|
||||||
"""
|
"""
|
||||||
dai_millions, realized_price = self.bonding_curve.burn(tokens_millions, self._collateral_pool, self._token_supply)
|
dai, realized_price = self.bonding_curve.burn(tokens, self._collateral_pool, self._token_supply)
|
||||||
self._token_supply -= tokens_millions
|
self._token_supply -= tokens
|
||||||
self._collateral_pool -= dai_millions
|
self._collateral_pool -= dai
|
||||||
money_returned = dai_millions
|
money_returned = dai
|
||||||
|
|
||||||
if self.exit_tribute:
|
if self.exit_tribute:
|
||||||
self._funding_pool += organization.exit_tribute * dai_millions
|
self._funding_pool += organization.exit_tribute * dai
|
||||||
money_returned = (1-organization.exit_tribute) * dai_millions
|
money_returned = (1-organization.exit_tribute) * dai
|
||||||
|
|
||||||
return money_returned, realized_price
|
return money_returned, realized_price
|
||||||
|
|
||||||
|
def token_price(self):
|
||||||
|
"""
|
||||||
|
Query the bonding curve for the current token price, given the size of the organization's collateral pool.
|
||||||
|
"""
|
||||||
|
return self.bonding_curve.get_token_price(self._collateral_pool)
|
||||||
|
|
@ -14,12 +14,16 @@ class TestHatch(unittest.TestCase):
|
||||||
class TestSystem(unittest.TestCase):
|
class TestSystem(unittest.TestCase):
|
||||||
def test_system(self):
|
def test_system(self):
|
||||||
# 3 contributors contribute equally to the foundation of an organization for 6 million tokens.
|
# 3 contributors contribute equally to the foundation of an organization for 6 million tokens.
|
||||||
token_supply_initial = 6e6 # TODO: millions
|
token_supply_initial = 6e6
|
||||||
hatcher_contributions = [3e3, 3e3, 3e3]
|
hatcher_contributions = [3e3, 3e3, 3e3]
|
||||||
token_batches = contributions_to_token_batches(hatcher_contributions, token_supply_initial, 90)
|
token_batches = contributions_to_token_batches(hatcher_contributions, token_supply_initial, 90)
|
||||||
|
|
||||||
o = Organization(sum(hatcher_contributions), 0.3, token_supply_initial)
|
o = Organization(sum(hatcher_contributions), token_supply_initial, funding_pool_fraction=0.3)
|
||||||
|
self.assertEqual(o._collateral_pool, 6300)
|
||||||
|
self.assertEqual(o._funding_pool, 2700)
|
||||||
|
self.assertEqual(o._token_supply, token_supply_initial)
|
||||||
|
|
||||||
print(o._funding_pool)
|
print(o.token_price())
|
||||||
print(o.deposit(5e5))
|
print(o.deposit(100))
|
||||||
print(o._funding_pool)
|
print(o.token_price())
|
||||||
|
print(o._collateral_pool)
|
||||||
Loading…
Reference in New Issue