tx · CHxxqpdozBKGNrorHNXLLJV7gsBvLum7LWeNSfeHdPmF 3MzwNdM8LQZEPXq3d4uXvxeZGpBwVQXs9RD: -0.00600000 Waves 2022.08.26 15:26 [2201447] smart account 3MzwNdM8LQZEPXq3d4uXvxeZGpBwVQXs9RD > SELF 0.00000000 Waves
{ "type": 13, "id": "CHxxqpdozBKGNrorHNXLLJV7gsBvLum7LWeNSfeHdPmF", "fee": 600000, "feeAssetId": null, "timestamp": 1661516814218, "version": 2, "chainId": 84, "sender": "3MzwNdM8LQZEPXq3d4uXvxeZGpBwVQXs9RD", "senderPublicKey": "G4H6mB4yX5B1YAf6cKk4TteRS3NbLVrZ2i45DJGqqwLV", "proofs": [ "22jfqqazFbqF3p9mykQfumpeRbjksGhcR3Z9Cq3QS8J3iwHKRq3idMge2SEJz64GZqfBg1RCdrKKLEQ7715VMs61" ], "script": "base64:BgIYCAISABIAEgMKAQESAwoBARIAEgASABIABgAEdXNkbgEg11KRGPRfT6VehNuJvBkobHB7OMalzc+gLp7N2ofv42AABHVzZGMBIPQcuTcYg4l4Uh6IaJaLWyiuNgmUbeQfgPZEel3eCXgMAAxhZG1pbl93YWxsZXQCIzNOM0RDbmdqaWRpdmtKYlRKd0ZURXZiWVJUZmZDV1ZCTENMAA5hbGZhcmtfdGVzdG5ldAAFAAp2aXJlc19kYXBwARoBVHjn3floRCovnhXY1SHCQGibEg7rsYrFrAENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAgBaQEPYnV5X3VzZG5fdGlja2V0AAMJAQIhPQIICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAUEdXNkbgkAAgECH1BsZWFzZSBkZXBvc2l0IFVTRC1OIHRva2VuIG9ubHkEC3VzZXJfY3JlZGl0CQENdHJ5R2V0SW50ZWdlcgEJAKwCAgkArAICAgV1c2RuXwkApQgBC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vb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXnGi7Rf", "height": 2201447, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4qsRq1eXL1Yyxdm6A2zEBPpQKuH6r4Fj5duxcGkZ5c9D Next: 4jJukCVwFuVQSdn7GHjdg6chkXogS7bvrgdndVuQgJRp Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let usdn = base58'FVXgJ86erBw5GAMeAw1CnYXwQn48BFAEAhRyHPUjbMQB' | |
5 | 5 | ||
6 | - | let usdC = base58'HRut8ESAGXxwvsKJky1V96qRtqyXQd4Apq4GY7TE5yGP' | |
6 | + | let usdc = base58'HRut8ESAGXxwvsKJky1V96qRtqyXQd4Apq4GY7TE5yGP' | |
7 | + | ||
8 | + | let admin_wallet = "3N3DCngjidivkJbTJwFTEvbYRTffCWVBLCL" | |
9 | + | ||
10 | + | let alfark_testnet = 5 | |
11 | + | ||
12 | + | let vires_dapp = base58'3MzwNdM8LQZEPXq3d4uXvxeZGpBwVQXs9RD' | |
13 | + | ||
14 | + | func tryGetInteger (key) = match getInteger(this, key) { | |
15 | + | case b: Int => | |
16 | + | b | |
17 | + | case _ => | |
18 | + | 0 | |
19 | + | } | |
20 | + | ||
7 | 21 | ||
8 | 22 | @Callable(i) | |
9 | - | func | |
10 | - | then throw(" | |
23 | + | func buy_usdn_ticket () = if ((i.payments[0].assetId != usdn)) | |
24 | + | then throw("Please deposit USD-N token only") | |
11 | 25 | else { | |
12 | - | let currentLiquidity = valueOrElse(getInteger(this, toString(i.originCaller)), 0) | |
13 | - | [IntegerEntry(toString(i.originCaller), (currentLiquidity + i.payments[0].amount))] | |
26 | + | let user_credit = tryGetInteger((("usdn_" + toString(i.originCaller)) + "_credit")) | |
27 | + | let deposit_amount = i.payments[0].amount | |
28 | + | let new_user_credit = (user_credit + deposit_amount) | |
29 | + | let all_credit = tryGetInteger("usdn_all_credit") | |
30 | + | let new_all_credit = (all_credit + deposit_amount) | |
31 | + | let transaction_block = match lastBlock.height { | |
32 | + | case a: Int => | |
33 | + | a | |
34 | + | case _ => | |
35 | + | throw("Error! with blochchain height") | |
36 | + | } | |
37 | + | let res = invoke(Address(vires_dapp), "usdN_stake", nil, [AttachedPayment(usdn, deposit_amount)]) | |
38 | + | if ((res == res)) | |
39 | + | then [IntegerEntry((("usdn_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdn_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdn_all_credit", new_all_credit), IntegerEntry("usdn_all_block", transaction_block)] | |
40 | + | else throw("Strict value is not equal to itself.") | |
14 | 41 | } | |
15 | 42 | ||
16 | 43 | ||
17 | 44 | ||
18 | 45 | @Callable(i) | |
19 | - | func usdN_cancelStake (amount) = if ((getIntegerValue(this, toString(i.caller)) >= amount)) | |
20 | - | then [ScriptTransfer(i.caller, amount, usdN)] | |
21 | - | else throw("too big amount") | |
22 | - | ||
23 | - | ||
24 | - | ||
25 | - | @Callable(i) | |
26 | - | func usdC_stake () = if ((i.payments[0].assetId != usdC)) | |
27 | - | then throw("unexpected asset") | |
46 | + | func buy_usdc_ticket () = if ((i.payments[0].assetId != usdc)) | |
47 | + | then throw("Please deposit USD-N token only") | |
28 | 48 | else { | |
29 | - | let currentLiquidity = valueOrElse(getInteger(this, toString(i.originCaller)), 0) | |
30 | - | [IntegerEntry(toString(i.originCaller), (currentLiquidity + i.payments[0].amount))] | |
49 | + | let user_credit = tryGetInteger((("usdc_" + toString(i.originCaller)) + "_credit")) | |
50 | + | let deposit_amount = i.payments[0].amount | |
51 | + | let new_user_credit = (user_credit + deposit_amount) | |
52 | + | let all_credit = tryGetInteger("usdc_all_credit") | |
53 | + | let new_all_credit = (all_credit + deposit_amount) | |
54 | + | let transaction_block = match lastBlock.height { | |
55 | + | case a: Int => | |
56 | + | a | |
57 | + | case _ => | |
58 | + | throw("Error block number") | |
59 | + | } | |
60 | + | let res = invoke(Address(vires_dapp), "usdC_stake", nil, [AttachedPayment(usdc, deposit_amount)]) | |
61 | + | if ((res == res)) | |
62 | + | then [IntegerEntry((("usdc_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdc_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdc_all_credit", new_all_credit), IntegerEntry("usdc_all_block", transaction_block)] | |
63 | + | else throw("Strict value is not equal to itself.") | |
31 | 64 | } | |
32 | 65 | ||
33 | 66 | ||
34 | 67 | ||
35 | 68 | @Callable(i) | |
36 | - | func usdC_cancelStake (amount) = if ((getIntegerValue(this, toString(i.caller)) >= amount)) | |
37 | - | then [ScriptTransfer(i.caller, amount, usdC)] | |
38 | - | else throw("too big amount") | |
69 | + | func sell_usdn_ticket (user_amount) = { | |
70 | + | let amount = match user_amount { | |
71 | + | case int: Int => | |
72 | + | int | |
73 | + | case _ => | |
74 | + | 0 | |
75 | + | } | |
76 | + | let user_credit = tryGetInteger((("usdn_" + toString(i.originCaller)) + "_credit")) | |
77 | + | if ((amount > user_credit)) | |
78 | + | then throw(("sorry you can't withdraw this amount, because u=you have only " + toString(user_credit))) | |
79 | + | else { | |
80 | + | let new_user_credit = (user_credit - amount) | |
81 | + | let all_credit = tryGetInteger("usdn_all_credit") | |
82 | + | let new_all_credit = (all_credit - amount) | |
83 | + | let transaction_block = match lastBlock.height { | |
84 | + | case a: Int => | |
85 | + | a | |
86 | + | case _ => | |
87 | + | throw("Error block number") | |
88 | + | } | |
89 | + | let res = invoke(Address(vires_dapp), "usdN_cancelStake", [amount], nil) | |
90 | + | if ((res == res)) | |
91 | + | then [IntegerEntry((("usdn_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdn_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdn_all_credit", new_all_credit), IntegerEntry("usdn_all_block", transaction_block)] | |
92 | + | else throw("Strict value is not equal to itself.") | |
93 | + | } | |
94 | + | } | |
39 | 95 | ||
96 | + | ||
97 | + | ||
98 | + | @Callable(i) | |
99 | + | func sell_usdc_ticket (amount) = { | |
100 | + | let user_credit = tryGetInteger((("usdc_" + toString(i.originCaller)) + "_credit")) | |
101 | + | if ((amount > user_credit)) | |
102 | + | then throw(("sorry you can't withdraw this amount, because u=you have only " + toString(user_credit))) | |
103 | + | else { | |
104 | + | let new_user_credit = (user_credit - amount) | |
105 | + | let all_credit = tryGetInteger("usdc_all_credit") | |
106 | + | let new_all_credit = (all_credit - amount) | |
107 | + | let transaction_block = match lastBlock.height { | |
108 | + | case a: Int => | |
109 | + | a | |
110 | + | case _ => | |
111 | + | throw("Error block number") | |
112 | + | } | |
113 | + | let res = invoke(Address(vires_dapp), "usdC_cancelStake", [amount], nil) | |
114 | + | if ((res == res)) | |
115 | + | then [IntegerEntry((("usdc_" + toString(i.originCaller)) + "_credit"), new_user_credit), IntegerEntry((("usdc_" + toString(i.originCaller)) + "_block"), transaction_block), IntegerEntry("usdc_all_credit", new_all_credit), IntegerEntry("usdc_all_block", transaction_block)] | |
116 | + | else throw("Strict value is not equal to itself.") | |
117 | + | } | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func usdn_calc_profit_amount () = if ((toString(i.originCaller) != admin_wallet)) | |
124 | + | then throw("Sorry! you are not allowed to use this funaction") | |
125 | + | else { | |
126 | + | let usdn_profit_last_block = tryGetInteger("usdn_profit_last_block") | |
127 | + | let usdn_profit_last_amount = tryGetInteger("usdn_profit_last_amount") | |
128 | + | let transaction_block = match lastBlock.height { | |
129 | + | case a: Int => | |
130 | + | a | |
131 | + | case _ => | |
132 | + | throw("Error block number") | |
133 | + | } | |
134 | + | let alfark = (transaction_block - usdn_profit_last_block) | |
135 | + | if ((alfark_testnet > alfark)) | |
136 | + | then throw((("Please try again after " + toString((alfark_testnet - alfark))) + " block")) | |
137 | + | else { | |
138 | + | let usdn_balance = assetBalance(this, usdn) | |
139 | + | [IntegerEntry("usdn_profit_last_block", transaction_block), IntegerEntry("usdn_profit_last_amount", usdn_balance)] | |
140 | + | } | |
141 | + | } | |
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | @Callable(i) | |
146 | + | func usdn_send_profit_amount () = { | |
147 | + | let usdn_profit_last_amount = tryGetInteger("usdn_profit_last_amount") | |
148 | + | if ((0 >= usdn_profit_last_amount)) | |
149 | + | then throw(("you dont have profit amount " + toString(usdn_profit_last_amount))) | |
150 | + | else { | |
151 | + | let transfer = ScriptTransfer(addressFromStringValue(admin_wallet), usdn_profit_last_amount, usdn) | |
152 | + | [transfer] | |
153 | + | } | |
154 | + | } | |
155 | + | ||
156 | + | ||
157 | + | ||
158 | + | @Callable(i) | |
159 | + | func usdc_calc_profit_amount () = if ((toString(i.originCaller) != admin_wallet)) | |
160 | + | then throw("Sorry! you are not allowed to use this funaction") | |
161 | + | else { | |
162 | + | let usdc_profit_last_block = tryGetInteger("usdc_profit_last_block") | |
163 | + | let usdc_profit_last_amount = tryGetInteger("usdc_profit_last_amount") | |
164 | + | let transaction_block = match lastBlock.height { | |
165 | + | case a: Int => | |
166 | + | a | |
167 | + | case _ => | |
168 | + | throw("Error block number") | |
169 | + | } | |
170 | + | let alfark = (transaction_block - usdc_profit_last_block) | |
171 | + | if ((alfark_testnet > alfark)) | |
172 | + | then throw((("Please try again after " + toString((alfark_testnet - alfark))) + " block")) | |
173 | + | else { | |
174 | + | let usdc_balance = assetBalance(this, usdc) | |
175 | + | [IntegerEntry("usdc_profit_last_block", transaction_block), IntegerEntry("usdc_profit_last_amount", usdc_balance)] | |
176 | + | } | |
177 | + | } | |
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | @Callable(i) | |
182 | + | func usdc_send_profit_amount () = { | |
183 | + | let usdc_profit_last_amount = tryGetInteger("usdc_profit_last_amount") | |
184 | + | if ((0 >= usdc_profit_last_amount)) | |
185 | + | then throw(("you dont have profit amount " + toString(usdc_profit_last_amount))) | |
186 | + | else { | |
187 | + | let transfer = ScriptTransfer(addressFromStringValue(admin_wallet), usdc_profit_last_amount, usdc) | |
188 | + | [transfer] | |
189 | + | } | |
190 | + | } | |
191 | + | ||
192 | + | ||
193 | + | @Verifier(tx) | |
194 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
40 | 195 |
github/deemru/w8io/026f985 49.09 ms ◑