tx · 4RqV2EvrxCMR2H4FZwXdBcv4SeXbCDBufPQq3q9jDVfK 3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL: -0.01000000 Waves 2022.04.26 04:19 [2024782] smart account 3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL > SELF 0.00000000 Waves
{ "type": 13, "id": "4RqV2EvrxCMR2H4FZwXdBcv4SeXbCDBufPQq3q9jDVfK", "fee": 1000000, "feeAssetId": null, "timestamp": 1650936026898, "version": 2, "chainId": 84, "sender": "3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL", "senderPublicKey": "FuM9F3sAdx6ZQfJfJMCdjC9w4wzTDx6F1KgWCbAM1KRy", "proofs": [ "3Dj15v369ZG9BNZJx3KjaBVTt9hsg9dMMgyEJ2fjsfKEzHmePKp5XDYhFoEejgWi8t7b1ozkeRXPV8KuufSUkhiW" ], "script": "base64:AAIFAAAAAAAAABkIAhIECgIBCBIECgIBCBIDCgEBEgQKAgEIAAAACgEAAAAFYXNJbnQAAAABAAAABXZhbHVlBAAAAAckbWF0Y2gwBQAAAAV2YWx1ZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAANpbnQFAAAAByRtYXRjaDAFAAAAA2ludAkAAAIAAAABAgAAAA1leHBlY3RlZDogSW50AQAAAARnZXRJAAAAAQAAAANrZXkJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AQAAAAh3cml0ZUludAAAAAIAAAADa2V5AAAABXZhbHVlAwkAAGYAAAACAAAAAAAAAAAABQAAAAV2YWx1ZQkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABd3cml0aW5nIG5lZ2F0aXZlIHZhbHVlIAkAAaQAAAABBQAAAAV2YWx1ZQIAAAAJIGZvciBrZXkgBQAAAANrZXkJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAANrZXkJAABkAAAAAgUAAAAFdmFsdWUADeC2s6dkAAAAAAAABG1haW4JAQAAAB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AAXYAAAAAAAAAAAAJAAACAAAAAQIAAAABMgkABRQAAAACCQAETAAAAAIJAQAAAAh3cml0ZUludAAAAAICAAAABU15QmFsCQAAZQAAAAIFAAAAAnVjBQAAAAF2BQAAAANuaWwJAQAAAAVhc0ludAAAAAEJAAP8AAAABAUAAAAEbWFpbgIAAAAId2l0aGRyYXcJAARMAAAAAgUAAAAPYXNzZXRTdHJpbmdVc2RjCQAETAAAAAIFAAAAAXYFAAAAA25pbAUAAAADbmlsAAAAAWkBAAAADWtpc3NtZWdvb2RieWUAAAACAAAABmxpbWl0ZAAAAANrZXkDCQEAAAACIT0AAAACCAUAAAABaQAAAAZjYWxsZXIFAAAABnNlbmRlcgkAAAIAAAABAgAAAAExBAAAAAlhdmFpbGFibGUJAAPwAAAAAgUAAAALcmVzZXJ2ZVVzZGMFAAAAB2Fzc2V0SWQDCQAAZgAAAAIFAAAABmxpbWl0ZAUAAAAJYXZhaWxhYmxlCQAAAgAAAAECAAAAATEEAAAABGZsYWcJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAQAAAARnZXRJAAAAAQUAAAADa2V5AAAAAAAAAAAAAwkAAAAAAAACBQAAAARmbGFnAAAAAAAAAAABCQAAAgAAAAECAAAAATIJAAUUAAAAAgkABEwAAAACCQEAAAAId3JpdGVJbnQAAAACBQAAAANrZXkAAAAAAAAAAAEFAAAAA25pbAkBAAAABWFzSW50AAAAAQkAA/wAAAAEBQAAAARtYWluAgAAAAh3aXRoZHJhdwkABEwAAAACBQAAAA9hc3NldFN0cmluZ1VzZGMJAARMAAAAAgUAAAAGbGltaXRkBQAAAANuaWwFAAAAA25pbAAAAAARNdE7", "height": 2024782, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4uY7uNg682mijftWrXTcGkFmEr7crcMbESXSNoywPLUY Next: none Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | ||
15 | 15 | func writeInt (key,value) = if ((0 > value)) | |
16 | 16 | then throw(((("writing negative value " + toString(value)) + " for key ") + key)) | |
17 | - | else IntegerEntry(key, value) | |
17 | + | else IntegerEntry(key, (value + 1000000000000000000)) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func asInt (value) = match value { | |
5 | 5 | case int: Int => | |
6 | 6 | int | |
7 | 7 | case _ => | |
8 | 8 | throw("expected: Int") | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func getI (key) = getInteger(this, key) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func writeInt (key,value) = if ((0 > value)) | |
16 | 16 | then throw(((("writing negative value " + toString(value)) + " for key ") + key)) | |
17 | - | else IntegerEntry(key, value) | |
17 | + | else IntegerEntry(key, (value + 1000000000000000000)) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT") | |
21 | 21 | ||
22 | 22 | let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" | |
23 | 23 | ||
24 | 24 | let assetStringBtc = addressFromStringValue("3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks") | |
25 | 25 | ||
26 | 26 | let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S") | |
27 | 27 | ||
28 | 28 | let assetId = fromBase58String(assetStringUsdc) | |
29 | 29 | ||
30 | 30 | let sender = addressFromStringValue("3PFSaPNBhUSsTmZwFF5DDbStDDJGrhcniS3") | |
31 | 31 | ||
32 | 32 | func withdraw3 (c,m) = asInt(invoke(assetStringBtc, (("valid" + c) + "imit"), [assetStringUsdc, toString(this), (0 - m)], nil)) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | @Callable(i) | |
36 | 36 | func initbal (bal,key) = $Tuple2([writeInt("MyBal", bal), writeInt(key, 0)], unit) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | ||
40 | 40 | @Callable(i) | |
41 | 41 | func withdraw (lowm,c) = if ((i.caller != sender)) | |
42 | 42 | then throw("1") | |
43 | 43 | else { | |
44 | 44 | let available = assetBalance(reserveUsdc, assetId) | |
45 | 45 | if ((lowm > available)) | |
46 | 46 | then throw("1") | |
47 | 47 | else { | |
48 | 48 | let uc = asInt(invoke(reserveUsdc, "userDepositUSD", [toString(this)], nil)) | |
49 | 49 | let v = if ((available > uc)) | |
50 | 50 | then uc | |
51 | 51 | else available | |
52 | 52 | if ((v == 0)) | |
53 | 53 | then throw("2") | |
54 | 54 | else { | |
55 | 55 | let b = withdraw3(c, (v - 1000000000)) | |
56 | 56 | $Tuple2(nil, (b + asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)))) | |
57 | 57 | } | |
58 | 58 | } | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | ||
63 | 63 | @Callable(i) | |
64 | 64 | func goodbye (lowm) = { | |
65 | 65 | let available = assetBalance(reserveUsdc, assetId) | |
66 | 66 | if ((lowm > available)) | |
67 | 67 | then throw("1") | |
68 | 68 | else { | |
69 | 69 | let uc = valueOrElse(getI("MyBal"), 0) | |
70 | 70 | let v = if ((available > uc)) | |
71 | 71 | then uc | |
72 | 72 | else available | |
73 | 73 | if ((v == 0)) | |
74 | 74 | then throw("2") | |
75 | 75 | else $Tuple2([writeInt("MyBal", (uc - v))], asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil))) | |
76 | 76 | } | |
77 | 77 | } | |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | 81 | @Callable(i) | |
82 | 82 | func kissmegoodbye (limitd,key) = if ((i.caller != sender)) | |
83 | 83 | then throw("1") | |
84 | 84 | else { | |
85 | 85 | let available = assetBalance(reserveUsdc, assetId) | |
86 | 86 | if ((limitd > available)) | |
87 | 87 | then throw("1") | |
88 | 88 | else { | |
89 | 89 | let flag = valueOrElse(getI(key), 0) | |
90 | 90 | if ((flag == 1)) | |
91 | 91 | then throw("2") | |
92 | 92 | else $Tuple2([writeInt(key, 1)], asInt(invoke(main, "withdraw", [assetStringUsdc, limitd], nil))) | |
93 | 93 | } | |
94 | 94 | } | |
95 | 95 | ||
96 | 96 |
github/deemru/w8io/026f985 25.49 ms ◑