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:AAIFAAAAAAAAAAwIAhIDCgEBEgMKAQEAAAAJAQAAAAVhc0ludAAAAAEAAAAFdmFsdWUEAAAAByRtYXRjaDAFAAAABXZhbHVlAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAA2ludAUAAAAHJG1hdGNoMAUAAAADaW50CQAAAgAAAAECAAAADWV4cGVjdGVkOiBJbnQBAAAABGdldEkAAAABAAAAA2tleQkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkBAAAACHdyaXRlSW50AAAAAgAAAANrZXkAAAAFdmFsdWUDCQAAZgAAAAIAAAAAAAAAAAAFAAAABXZhbHVlCQAAAgAAAAEJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAAF3dyaXRpbmcgbmVnYXRpdmUgdmFsdWUgCQABpAAAAAEFAAAABXZhbHVlAgAAAAkgZm9yIGtleSAFAAAAA2tleQkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAAA2tleQUAAAAFdmFsdWUBAAAACGNoYW5nZUJ5AAAAAgAAAANrZXkAAAAFdmFsdWUJAQAA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wkABEwAAAACBQAAAAF2BQAAAANuaWwFAAAAA25pbAAAAAFpAQAAAAdpbml0YmFsAAAAAQAAAANiYWwJAAUUAAAAAgkABEwAAAACCQEAAAAId3JpdGVJbnQAAAACAgAAAAVNeUJhbAUAAAADYmFsBQAAAANuaWwFAAAABHVuaXQAAAAApiICfA==",
"height": 2018426,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: CvdbTBtM3jcis9K8PD1fTBPuRz7B8xuYVRFkood7yWMj
Next: F8PMCQCXbycWrCXmVcwZ8SFFfBanUQC8JvwXg5XCN4aG
Diff:
Old | New | | Differences |
---|
9 | 9 | | } |
---|
10 | 10 | | |
---|
11 | 11 | | |
---|
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)) |
---|
18 | 21 | | |
---|
19 | 22 | | |
---|
20 | 23 | | let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT") |
---|
21 | 24 | | |
---|
22 | 25 | | let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" |
---|
23 | 26 | | |
---|
24 | | - | let reserveUsdc = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL") |
---|
| 27 | + | let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S") |
---|
25 | 28 | | |
---|
26 | 29 | | let assetId = fromBase58String(assetStringUsdc) |
---|
27 | 30 | | |
---|
28 | | - | @Callable(i) |
---|
29 | | - | func userBalance () = $Tuple2(nil, 900000000) |
---|
30 | | - | |
---|
31 | | - | |
---|
| 31 | + | let balkey = "MyBal" |
---|
32 | 32 | | |
---|
33 | 33 | | @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 | + | } |
---|
37 | 47 | | } |
---|
38 | 48 | | |
---|
39 | 49 | | |
---|
40 | 50 | | |
---|
41 | 51 | | @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) |
---|
51 | 53 | | |
---|
52 | 54 | | |
---|
Full:
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 | | - | 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)) |
---|
18 | 21 | | |
---|
19 | 22 | | |
---|
20 | 23 | | let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT") |
---|
21 | 24 | | |
---|
22 | 25 | | let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" |
---|
23 | 26 | | |
---|
24 | | - | let reserveUsdc = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL") |
---|
| 27 | + | let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S") |
---|
25 | 28 | | |
---|
26 | 29 | | let assetId = fromBase58String(assetStringUsdc) |
---|
27 | 30 | | |
---|
28 | | - | @Callable(i) |
---|
29 | | - | func userBalance () = $Tuple2(nil, 900000000) |
---|
30 | | - | |
---|
31 | | - | |
---|
| 31 | + | let balkey = "MyBal" |
---|
32 | 32 | | |
---|
33 | 33 | | @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 | + | } |
---|
37 | 47 | | } |
---|
38 | 48 | | |
---|
39 | 49 | | |
---|
40 | 50 | | |
---|
41 | 51 | | @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) |
---|
51 | 53 | | |
---|
52 | 54 | | |
---|