tx · 8mN8xo49f5YZm8McR2TryfYc1YTqqk1ZxnHh4JoWtDbL 3NBbFNBed9tcU5AmsJAuExWvgJyNmJxqjWq: -0.01000000 Waves 2023.08.09 21:18 [2703413] smart account 3NBbFNBed9tcU5AmsJAuExWvgJyNmJxqjWq > SELF 0.00000000 Waves
{ "type": 13, "id": "8mN8xo49f5YZm8McR2TryfYc1YTqqk1ZxnHh4JoWtDbL", "fee": 1000000, "feeAssetId": null, "timestamp": 1691605196233, "version": 2, "chainId": 84, "sender": "3NBbFNBed9tcU5AmsJAuExWvgJyNmJxqjWq", "senderPublicKey": "ERewvWFUFQfR1eCnipNAv9n7SdQhof2ESP6PGVjTueLd", "proofs": [ "4HvNSyATv5D9Jg4nnQcSiFaYgRYpyEXwuMR5v34QTTTUAQYpEqWU37YFuyEYu3KNBCpB4NKzDhnFeKUhYB6RxobW" ], "script": "base64:BgIPCAISABIAEgASABIDCgEIDgAJd2F2ZXMxTElkCQEHQWRkcmVzcwEBILH15FajP9PuifZAK5w8TIAJNqCYeFqn5MUfblsP6UaFAAl3YXZlczNMSWQJAQdBZGRyZXNzAQEgd1cMNeo2lN9O0xXcegEAmbtNEEfXDIqrV+HrcYvguGQACXdhdmVzNUxJZAkBB0FkZHJlc3MBASAbRmiSZTlYFNBubUQi5dTeIOXW7rvmiX4XxEsz9ehmpAADYXJyCQDMCAIAAQkAzAgCAAIJAMwIAgADCQDMCAIABAkAzAgCAAUFA25pbAAEYXJyMgkAzAgCAAEJAMwIAgACBQNuaWwABGFycjMJAMwIAgABCQDMCAIAAgkAzAgCAAMFA25pbAEDc3VtAgFhAWIJAPwHBAkBEUBleHRyTmF0aXZlKDEwNjIpAQIjM04zRG5WZmZuVXladHoyTVJiazVVN2dpTjExMldlbXBNTmQCBmJvcnJvdwkAzAgCAiwyNUZFcUVqUmtxSzZ5Q2tpVDdMejZTQVl6N2dVRkN0eGZDQ2huclZGRDVBVAkAzAgCAMCEPQUDbmlsBQNuaWwBCmdldEJhbGFuY2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Z2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V59ecFTQ==", "height": 2703413, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ACCGaSswRh9ZdZZbL7mnVtVFvtmKEJcrBzzQNQmwNFhy Next: 9kBJohuSW8s7Cw5zdDv2EC5qaatBJJ2ZLwRtMsu5Boti Diff:
Old | New | Differences | |
---|---|---|---|
29 | 29 | func getWavesCurrentPrice () = 2000000 | |
30 | 30 | ||
31 | 31 | ||
32 | + | func getWavesNewPrice () = 3000000 | |
33 | + | ||
34 | + | ||
32 | 35 | func getWaves1LCurrentPrice () = 1500000 | |
33 | 36 | ||
34 | 37 | ||
38 | 41 | func getWaves3LNewPrice () = 2000000 | |
39 | 42 | ||
40 | 43 | ||
41 | - | func transferWavesTestInternal (assetIdStr,assetAmount,address) = [IntegerEntry(((address + "_deposited_") + assetIdStr), assetAmount)] | |
42 | - | ||
43 | - | ||
44 | 44 | @Callable(i) | |
45 | - | func transferWaves (assetAmount,senderAddress) = if ((i.caller != this)) | |
46 | - | then throw("only for internal smart contract invocations") | |
47 | - | else [ScriptTransfer(this, assetAmount, unit), IntegerEntry((senderAddress + "_deposited_WAVES"), assetAmount)] | |
48 | - | ||
49 | - | ||
50 | - | ||
51 | - | @Callable(i) | |
52 | - | func issue3xLong () = [Issue("WAVES3L", "WAVES_USDN_LONG3X Token", 1000000000, 6, true)] | |
53 | - | ||
54 | - | ||
55 | - | ||
56 | - | @Callable(i) | |
57 | - | func transferWavesTest () = if (if ((size(i.payments) != 1)) | |
58 | - | then true | |
59 | - | else (i.payments[0].amount == 0)) | |
60 | - | then throw("1 payment has to be attached") | |
61 | - | else { | |
62 | - | let assetIdStr = "WAVES" | |
63 | - | let assetAmount = i.payments[0].amount | |
64 | - | transferWavesTestInternal(assetIdStr, assetAmount, toString(i.caller)) | |
65 | - | } | |
66 | - | ||
67 | - | ||
68 | - | ||
69 | - | @Callable(i) | |
70 | - | func mintWaves3L () = if (if ((size(i.payments) != 1)) | |
45 | + | func mintWaves3L_v1 () = if (if ((size(i.payments) != 1)) | |
71 | 46 | then true | |
72 | 47 | else (i.payments[0].amount == 0)) | |
73 | 48 | then throw("1 payment has to be attached") | |
114 | 89 | ||
115 | 90 | ||
116 | 91 | @Callable(i) | |
117 | - | func redeemWaves3L () = if (if ((size(i.payments) != 1)) | |
92 | + | func redeemWaves3L_v1 () = if (if ((size(i.payments) != 1)) | |
118 | 93 | then true | |
119 | 94 | else (i.payments[0].amount == 0)) | |
120 | 95 | then throw("1 payment has to be attached") | |
128 | 103 | ||
129 | 104 | ||
130 | 105 | @Callable(i) | |
131 | - | func mintWaves3L_ | |
106 | + | func mintWaves3L_v2 () = if (if ((size(i.payments) != 1)) | |
132 | 107 | then true | |
133 | 108 | else (i.payments[0].amount == 0)) | |
134 | 109 | then throw("1 payment has to be attached") | |
135 | 110 | else { | |
136 | 111 | let address = toString(i.caller) | |
137 | 112 | let stableCoinAmount = i.payments[0].amount | |
138 | - | [IntegerEntry((address + "_gave_USDN"), stableCoinAmount)] | |
139 | - | } | |
140 | - | ||
141 | - | ||
142 | - | ||
143 | - | @Callable(i) | |
144 | - | func long3x_v2 () = if (if ((size(i.payments) != 1)) | |
145 | - | then true | |
146 | - | else (i.payments[0].amount == 0)) | |
147 | - | then throw("1 payment has to be attached") | |
148 | - | else { | |
149 | - | let address = toString(i.caller) | |
150 | - | let assetIdStr = "WAVES" | |
151 | - | let wavesAmount = i.payments[0].amount | |
152 | - | let currentWavesAmount = getBalance(assetIdStr, i.caller) | |
153 | - | if ((currentWavesAmount > wavesAmount)) | |
113 | + | let convertedWavesAmount = ((stableCoinAmount / 2000000) * 100000000) | |
114 | + | let userWavesAmount = getBalance("WAVES", i.caller) | |
115 | + | let bedingung = ((3 - 1) * getWavesCurrentPrice()) | |
116 | + | if ((stableCoinAmount >= bedingung)) | |
154 | 117 | then { | |
155 | - | let depositResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, | |
118 | + | let depositResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, convertedWavesAmount)]) | |
156 | 119 | if ((depositResult == depositResult)) | |
157 | 120 | then { | |
158 | 121 | func repeatFunc (accum,next) = { | |
159 | - | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", | |
122 | + | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", stableCoinAmount], nil) | |
160 | 123 | if ((borrowResult == borrowResult)) | |
161 | 124 | then (accum + next) | |
162 | 125 | else throw("Strict value is not equal to itself.") | |
163 | 126 | } | |
164 | 127 | ||
165 | - | let array = [ | |
128 | + | let array = [stableCoinAmount, stableCoinAmount, stableCoinAmount] | |
166 | 129 | let res = { | |
167 | 130 | let $l = array | |
168 | 131 | let $s = size($l) | |
177 | 140 | ||
178 | 141 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
179 | 142 | } | |
180 | - | [IntegerEntry((address + "_deposited_WAVES"), wavesAmount), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), (wavesAmount * getCurrentPrice("WAVES"))), ScriptTransfer(i.caller, ((res * getCurrentPrice("WAVES")) / 100), base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
143 | + | let byWavesKaufen = ((res / getWavesCurrentPrice()) * 100000000) | |
144 | + | [IntegerEntry((address + "_gave_USDN"), stableCoinAmount), IntegerEntry((address + "_deposited_WAVES"), convertedWavesAmount), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), res), IntegerEntry((address + "_received_WAVES3L"), 1000000), ScriptTransfer(i.caller, 1000000, base58'92rW5ucGkH84YeXLnLs8dMN1P7RAFocmR8zfBqUy4gPM')] | |
181 | 145 | } | |
182 | 146 | else throw("Strict value is not equal to itself.") | |
183 | 147 | } | |
187 | 151 | ||
188 | 152 | ||
189 | 153 | @Callable(i) | |
190 | - | func long2x (assetAmount) = { | |
191 | - | let address = toString(i.caller) | |
192 | - | let currentAmount = getBalance("WAVES", i.caller) | |
193 | - | if ((currentAmount > assetAmount)) | |
194 | - | then { | |
195 | - | func repeatFunc (accum,next) = { | |
196 | - | let transferResult = invoke(this, "transferWaves", [assetAmount, i.caller], nil) | |
197 | - | if ((transferResult == transferResult)) | |
198 | - | then { | |
199 | - | let supplyResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, assetAmount)]) | |
200 | - | if ((supplyResult == supplyResult)) | |
201 | - | then { | |
202 | - | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", ((assetAmount * getCurrentPrice("WAVES")) / 100)], nil) | |
203 | - | if ((borrowResult == borrowResult)) | |
204 | - | then (accum + next) | |
205 | - | else throw("Strict value is not equal to itself.") | |
206 | - | } | |
207 | - | else throw("Strict value is not equal to itself.") | |
208 | - | } | |
209 | - | else throw("Strict value is not equal to itself.") | |
210 | - | } | |
211 | - | ||
212 | - | let array = [assetAmount, assetAmount] | |
213 | - | let res = { | |
214 | - | let $l = array | |
215 | - | let $s = size($l) | |
216 | - | let $acc0 = 0 | |
217 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
218 | - | then $a | |
219 | - | else repeatFunc($a, $l[$i]) | |
220 | - | ||
221 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
222 | - | then $a | |
223 | - | else throw("List size exceeds 2") | |
224 | - | ||
225 | - | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
226 | - | } | |
227 | - | [IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), (assetAmount * getCurrentPrice("WAVES"))), ScriptTransfer(i.caller, ((res * getCurrentPrice("WAVES")) / 100), base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'), ScriptTransfer(this, res, unit)] | |
228 | - | } | |
229 | - | else throw("Error!") | |
230 | - | } | |
231 | - | ||
232 | - | ||
233 | - | ||
234 | - | @Callable(i) | |
235 | - | func borrow (assetAmount) = { | |
236 | - | let address = toString(i.caller) | |
237 | - | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", assetAmount], nil) | |
238 | - | if ((res == res)) | |
239 | - | then [ScriptTransfer(i.caller, assetAmount, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), assetAmount)] | |
240 | - | else throw("Strict value is not equal to itself.") | |
241 | - | } | |
242 | - | ||
243 | - | ||
244 | - | ||
245 | - | @Callable(i) | |
246 | - | func borrow2 (assetAmount) = { | |
247 | - | let address = toString(i.caller) | |
248 | - | func repeatFunc (accum,next) = { | |
249 | - | let result = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", assetAmount], nil) | |
250 | - | if ((result == result)) | |
251 | - | then (accum + next) | |
252 | - | else throw("Strict value is not equal to itself.") | |
154 | + | func redeemWaves3L_v2 () = if (if ((size(i.payments) != 1)) | |
155 | + | then true | |
156 | + | else (i.payments[0].amount == 0)) | |
157 | + | then throw("1 payment has to be attached") | |
158 | + | else { | |
159 | + | let address = toString(i.caller) | |
160 | + | let tokenAmount = 6 | |
161 | + | let returnedUSDNAmount = (((tokenAmount * (getWavesNewPrice() / 1000000)) - 4) * 1000000) | |
162 | + | [IntegerEntry((address + "_redeemed_WAVES3L"), tokenAmount), IntegerEntry((address + "_received_USDN"), returnedUSDNAmount), ScriptTransfer(i.caller, returnedUSDNAmount, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
253 | 163 | } | |
254 | - | ||
255 | - | let array = [assetAmount, assetAmount] | |
256 | - | let res = { | |
257 | - | let $l = array | |
258 | - | let $s = size($l) | |
259 | - | let $acc0 = 0 | |
260 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
261 | - | then $a | |
262 | - | else repeatFunc($a, $l[$i]) | |
263 | - | ||
264 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
265 | - | then $a | |
266 | - | else throw("List size exceeds 2") | |
267 | - | ||
268 | - | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
269 | - | } | |
270 | - | [IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), assetAmount), ScriptTransfer(i.caller, res, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
271 | - | } | |
272 | - | ||
273 | - | ||
274 | - | ||
275 | - | @Callable(i) | |
276 | - | func borrow5 (assetIdStr,assetAmount) = { | |
277 | - | let address = toString(i.caller) | |
278 | - | let res = { | |
279 | - | let $l = arr | |
280 | - | let $s = size($l) | |
281 | - | let $acc0 = 0 | |
282 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
283 | - | then $a | |
284 | - | else sum($a, $l[$i]) | |
285 | - | ||
286 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
287 | - | then $a | |
288 | - | else throw("List size exceeds 5") | |
289 | - | ||
290 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
291 | - | } | |
292 | - | if ((res == res)) | |
293 | - | then [IntegerEntry(((address + "_borrowed_") + assetIdStr), assetAmount)] | |
294 | - | else throw("Strict value is not equal to itself.") | |
295 | - | } | |
296 | - | ||
297 | - | ||
298 | - | ||
299 | - | @Callable(i) | |
300 | - | func deposit () = { | |
301 | - | let address = toString(i.caller) | |
302 | - | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, 1000000)]) | |
303 | - | if ((res == res)) | |
304 | - | then [IntegerEntry((address + "supply_waves"), 1000000)] | |
305 | - | else throw("Strict value is not equal to itself.") | |
306 | - | } | |
307 | - | ||
308 | - | ||
309 | - | ||
310 | - | @Callable(i) | |
311 | - | func withdraw (assetIdStr,assetAmount) = { | |
312 | - | let address = toString(i.caller) | |
313 | - | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "withdraw", [assetIdStr, assetAmount], nil) | |
314 | - | if ((res == res)) | |
315 | - | then [IntegerEntry(((address + "_withdrew_") + assetIdStr), assetAmount)] | |
316 | - | else throw("Strict value is not equal to itself.") | |
317 | - | } | |
318 | 164 | ||
319 | 165 | ||
320 | 166 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let waves1LId = Address(base58'CygdaJKZfxRrHyYMwkNdz9ZgSD5FpJLtk5s5B4q1DKV6') | |
5 | 5 | ||
6 | 6 | let waves3LId = Address(base58'92rW5ucGkH84YeXLnLs8dMN1P7RAFocmR8zfBqUy4gPM') | |
7 | 7 | ||
8 | 8 | let waves5LId = Address(base58'2qUH6Nh6cgC8dxj8fwH3bTJi261PNr5nMQKRbBXBuwmM') | |
9 | 9 | ||
10 | 10 | let arr = [1, 2, 3, 4, 5] | |
11 | 11 | ||
12 | 12 | let arr2 = [1, 2] | |
13 | 13 | ||
14 | 14 | let arr3 = [1, 2, 3] | |
15 | 15 | ||
16 | 16 | func sum (a,b) = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", 1000000], nil) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func getBalance (assetIdStr,address) = if ((assetIdStr == "WAVES")) | |
20 | 20 | then wavesBalance(address).available | |
21 | 21 | else assetBalance(address, fromBase58String(assetIdStr)) | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getCurrentPrice (assetIdStr) = if ((assetIdStr == "WAVES")) | |
25 | 25 | then 2 | |
26 | 26 | else throw("Error") | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func getWavesCurrentPrice () = 2000000 | |
30 | 30 | ||
31 | 31 | ||
32 | + | func getWavesNewPrice () = 3000000 | |
33 | + | ||
34 | + | ||
32 | 35 | func getWaves1LCurrentPrice () = 1500000 | |
33 | 36 | ||
34 | 37 | ||
35 | 38 | func getWaves3LCurrentPrice () = 1200000 | |
36 | 39 | ||
37 | 40 | ||
38 | 41 | func getWaves3LNewPrice () = 2000000 | |
39 | 42 | ||
40 | 43 | ||
41 | - | func transferWavesTestInternal (assetIdStr,assetAmount,address) = [IntegerEntry(((address + "_deposited_") + assetIdStr), assetAmount)] | |
42 | - | ||
43 | - | ||
44 | 44 | @Callable(i) | |
45 | - | func transferWaves (assetAmount,senderAddress) = if ((i.caller != this)) | |
46 | - | then throw("only for internal smart contract invocations") | |
47 | - | else [ScriptTransfer(this, assetAmount, unit), IntegerEntry((senderAddress + "_deposited_WAVES"), assetAmount)] | |
48 | - | ||
49 | - | ||
50 | - | ||
51 | - | @Callable(i) | |
52 | - | func issue3xLong () = [Issue("WAVES3L", "WAVES_USDN_LONG3X Token", 1000000000, 6, true)] | |
53 | - | ||
54 | - | ||
55 | - | ||
56 | - | @Callable(i) | |
57 | - | func transferWavesTest () = if (if ((size(i.payments) != 1)) | |
58 | - | then true | |
59 | - | else (i.payments[0].amount == 0)) | |
60 | - | then throw("1 payment has to be attached") | |
61 | - | else { | |
62 | - | let assetIdStr = "WAVES" | |
63 | - | let assetAmount = i.payments[0].amount | |
64 | - | transferWavesTestInternal(assetIdStr, assetAmount, toString(i.caller)) | |
65 | - | } | |
66 | - | ||
67 | - | ||
68 | - | ||
69 | - | @Callable(i) | |
70 | - | func mintWaves3L () = if (if ((size(i.payments) != 1)) | |
45 | + | func mintWaves3L_v1 () = if (if ((size(i.payments) != 1)) | |
71 | 46 | then true | |
72 | 47 | else (i.payments[0].amount == 0)) | |
73 | 48 | then throw("1 payment has to be attached") | |
74 | 49 | else { | |
75 | 50 | let address = toString(i.caller) | |
76 | 51 | let stableCoinAmount = i.payments[0].amount | |
77 | 52 | let convertedWavesAmount = ((stableCoinAmount / getWavesCurrentPrice()) * 100000000) | |
78 | 53 | let userWavesAmount = getBalance("WAVES", i.caller) | |
79 | 54 | if ((userWavesAmount > convertedWavesAmount)) | |
80 | 55 | then { | |
81 | 56 | let depositResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, convertedWavesAmount)]) | |
82 | 57 | if ((depositResult == depositResult)) | |
83 | 58 | then { | |
84 | 59 | func repeatFunc (accum,next) = { | |
85 | 60 | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", stableCoinAmount], nil) | |
86 | 61 | if ((borrowResult == borrowResult)) | |
87 | 62 | then (accum + next) | |
88 | 63 | else throw("Strict value is not equal to itself.") | |
89 | 64 | } | |
90 | 65 | ||
91 | 66 | let array = [stableCoinAmount, stableCoinAmount, stableCoinAmount] | |
92 | 67 | let res = { | |
93 | 68 | let $l = array | |
94 | 69 | let $s = size($l) | |
95 | 70 | let $acc0 = 0 | |
96 | 71 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
97 | 72 | then $a | |
98 | 73 | else repeatFunc($a, $l[$i]) | |
99 | 74 | ||
100 | 75 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
101 | 76 | then $a | |
102 | 77 | else throw("List size exceeds 3") | |
103 | 78 | ||
104 | 79 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
105 | 80 | } | |
106 | 81 | let returnedTokenAmount = ((res / getWaves3LCurrentPrice()) * 1000000) | |
107 | 82 | [IntegerEntry((address + "_gave_USDN"), stableCoinAmount), IntegerEntry((address + "_deposited_WAVES"), convertedWavesAmount), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), res), IntegerEntry((address + "_received_WAVES3L"), returnedTokenAmount), ScriptTransfer(i.caller, returnedTokenAmount, base58'92rW5ucGkH84YeXLnLs8dMN1P7RAFocmR8zfBqUy4gPM')] | |
108 | 83 | } | |
109 | 84 | else throw("Strict value is not equal to itself.") | |
110 | 85 | } | |
111 | 86 | else throw("Not enough WAVES to deposit!") | |
112 | 87 | } | |
113 | 88 | ||
114 | 89 | ||
115 | 90 | ||
116 | 91 | @Callable(i) | |
117 | - | func redeemWaves3L () = if (if ((size(i.payments) != 1)) | |
92 | + | func redeemWaves3L_v1 () = if (if ((size(i.payments) != 1)) | |
118 | 93 | then true | |
119 | 94 | else (i.payments[0].amount == 0)) | |
120 | 95 | then throw("1 payment has to be attached") | |
121 | 96 | else { | |
122 | 97 | let address = toString(i.caller) | |
123 | 98 | let tokenAmount = i.payments[0].amount | |
124 | 99 | let returnedUSDNAmount = (tokenAmount * (getWaves3LNewPrice() / 1000000)) | |
125 | 100 | [IntegerEntry((address + "_redeemed_WAVES3L"), tokenAmount), IntegerEntry((address + "_received_USDN"), returnedUSDNAmount), ScriptTransfer(i.caller, returnedUSDNAmount, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
126 | 101 | } | |
127 | 102 | ||
128 | 103 | ||
129 | 104 | ||
130 | 105 | @Callable(i) | |
131 | - | func mintWaves3L_ | |
106 | + | func mintWaves3L_v2 () = if (if ((size(i.payments) != 1)) | |
132 | 107 | then true | |
133 | 108 | else (i.payments[0].amount == 0)) | |
134 | 109 | then throw("1 payment has to be attached") | |
135 | 110 | else { | |
136 | 111 | let address = toString(i.caller) | |
137 | 112 | let stableCoinAmount = i.payments[0].amount | |
138 | - | [IntegerEntry((address + "_gave_USDN"), stableCoinAmount)] | |
139 | - | } | |
140 | - | ||
141 | - | ||
142 | - | ||
143 | - | @Callable(i) | |
144 | - | func long3x_v2 () = if (if ((size(i.payments) != 1)) | |
145 | - | then true | |
146 | - | else (i.payments[0].amount == 0)) | |
147 | - | then throw("1 payment has to be attached") | |
148 | - | else { | |
149 | - | let address = toString(i.caller) | |
150 | - | let assetIdStr = "WAVES" | |
151 | - | let wavesAmount = i.payments[0].amount | |
152 | - | let currentWavesAmount = getBalance(assetIdStr, i.caller) | |
153 | - | if ((currentWavesAmount > wavesAmount)) | |
113 | + | let convertedWavesAmount = ((stableCoinAmount / 2000000) * 100000000) | |
114 | + | let userWavesAmount = getBalance("WAVES", i.caller) | |
115 | + | let bedingung = ((3 - 1) * getWavesCurrentPrice()) | |
116 | + | if ((stableCoinAmount >= bedingung)) | |
154 | 117 | then { | |
155 | - | let depositResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, | |
118 | + | let depositResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, convertedWavesAmount)]) | |
156 | 119 | if ((depositResult == depositResult)) | |
157 | 120 | then { | |
158 | 121 | func repeatFunc (accum,next) = { | |
159 | - | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", | |
122 | + | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", stableCoinAmount], nil) | |
160 | 123 | if ((borrowResult == borrowResult)) | |
161 | 124 | then (accum + next) | |
162 | 125 | else throw("Strict value is not equal to itself.") | |
163 | 126 | } | |
164 | 127 | ||
165 | - | let array = [ | |
128 | + | let array = [stableCoinAmount, stableCoinAmount, stableCoinAmount] | |
166 | 129 | let res = { | |
167 | 130 | let $l = array | |
168 | 131 | let $s = size($l) | |
169 | 132 | let $acc0 = 0 | |
170 | 133 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
171 | 134 | then $a | |
172 | 135 | else repeatFunc($a, $l[$i]) | |
173 | 136 | ||
174 | 137 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
175 | 138 | then $a | |
176 | 139 | else throw("List size exceeds 3") | |
177 | 140 | ||
178 | 141 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
179 | 142 | } | |
180 | - | [IntegerEntry((address + "_deposited_WAVES"), wavesAmount), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), (wavesAmount * getCurrentPrice("WAVES"))), ScriptTransfer(i.caller, ((res * getCurrentPrice("WAVES")) / 100), base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
143 | + | let byWavesKaufen = ((res / getWavesCurrentPrice()) * 100000000) | |
144 | + | [IntegerEntry((address + "_gave_USDN"), stableCoinAmount), IntegerEntry((address + "_deposited_WAVES"), convertedWavesAmount), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), res), IntegerEntry((address + "_received_WAVES3L"), 1000000), ScriptTransfer(i.caller, 1000000, base58'92rW5ucGkH84YeXLnLs8dMN1P7RAFocmR8zfBqUy4gPM')] | |
181 | 145 | } | |
182 | 146 | else throw("Strict value is not equal to itself.") | |
183 | 147 | } | |
184 | 148 | else throw("Not enough WAVES to deposit!") | |
185 | 149 | } | |
186 | 150 | ||
187 | 151 | ||
188 | 152 | ||
189 | 153 | @Callable(i) | |
190 | - | func long2x (assetAmount) = { | |
191 | - | let address = toString(i.caller) | |
192 | - | let currentAmount = getBalance("WAVES", i.caller) | |
193 | - | if ((currentAmount > assetAmount)) | |
194 | - | then { | |
195 | - | func repeatFunc (accum,next) = { | |
196 | - | let transferResult = invoke(this, "transferWaves", [assetAmount, i.caller], nil) | |
197 | - | if ((transferResult == transferResult)) | |
198 | - | then { | |
199 | - | let supplyResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, assetAmount)]) | |
200 | - | if ((supplyResult == supplyResult)) | |
201 | - | then { | |
202 | - | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", ((assetAmount * getCurrentPrice("WAVES")) / 100)], nil) | |
203 | - | if ((borrowResult == borrowResult)) | |
204 | - | then (accum + next) | |
205 | - | else throw("Strict value is not equal to itself.") | |
206 | - | } | |
207 | - | else throw("Strict value is not equal to itself.") | |
208 | - | } | |
209 | - | else throw("Strict value is not equal to itself.") | |
210 | - | } | |
211 | - | ||
212 | - | let array = [assetAmount, assetAmount] | |
213 | - | let res = { | |
214 | - | let $l = array | |
215 | - | let $s = size($l) | |
216 | - | let $acc0 = 0 | |
217 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
218 | - | then $a | |
219 | - | else repeatFunc($a, $l[$i]) | |
220 | - | ||
221 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
222 | - | then $a | |
223 | - | else throw("List size exceeds 2") | |
224 | - | ||
225 | - | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
226 | - | } | |
227 | - | [IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), (assetAmount * getCurrentPrice("WAVES"))), ScriptTransfer(i.caller, ((res * getCurrentPrice("WAVES")) / 100), base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'), ScriptTransfer(this, res, unit)] | |
228 | - | } | |
229 | - | else throw("Error!") | |
230 | - | } | |
231 | - | ||
232 | - | ||
233 | - | ||
234 | - | @Callable(i) | |
235 | - | func borrow (assetAmount) = { | |
236 | - | let address = toString(i.caller) | |
237 | - | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", assetAmount], nil) | |
238 | - | if ((res == res)) | |
239 | - | then [ScriptTransfer(i.caller, assetAmount, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), assetAmount)] | |
240 | - | else throw("Strict value is not equal to itself.") | |
241 | - | } | |
242 | - | ||
243 | - | ||
244 | - | ||
245 | - | @Callable(i) | |
246 | - | func borrow2 (assetAmount) = { | |
247 | - | let address = toString(i.caller) | |
248 | - | func repeatFunc (accum,next) = { | |
249 | - | let result = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", assetAmount], nil) | |
250 | - | if ((result == result)) | |
251 | - | then (accum + next) | |
252 | - | else throw("Strict value is not equal to itself.") | |
154 | + | func redeemWaves3L_v2 () = if (if ((size(i.payments) != 1)) | |
155 | + | then true | |
156 | + | else (i.payments[0].amount == 0)) | |
157 | + | then throw("1 payment has to be attached") | |
158 | + | else { | |
159 | + | let address = toString(i.caller) | |
160 | + | let tokenAmount = 6 | |
161 | + | let returnedUSDNAmount = (((tokenAmount * (getWavesNewPrice() / 1000000)) - 4) * 1000000) | |
162 | + | [IntegerEntry((address + "_redeemed_WAVES3L"), tokenAmount), IntegerEntry((address + "_received_USDN"), returnedUSDNAmount), ScriptTransfer(i.caller, returnedUSDNAmount, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
253 | 163 | } | |
254 | - | ||
255 | - | let array = [assetAmount, assetAmount] | |
256 | - | let res = { | |
257 | - | let $l = array | |
258 | - | let $s = size($l) | |
259 | - | let $acc0 = 0 | |
260 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
261 | - | then $a | |
262 | - | else repeatFunc($a, $l[$i]) | |
263 | - | ||
264 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
265 | - | then $a | |
266 | - | else throw("List size exceeds 2") | |
267 | - | ||
268 | - | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
269 | - | } | |
270 | - | [IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), assetAmount), ScriptTransfer(i.caller, res, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
271 | - | } | |
272 | - | ||
273 | - | ||
274 | - | ||
275 | - | @Callable(i) | |
276 | - | func borrow5 (assetIdStr,assetAmount) = { | |
277 | - | let address = toString(i.caller) | |
278 | - | let res = { | |
279 | - | let $l = arr | |
280 | - | let $s = size($l) | |
281 | - | let $acc0 = 0 | |
282 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
283 | - | then $a | |
284 | - | else sum($a, $l[$i]) | |
285 | - | ||
286 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
287 | - | then $a | |
288 | - | else throw("List size exceeds 5") | |
289 | - | ||
290 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
291 | - | } | |
292 | - | if ((res == res)) | |
293 | - | then [IntegerEntry(((address + "_borrowed_") + assetIdStr), assetAmount)] | |
294 | - | else throw("Strict value is not equal to itself.") | |
295 | - | } | |
296 | - | ||
297 | - | ||
298 | - | ||
299 | - | @Callable(i) | |
300 | - | func deposit () = { | |
301 | - | let address = toString(i.caller) | |
302 | - | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, 1000000)]) | |
303 | - | if ((res == res)) | |
304 | - | then [IntegerEntry((address + "supply_waves"), 1000000)] | |
305 | - | else throw("Strict value is not equal to itself.") | |
306 | - | } | |
307 | - | ||
308 | - | ||
309 | - | ||
310 | - | @Callable(i) | |
311 | - | func withdraw (assetIdStr,assetAmount) = { | |
312 | - | let address = toString(i.caller) | |
313 | - | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "withdraw", [assetIdStr, assetAmount], nil) | |
314 | - | if ((res == res)) | |
315 | - | then [IntegerEntry(((address + "_withdrew_") + assetIdStr), assetAmount)] | |
316 | - | else throw("Strict value is not equal to itself.") | |
317 | - | } | |
318 | 164 | ||
319 | 165 | ||
320 | 166 | ||
321 | 167 | @Callable(i) | |
322 | 168 | func checkBalance (assetIdStr) = { | |
323 | 169 | let address = i.caller | |
324 | 170 | if ((assetIdStr == "WAVES")) | |
325 | 171 | then [IntegerEntry("Waves Balance", wavesBalance(address).available)] | |
326 | 172 | else [IntegerEntry("Asset Balance", assetBalance(address, fromBase58String(assetIdStr)))] | |
327 | 173 | } | |
328 | 174 | ||
329 | 175 | ||
330 | 176 | @Verifier(tx) | |
331 | 177 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
332 | 178 |
github/deemru/w8io/169f3d6 55.12 ms ◑![]()