Contract con_collider_007


Contract Code

1 import currency as tau
2 import con_collider_contract as lhc
3 import con_rocketswap_official_v1_1 as rswp
4
5 random.seed()
6
7 owner = Variable()
8 min_amount = Variable()
9 max_amount = Variable()
10 payout_factor = Variable()
11
12
13 @construct
14 def init():
15 owner.set(ctx.caller)
16 min_amount.set(15)
17 max_amount.set(150)
18 payout_factor.set(1.1)
19
20 @export
21 def collide(amount: float):
22 error = "Min amount is " + str(min_amount.get())
23 assert amount >= min_amount.get(), error
24
25 error = "Max amount is " + str(max_amount.get())
26 assert amount <= max_amount.get(), error
27
28 tau.transfer_from(
29 amount=amount,
30 to=ctx.this,
31 main_account=ctx.caller)
32
33 rswp_prices = ForeignHash(
34 foreign_contract='con_rocketswap_official_v1_1',
35 foreign_name='prices')
36
37 lhc_price = rswp_prices["con_collider_contract"]
38 lhc_amount = (amount / lhc_price) * payout_factor.get()
39
40 if random.choice([True, False]):
41 tau.transfer(
42 amount=amount,
43 to=ctx.caller)
44
45 lhc.transfer(
46 amount=lhc_amount,
47 to=ctx.caller)
48
49 return "You won " + str(amount) + " TAU and " + str(lhc_amount) + " LHC"
50
51 else:
52 tau.approve(
53 amount=amount,
54 to="con_rocketswap_official_v1_1")
55
56 rswp.buy(
57 contract="con_collider_contract",
58 currency_amount=amount,
59 minimum_received=lhc_amount * 0.51,
60 token_fees=False)
61
62 return "You lost " + str(amount) + " TAU"
63
64 @export
65 def deposit_tau(amount: float):
66 tau.transfer_from(
67 amount=amount,
68 to=ctx.this,
69 main_account=ctx.caller)
70
71 @export
72 def withdraw_tau(amount: float):
73 error = "Only the owner can withdraw TAU"
74 assert owner.get() == ctx.caller, error
75
76 tau.transfer(
77 amount=amount,
78 to=ctx.caller)
79
80 @export
81 def deposit_lhc(amount: float):
82 lhc.transfer_from(
83 amount=amount,
84 to=ctx.this,
85 main_account=ctx.caller)
86
87 @export
88 def withdraw_lhc(amount: float):
89 error = "Only the owner can withdraw LHC"
90 assert owner.get() == ctx.caller, error
91
92 lhc.transfer(
93 amount=amount,
94 to=ctx.caller)
95
96 @export
97 def set_min(amount: float):
98 error = "Only the owner can adjust MIN value"
99 assert owner.get() == ctx.caller, error
100
101 min_amount.set(amount)
102
103 @export
104 def set_max(amount: float):
105 error = "Only the owner can adjust MAX value"
106 assert owner.get() == ctx.caller, error
107
108 max_amount.set(amount)
109
110 @export
111 def set_payout_factor(factor: float):
112 error = "Only the owner can payout factor"
113 assert owner.get() == ctx.caller, error
114
115 payout_factor.set(factor)
116

Byte Code

