tx · 5PbM7v1xj6HCY2UmPNGd2RUVYyVN9Azhwp5qYkduappV

3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL:  -0.01000000 Waves

2022.04.21 17:50 [2018426] smart account 3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL > SELF 0.00000000 Waves

{ "type": 13, "id": "5PbM7v1xj6HCY2UmPNGd2RUVYyVN9Azhwp5qYkduappV", "fee": 1000000, "feeAssetId": null, "timestamp": 1650552631199, "version": 2, "chainId": 84, "sender": "3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL", "senderPublicKey": "FuM9F3sAdx6ZQfJfJMCdjC9w4wzTDx6F1KgWCbAM1KRy", "proofs": [ "2E1dGdiAbgvsAboYuiRJcqr8SYJiJ4wHwumEv5FzK2tmgUjciDL4SQTmAnkuqDiwhTSvbdXdZdZHdE5MQMHHgmk5" ], "script": "base64:AAIFAAAAAAAAAAwIAhIDCgEBEgMKAQEAAAAJAQAAAAVhc0ludAAAAAEAAAAFdmFsdWUEAAAAByRtYXRjaDAFAAAABXZhbHVlAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAA2ludAUAAAAHJG1hdGNoMAUAAAADaW50CQAAAgAAAAECAAAADWV4cGVjdGVkOiBJbnQBAAAABGdldEkAAAABAAAAA2tleQkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkBAAAACHdyaXRlSW50AAAAAgAAAANrZXkAAAAFdmFsdWUDCQAAZgAAAAIAAAAAAAAAAAAFAAAABXZhbHVlCQAAAgAAAAEJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAAF3dyaXRpbmcgbmVnYXRpdmUgdmFsdWUgCQABpAAAAAEFAAAABXZhbHVlAgAAAAkgZm9yIGtleSAFAAAAA2tleQkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAAA2tleQUAAAAFdmFsdWUBAAAACGNoYW5nZUJ5AAAAAgAAAANrZXkAAAAFdmFsdWUJAQAAAAh3cml0Z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BQAAAAF2BQAAAANuaWwFAAAAA25pbAAAAAFpAQAAAAdpbml0YmFsAAAAAQAAAANiYWwJAAUUAAAAAgkABEwAAAACCQEAAAAId3JpdGVJbnQAAAACAgAAAAVNeUJhbAUAAAADYmFsBQAAAANuaWwFAAAABHVuaXQAAAAApiICfA==", "height": 2018426, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CvdbTBtM3jcis9K8PD1fTBPuRz7B8xuYVRFkood7yWMj Next: F8PMCQCXbycWrCXmVcwZ8SFFfBanUQC8JvwXg5XCN4aG Diff:
OldNewDifferences
99 }
1010
1111
12-func asUserBalanceData (value) = match value {
13- case x: (Int, Int, Int, Int, Int, Boolean) =>
14- x._3
15- case t =>
16- throw("wrong type, expected: Int5&Boolean")
17-}
12+func getI (key) = getInteger(this, key)
13+
14+
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+func changeBy (key,value) = writeInt(key, (valueOrElse(getI(key), 0) + value))
1821
1922
2023 let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT")
2124
2225 let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ"
2326
24-let reserveUsdc = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL")
27+let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S")
2528
2629 let assetId = fromBase58String(assetStringUsdc)
2730
28-@Callable(i)
29-func userBalance () = $Tuple2(nil, 900000000)
30-
31-
31+let balkey = "MyBal"
3232
3333 @Callable(i)
34-func getB () = {
35- let a = asInt(invoke(reserveUsdc, "userBalance", nil, nil))
36- $Tuple2(nil, toString(a))
34+func byebye (lowm) = {
35+ let available = assetBalance(reserveUsdc, assetId)
36+ if ((lowm > available))
37+ then throw("1")
38+ else {
39+ let uc = asInt(invoke(reserveUsdc, "userDepositUSD", [toString(this)], nil))
40+ let v = if ((available > uc))
41+ then uc
42+ else available
43+ if ((lowm > v))
44+ then throw("2")
45+ else $Tuple2(nil, asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)))
46+ }
3747 }
3848
3949
4050
4151 @Callable(i)
42-func byebye (minm) = {
43- let available = assetBalance(reserveUsdc, assetId)
44- if ((minm > available))
45- then throw("2")
46- else {
47- let depositUsd = assetBalance(reserveUsdc, assetId)
48- throw("1")
49- }
50- }
52+func initbal (bal) = $Tuple2([writeInt("MyBal", bal)], unit)
5153
5254
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 func asInt (value) = match value {
55 case int: Int =>
66 int
77 case _ =>
88 throw("expected: Int")
99 }
1010
1111
12-func asUserBalanceData (value) = match value {
13- case x: (Int, Int, Int, Int, Int, Boolean) =>
14- x._3
15- case t =>
16- throw("wrong type, expected: Int5&Boolean")
17-}
12+func getI (key) = getInteger(this, key)
13+
14+
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+func changeBy (key,value) = writeInt(key, (valueOrElse(getI(key), 0) + value))
1821
1922
2023 let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT")
2124
2225 let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ"
2326
24-let reserveUsdc = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL")
27+let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S")
2528
2629 let assetId = fromBase58String(assetStringUsdc)
2730
28-@Callable(i)
29-func userBalance () = $Tuple2(nil, 900000000)
30-
31-
31+let balkey = "MyBal"
3232
3333 @Callable(i)
34-func getB () = {
35- let a = asInt(invoke(reserveUsdc, "userBalance", nil, nil))
36- $Tuple2(nil, toString(a))
34+func byebye (lowm) = {
35+ let available = assetBalance(reserveUsdc, assetId)
36+ if ((lowm > available))
37+ then throw("1")
38+ else {
39+ let uc = asInt(invoke(reserveUsdc, "userDepositUSD", [toString(this)], nil))
40+ let v = if ((available > uc))
41+ then uc
42+ else available
43+ if ((lowm > v))
44+ then throw("2")
45+ else $Tuple2(nil, asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)))
46+ }
3747 }
3848
3949
4050
4151 @Callable(i)
42-func byebye (minm) = {
43- let available = assetBalance(reserveUsdc, assetId)
44- if ((minm > available))
45- then throw("2")
46- else {
47- let depositUsd = assetBalance(reserveUsdc, assetId)
48- throw("1")
49- }
50- }
52+func initbal (bal) = $Tuple2([writeInt("MyBal", bal)], unit)
5153
5254

github/deemru/w8io/026f985 
32.16 ms