tx · 65i9ZrN5bhnN63h5N8mpSpGWNrhZeATdyxNkH1cRXBts 3NBbFNBed9tcU5AmsJAuExWvgJyNmJxqjWq: -0.01000000 Waves 2023.06.27 12:16 [2640870] smart account 3NBbFNBed9tcU5AmsJAuExWvgJyNmJxqjWq > SELF 0.00000000 Waves
{ "type": 13, "id": "65i9ZrN5bhnN63h5N8mpSpGWNrhZeATdyxNkH1cRXBts", "fee": 1000000, "feeAssetId": null, "timestamp": 1687857359365, "version": 2, "chainId": 84, "sender": "3NBbFNBed9tcU5AmsJAuExWvgJyNmJxqjWq", "senderPublicKey": "ERewvWFUFQfR1eCnipNAv9n7SdQhof2ESP6PGVjTueLd", "proofs": [ "9WSEriyuAqREpgAgDGxJRLHnGNVsNJHxg4sLCyb2mqGPeVAdsWhq4rWN9hXyjLn83qBwfNnWYGRspvMcXybzGBW" ], "script": "base64:BgIsCAISBAoCAQgSABIDCgEBEgMKAQESAwoBARIECgIIARIAEgQKAggBEgMKAQgGAANhcnIJAMwIAgABCQDMCAIAAgkAzAgCAAMJAMwIAgAECQDMCAIABQUDbmlsAARhcnIyCQDMCAIAAQkAzAgCAAIFA25pbAEDc3VtAgFhAWIJAPwHBAkBEUBleHRyTmF0aXZlKDEwNjIpAQIjM04zRG5WZmZuVXladHoyTVJiazVVN2dpTjExMldlbXBNTmQCBmJvcnJvdwkAzAgCAiwyNUZFcUVqUmtxSzZ5Q2tpVDdMejZTQVl6N2dVRkN0eGZDQ2huclZGRDVBVAkAzAgCAMCEPQUDbmlsBQNuaWwBD2dldEN1cnJlbnRQcmljZQEKYXNzZXRJZFN0cgMJAAACBQphc3NldElkU3RyAgVXQVZFUwACCQACAQIFRXJyb3IBCmdldEJhbGFuY2UCCmFzc2V0SWRTdHIHYWRkcmVzcwMJAAACBQphc3NldElkU3RyAgVXQVZFUwgJAO8HAQUHYWRkcmVzcwlhdmFpbGFibGUJAPAHAgUHYWRkcmVzcwkA2QQBBQphc3NldElkU3RyARl0cmFuc2Zlcldhd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JAPwHBAkBEUBleHRyTmF0aXZlKDEwNjIpAQIjM04zRG5WZmZuVXladHoyTVJiazVVN2dpTjExMldlbXBNTmQCCHdpdGhkcmF3CQDMCAIFCmFzc2V0SWRTdHIJAMwIAgULYXNzZXRBbW91bnQFA25pbAUDbmlsAwkAAAIFA3JlcwUDcmVzCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQCsAgIJAKwCAgUHYWRkcmVzcwIKX3dpdGhkcmV3XwUKYXNzZXRJZFN0cgULYXNzZXRBbW91bnQFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQxjaGVja0JhbGFuY2UBCmFzc2V0SWRTdHIEB2FkZHJlc3MIBQFpBmNhbGxlcgMJAAACBQphc3NldElkU3RyAgVXQVZFUwkAzAgCCQEMSW50ZWdlckVudHJ5AgINV2F2ZXMgQmFsYW5jZQgJAO8HAQUHYWRkcmVzcwlhdmFpbGFibGUFA25pbAkAzAgCCQEMSW50ZWdlckVudHJ5AgINQXNzZXQgQmFsYW5jZQkA8AcCBQdhZGRyZXNzCQDZBAEFCmFzc2V0SWRTdHIFA25pbAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXmuQ9N5", "height": 2640870, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3hDEba7ishGuVj11c4xbNxgYEJTZW3JcNHLHPLvniiV9 Next: VwToUbpMaF3Ja1Vg88oE5hU8wf8vkT93ZSqYonPGzWK Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | else assetBalance(address, fromBase58String(assetIdStr)) | |
19 | 19 | ||
20 | 20 | ||
21 | + | func transferWavesTestInternal (assetIdStr,assetAmount,address) = [IntegerEntry(((address + "_deposited_") + assetIdStr), assetAmount)] | |
22 | + | ||
23 | + | ||
21 | 24 | @Callable(i) | |
22 | 25 | func transferWaves (assetAmount,senderAddress) = if ((i.caller != this)) | |
23 | 26 | then throw("only for internal smart contract invocations") | |
26 | 29 | ||
27 | 30 | ||
28 | 31 | @Callable(i) | |
29 | - | func transferWavesTest (assetAmount) = [IntegerEntry((toString(i.caller) + "_deposited_WAVES"), assetAmount)] | |
32 | + | func transferWavesTest () = if (if ((size(i.payments) != 1)) | |
33 | + | then true | |
34 | + | else (i.payments[0].amount == 0)) | |
35 | + | then throw("1 payment has to be attached") | |
36 | + | else { | |
37 | + | let assetIdStr = "WAVES" | |
38 | + | let assetAmount = i.payments[0].amount | |
39 | + | transferWavesTestInternal(assetIdStr, assetAmount, toString(i.caller)) | |
40 | + | } | |
30 | 41 | ||
31 | 42 | ||
32 | 43 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let arr = [1, 2, 3, 4, 5] | |
5 | 5 | ||
6 | 6 | let arr2 = [1, 2] | |
7 | 7 | ||
8 | 8 | func sum (a,b) = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", 1000000], nil) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func getCurrentPrice (assetIdStr) = if ((assetIdStr == "WAVES")) | |
12 | 12 | then 2 | |
13 | 13 | else throw("Error") | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func getBalance (assetIdStr,address) = if ((assetIdStr == "WAVES")) | |
17 | 17 | then wavesBalance(address).available | |
18 | 18 | else assetBalance(address, fromBase58String(assetIdStr)) | |
19 | 19 | ||
20 | 20 | ||
21 | + | func transferWavesTestInternal (assetIdStr,assetAmount,address) = [IntegerEntry(((address + "_deposited_") + assetIdStr), assetAmount)] | |
22 | + | ||
23 | + | ||
21 | 24 | @Callable(i) | |
22 | 25 | func transferWaves (assetAmount,senderAddress) = if ((i.caller != this)) | |
23 | 26 | then throw("only for internal smart contract invocations") | |
24 | 27 | else [ScriptTransfer(this, assetAmount, unit), IntegerEntry((senderAddress + "_deposited_WAVES"), assetAmount)] | |
25 | 28 | ||
26 | 29 | ||
27 | 30 | ||
28 | 31 | @Callable(i) | |
29 | - | func transferWavesTest (assetAmount) = [IntegerEntry((toString(i.caller) + "_deposited_WAVES"), assetAmount)] | |
32 | + | func transferWavesTest () = if (if ((size(i.payments) != 1)) | |
33 | + | then true | |
34 | + | else (i.payments[0].amount == 0)) | |
35 | + | then throw("1 payment has to be attached") | |
36 | + | else { | |
37 | + | let assetIdStr = "WAVES" | |
38 | + | let assetAmount = i.payments[0].amount | |
39 | + | transferWavesTestInternal(assetIdStr, assetAmount, toString(i.caller)) | |
40 | + | } | |
30 | 41 | ||
31 | 42 | ||
32 | 43 | ||
33 | 44 | @Callable(i) | |
34 | 45 | func long2x (assetAmount) = { | |
35 | 46 | let address = toString(i.caller) | |
36 | 47 | let currentAmount = getBalance("WAVES", i.caller) | |
37 | 48 | if ((currentAmount > assetAmount)) | |
38 | 49 | then { | |
39 | 50 | func repeatFunc (accum,next) = { | |
40 | 51 | let transferResult = invoke(this, "transferWaves", [assetAmount, i.caller], nil) | |
41 | 52 | if ((transferResult == transferResult)) | |
42 | 53 | then { | |
43 | 54 | let supplyResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, assetAmount)]) | |
44 | 55 | if ((supplyResult == supplyResult)) | |
45 | 56 | then { | |
46 | 57 | let borrowResult = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", ((assetAmount * getCurrentPrice("WAVES")) / 100)], nil) | |
47 | 58 | if ((borrowResult == borrowResult)) | |
48 | 59 | then (accum + next) | |
49 | 60 | else throw("Strict value is not equal to itself.") | |
50 | 61 | } | |
51 | 62 | else throw("Strict value is not equal to itself.") | |
52 | 63 | } | |
53 | 64 | else throw("Strict value is not equal to itself.") | |
54 | 65 | } | |
55 | 66 | ||
56 | 67 | let array = [assetAmount, assetAmount] | |
57 | 68 | let res = { | |
58 | 69 | let $l = array | |
59 | 70 | let $s = size($l) | |
60 | 71 | let $acc0 = 0 | |
61 | 72 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
62 | 73 | then $a | |
63 | 74 | else repeatFunc($a, $l[$i]) | |
64 | 75 | ||
65 | 76 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
66 | 77 | then $a | |
67 | 78 | else throw("List size exceeds 2") | |
68 | 79 | ||
69 | 80 | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
70 | 81 | } | |
71 | 82 | [IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), (assetAmount * getCurrentPrice("WAVES"))), ScriptTransfer(i.caller, ((res * getCurrentPrice("WAVES")) / 100), base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'), ScriptTransfer(this, res, unit)] | |
72 | 83 | } | |
73 | 84 | else throw("Error!") | |
74 | 85 | } | |
75 | 86 | ||
76 | 87 | ||
77 | 88 | ||
78 | 89 | @Callable(i) | |
79 | 90 | func borrow (assetAmount) = { | |
80 | 91 | let address = toString(i.caller) | |
81 | 92 | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", assetAmount], nil) | |
82 | 93 | if ((res == res)) | |
83 | 94 | then [ScriptTransfer(i.caller, assetAmount, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'), IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), assetAmount)] | |
84 | 95 | else throw("Strict value is not equal to itself.") | |
85 | 96 | } | |
86 | 97 | ||
87 | 98 | ||
88 | 99 | ||
89 | 100 | @Callable(i) | |
90 | 101 | func borrow2 (assetAmount) = { | |
91 | 102 | let address = toString(i.caller) | |
92 | 103 | func repeatFunc (accum,next) = { | |
93 | 104 | let result = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "borrow", ["25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT", assetAmount], nil) | |
94 | 105 | if ((result == result)) | |
95 | 106 | then (accum + next) | |
96 | 107 | else throw("Strict value is not equal to itself.") | |
97 | 108 | } | |
98 | 109 | ||
99 | 110 | let array = [assetAmount, assetAmount] | |
100 | 111 | let res = { | |
101 | 112 | let $l = array | |
102 | 113 | let $s = size($l) | |
103 | 114 | let $acc0 = 0 | |
104 | 115 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
105 | 116 | then $a | |
106 | 117 | else repeatFunc($a, $l[$i]) | |
107 | 118 | ||
108 | 119 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
109 | 120 | then $a | |
110 | 121 | else throw("List size exceeds 2") | |
111 | 122 | ||
112 | 123 | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
113 | 124 | } | |
114 | 125 | [IntegerEntry(((address + "_borrowed_") + "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT"), assetAmount), ScriptTransfer(i.caller, res, base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT')] | |
115 | 126 | } | |
116 | 127 | ||
117 | 128 | ||
118 | 129 | ||
119 | 130 | @Callable(i) | |
120 | 131 | func borrow5 (assetIdStr,assetAmount) = { | |
121 | 132 | let address = toString(i.caller) | |
122 | 133 | let res = { | |
123 | 134 | let $l = arr | |
124 | 135 | let $s = size($l) | |
125 | 136 | let $acc0 = 0 | |
126 | 137 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
127 | 138 | then $a | |
128 | 139 | else sum($a, $l[$i]) | |
129 | 140 | ||
130 | 141 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
131 | 142 | then $a | |
132 | 143 | else throw("List size exceeds 5") | |
133 | 144 | ||
134 | 145 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
135 | 146 | } | |
136 | 147 | if ((res == res)) | |
137 | 148 | then [IntegerEntry(((address + "_borrowed_") + assetIdStr), assetAmount)] | |
138 | 149 | else throw("Strict value is not equal to itself.") | |
139 | 150 | } | |
140 | 151 | ||
141 | 152 | ||
142 | 153 | ||
143 | 154 | @Callable(i) | |
144 | 155 | func deposit () = { | |
145 | 156 | let address = toString(i.caller) | |
146 | 157 | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "supply", nil, [AttachedPayment(unit, 1000000)]) | |
147 | 158 | if ((res == res)) | |
148 | 159 | then [IntegerEntry((address + "supply_waves"), 1000000)] | |
149 | 160 | else throw("Strict value is not equal to itself.") | |
150 | 161 | } | |
151 | 162 | ||
152 | 163 | ||
153 | 164 | ||
154 | 165 | @Callable(i) | |
155 | 166 | func withdraw (assetIdStr,assetAmount) = { | |
156 | 167 | let address = toString(i.caller) | |
157 | 168 | let res = invoke(addressFromStringValue("3N3DnVffnUyZtz2MRbk5U7giN112WempMNd"), "withdraw", [assetIdStr, assetAmount], nil) | |
158 | 169 | if ((res == res)) | |
159 | 170 | then [IntegerEntry(((address + "_withdrew_") + assetIdStr), assetAmount)] | |
160 | 171 | else throw("Strict value is not equal to itself.") | |
161 | 172 | } | |
162 | 173 | ||
163 | 174 | ||
164 | 175 | ||
165 | 176 | @Callable(i) | |
166 | 177 | func checkBalance (assetIdStr) = { | |
167 | 178 | let address = i.caller | |
168 | 179 | if ((assetIdStr == "WAVES")) | |
169 | 180 | then [IntegerEntry("Waves Balance", wavesBalance(address).available)] | |
170 | 181 | else [IntegerEntry("Asset Balance", assetBalance(address, fromBase58String(assetIdStr)))] | |
171 | 182 | } | |
172 | 183 | ||
173 | 184 | ||
174 | 185 | @Verifier(tx) | |
175 | 186 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
176 | 187 |
github/deemru/w8io/169f3d6 42.08 ms ◑