Contract con_altswap_sale
Creator | ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89 |
Creation Hash | 2bbd819c528c9aa701ac460ca5c35cadc1dc63a045f1febea006e768b6860921 |
Created On | 667 days ago - 7/11/2022, 5:22:21 PM UTC+0 |
Contract Code
1
#con_altswap - Unique DEX featuring multi-token pools with weights
2
#con_altswap_lst001_1
3
#con_altswap_sale
4
5
import currency as tau
6
import con_altswap_lst001_1 as alp
7
8
9
tau_balances = ForeignHash(foreign_contract='currency', foreign_name='balances')
10
owner = Variable()
11
price = Variable()
12
quantity = Variable()
13
14
15
@construct
16
def seed():
17
price.set(2)
18
quantity.set(600_000)
19
owner.set(ctx.caller)
20
21
22
@export
23
def set_sale_price(sale_price: float):
24
error = "Only owner can update this"
25
assert ctx.caller == owner.get(), error
26
price.set(sale_price)
27
28
29
@export
30
def set_sale_quantity(sale_quantity: int):
31
error = "Only owner can update this"
32
assert ctx.caller == owner.get(), error
33
quantity.set(sale_quantity)
34
35
36
@export
37
def purchase(amount_tau: float):
38
assert amount_tau > 0, 'Cannot purchase negative amounts!'
39
purchaser = ctx.caller
40
assert tau_balances[purchaser] >= amount_tau, 'Not enough tau!'
41
amount = amount_tau / price.get()
42
assert quantity.get() > amount, 'Not enough remaining'
43
quantity.set(quantity.get() - amount)
44
tau.transfer_from(amount_tau, ctx.this, purchaser)
45
alp.transfer(amount, purchaser)
46
47
48
@export
49
def pay_out_alp(amount: float):
50
error = "Negative amount is not allowed"
51
assert amount > 0, error
52
error = "Only owner can payout tokens"
53
assert ctx.caller == owner.get(), error
54
# Transfer tokens from contract to owner
55
alp.transfer(
56
amount=amount,
57
to=ctx.caller)
58
59
60
@export
61
def pay_out_tau(amount: float):
62
error = "Negative amount is not allowed"
63
assert amount > 0, error
64
error = "Only owner can payout tokens"
65
assert ctx.caller == owner.get(), error
66
# Transfer tokens from contract to owner
67
tau.transfer(
68
amount=amount,
69
to=ctx.caller)
70
71
72
@export
73
def change_ownership(new_owner: str):
74
assert ctx.caller == owner.get(), 'Only the owner can change ownership!'
75
owner.set(new_owner)
Byte Code
e3000000000000000000000000060000004000000073d4000000640064016c005a01640064016c025a036504640264036404640564068d045a0565066404640764088d025a0765066404640964088d025a0865066404640a64088d025a09640b640c84005a0a650b64048301650c640d9c01640e640f840483015a0d650b64048301650e64109c0164116412840483015a0f650b64048301650c64139c0164146415840483015a10650b64048301650c64169c0164176418840483015a11650b64048301650c64169c016419641a840483015a12650b640483016513641b9c01641c641d840483015a1464015300291ee9000000004eda0863757272656e6379da0862616c616e636573da10636f6e5f616c74737761705f73616c65da0c7461755f62616c616e6365732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d65da08636f6e7472616374da046e616d65da056f776e6572290272080000007209000000da057072696365da087175616e74697479630000000000000000000000000200000043000000732400000074006a0164018301010074026a0164028301010074036a0174046a05830101006400530029034ee90200000069c02709002906da075f5f7072696365da03736574da0a5f5f7175616e74697479da075f5f6f776e6572da03637478da0663616c6c6572a90072140000007214000000da00da045f5f5f5f0a000000730600000000010a010a0172160000002901da0a73616c655f7072696365630100000000000000020000000200000043000000732800000064017d0174006a0174026a0383006b02731a74047c018301820174056a067c00830101006400530029024e7a1a4f6e6c79206f776e65722063616e2075706461746520746869732907721200000072130000007211000000da03676574da0e417373657274696f6e4572726f72720e000000720f00000029027217000000da056572726f72721400000072140000007215000000da0e7365745f73616c655f7072696365100000007306000000000204011601721b0000002901da0d73616c655f7175616e74697479630100000000000000020000000200000043000000732800000064017d0174006a0174026a0383006b02731a74047c018301820174056a067c00830101006400530029024e7a1a4f6e6c79206f776e65722063616e2075706461746520746869732907721200000072130000007211000000721800000072190000007210000000720f0000002902721c000000721a000000721400000072140000007215000000da117365745f73616c655f7175616e74697479170000007306000000000204011601721d0000002901da0a616d6f756e745f746175630100000000000000030000000400000043000000737c0000007c0064016b047310740064028301820174016a027d0174037c0119007c006b05732a74006403830182017c0074046a0583001b007d0274066a0583007c026b04734a740064048301820174066a0774066a0583007c0218008301010074086a097c0074016a0a7c0183030100740b6a0c7c027c01830201006400530029054e72010000007a2143616e6e6f74207075726368617365206e6567617469766520616d6f756e7473217a0f4e6f7420656e6f75676820746175217a144e6f7420656e6f7567682072656d61696e696e67290d721900000072120000007213000000da0e5f5f7461755f62616c616e636573720e00000072180000007210000000720f000000da03746175da0d7472616e736665725f66726f6dda0474686973da03616c70da087472616e736665722903721e000000da09707572636861736572da06616d6f756e74721400000072140000007215000000da0870757263686173651e000000731000000000021001060114010c01140112011001722700000029017226000000630100000000000000020000000400000043000000734200000064017d017c0064026b04731474007c018301820164037d0174016a0274036a0483006b02732e74007c018301820174056a067c0074016a0264048d0201006400530029054e7a1e4e6567617469766520616d6f756e74206973206e6f7420616c6c6f77656472010000007a1c4f6e6c79206f776e65722063616e207061796f757420746f6b656e7329027226000000da02746f2907721900000072120000007213000000721100000072180000007223000000722400000029027226000000721a000000721400000072140000007215000000da0b7061795f6f75745f616c702a000000730a000000000204011001040116017229000000630100000000000000020000000400000043000000734200000064017d017c0064026b04731474007c018301820164037d0174016a0274036a0483006b02732e74007c018301820174056a067c0074016a0264048d0201006400530029054e7a1e4e6567617469766520616d6f756e74206973206e6f7420616c6c6f77656472010000007a1c4f6e6c79206f776e65722063616e207061796f757420746f6b656e732902722600000072280000002907721900000072120000007213000000721100000072180000007220000000722400000029027226000000721a000000721400000072140000007215000000da0b7061795f6f75745f74617533000000730a00000000020401100104011601722a0000002901da096e65775f6f776e6572630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174026a057c00830101006400530029024e7a244f6e6c7920746865206f776e65722063616e206368616e6765206f776e65727368697021290672120000007213000000721100000072180000007219000000720f0000002901722b000000721400000072140000007215000000da106368616e67655f6f776e6572736869703c000000730400000000021601722c000000291572020000007220000000da14636f6e5f616c74737761705f6c73743030315f317223000000da0b466f726569676e48617368721f000000da085661726961626c657211000000720e00000072100000007216000000da085f5f6578706f7274da05666c6f6174721b000000da03696e74721d00000072270000007229000000722a000000da03737472722c0000007214000000721400000072140000007215000000da083c6d6f64756c653e0100000073260000000801080104010c010c010c010c03080606011006060110060601100b06011008060110080601