e30000000000000000000000000400000040000000730c010000640064016c005a01640064016c025a03640064016c045a0565066a078300010065086402640364048d025a0965086402640564048d025a0a65086402640664048d025a0b65086402640764048d025a0c6408640984005a0d650e64028301650f640a9c01640b640c840483015a10650e64028301650f640a9c01640d640e840483015a11650e64028301650f640a9c01640f6410840483015a12650e64028301650f640a9c0164116412840483015a13650e64028301650f640a9c0164136414840483015a14650e64028301650f640a9c0164156416840483015a15650e64028301650f640a9c0164176418840483015a16650e64028301650f64199c01641a641b840483015a1764015300291ce9000000004eda10636f6e5f636f6c6c696465725f303037da056f776e65722902da08636f6e7472616374da046e616d65da0a6d696e5f616d6f756e74da0a6d61785f616d6f756e74da0d7061796f75745f666163746f72630000000000000000000000000300000043000000733200000074006a0174026a038301010074046a0164018301010074056a0164028301010074066a01740764038301830101006400530029044ee90f000000e9960000007a03312e312908da075f5f6f776e6572da03736574da03637478da0663616c6c6572da0c5f5f6d696e5f616d6f756e74da0c5f5f6d61785f616d6f756e74da0f5f5f7061796f75745f666163746f72da07646563696d616ca90072130000007213000000da00da045f5f5f5f0b000000730800000000010c010a010a0172150000002901da06616d6f756e74630100000000000000050000000600000043000000730a0100006401740074016a028300830117007d017c0074016a0283006b05732474037c01830182016402740074046a028300830117007d017c0074046a0283006b01734874037c018301820174056a067c0074076a0874076a0964038d030100740a640464056406640764088d047d027c02640919007d037c007c031b00740b6a02830014007d04740c6a0d640a640b6702830172ce74056a0e7c0074076a09640c8d020100740f6a0e7c0474076a09640c8d020100640d74007c0083011700640e170074007c0483011700640f1700530074056a107c006404640c8d02010074116a1264097c007c047413641083011400640b64118d040100641274007c00830117006413170053006400530029144e7a0e4d696e20616d6f756e74206973207a0e4d617820616d6f756e742069732029037216000000da02746fda0c6d61696e5f6163636f756e74da1c636f6e5f726f636b6574737761705f6f6666696369616c5f76315f31da067072696365737202000000da0b727377705f7072696365732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d6572040000007205000000da15636f6e5f636f6c6c696465725f636f6e747261637454462902721600000072170000007a08596f7520776f6e207a092054415520616e64207a04204c48437a04302e353129047204000000da0f63757272656e63795f616d6f756e74da106d696e696d756d5f7265636569766564da0a746f6b656e5f666565737a09596f75206c6f7374207a04205441552914da03737472720f000000da03676574da0e417373657274696f6e4572726f727210000000da03746175da0d7472616e736665725f66726f6d720d000000da0474686973720e000000da0b466f726569676e486173687211000000da0672616e646f6dda0663686f696365da087472616e73666572da036c6863da07617070726f7665da0472737770da03627579721200000029057216000000da056572726f72da0d5f5f727377705f707269636573da096c68635f7072696365da0a6c68635f616d6f756e74721300000072130000007214000000da07636f6c6c696465120000007324000000000210011401100114011401020104010a01080110010e01100110021c020e01080112017234000000630100000000000000010000000500000043000000731800000074006a017c0074026a0374026a0464018d0301006400530029024e2903721600000072170000007218000000290572250000007226000000720d0000007227000000720e00000029017216000000721300000072130000007214000000da0b6465706f7369745f7461752a000000730200000000027235000000630100000000000000020000000400000043000000732e00000064017d0174006a01830074026a036b02731a74047c018301820174056a067c0074026a0364028d0201006400530029034e7a1f4f6e6c7920746865206f776e65722063616e207769746864726177205441552902721600000072170000002907720b0000007223000000720d000000720e00000072240000007225000000722b000000290272160000007230000000721300000072130000007214000000da0c77697468647261775f7461752f00000073060000000002040116017236000000630100000000000000010000000500000043000000731800000074006a017c0074026a0374026a0464018d0301006400530029024e29037216000000721700000072180000002905722c0000007226000000720d0000007227000000720e00000029017216000000721300000072130000007214000000da0b6465706f7369745f6c686336000000730200000000027237000000630100000000000000020000000400000043000000732e00000064017d0174006a01830074026a036b02731a74047c018301820174056a067c0074026a0364028d0201006400530029034e7a1f4f6e6c7920746865206f776e65722063616e207769746864726177204c48432902721600000072170000002907720b0000007223000000720d000000720e0000007224000000722c000000722b000000290272160000007230000000721300000072130000007214000000da0c77697468647261775f6c68633b00000073060000000002040116017238000000630100000000000000020000000200000043000000732800000064017d0174006a01830074026a036b02731a74047c018301820174056a067c00830101006400530029024e7a234f6e6c7920746865206f776e65722063616e2061646a757374204d494e2076616c75652907720b0000007223000000720d000000720e0000007224000000720f000000720c000000290272160000007230000000721300000072130000007214000000da077365745f6d696e4200000073060000000002040116017239000000630100000000000000020000000200000043000000732800000064017d0174006a01830074026a036b02731a74047c018301820174056a067c00830101006400530029024e7a234f6e6c7920746865206f776e65722063616e2061646a757374204d41582076616c75652907720b0000007223000000720d000000720e00000072240000007210000000720c000000290272160000007230000000721300000072130000007214000000da077365745f6d6178490000007306000000000204011601723a0000002901da06666163746f72630100000000000000020000000200000043000000732800000064017d0174006a01830074026a036b02731a74047c018301820174056a067c00830101006400530029024e7a204f6e6c7920746865206f776e65722063616e207061796f757420666163746f722907720b0000007223000000720d000000720e00000072240000007211000000720c0000002902723b0000007230000000721300000072130000007214000000da117365745f7061796f75745f666163746f72500000007306000000000204011601723c0000002918da0863757272656e63797225000000721e000000722c0000007219000000722e0000007229000000da0473656564da085661726961626c65720b000000720f000000721000000072110000007215000000da085f5f6578706f7274da05666c6f6174723400000072350000007236000000723700000072380000007239000000723a000000723c0000007213000000721300000072130000007214000000da083c6d6f64756c653e01000000733000000008010801080108010c010c010c010c030807060110170601100406011006060110040601100606011006060110060601