tx · 2sSdTEDee55h4KAjazCZKfEbgSMGgMS5RUApuYztzmnE
3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL: -0.01000000 Waves
2022.04.21 09:11 [2017923] smart account 3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL > SELF 0.00000000 Waves
{
"type": 13,
"id": "2sSdTEDee55h4KAjazCZKfEbgSMGgMS5RUApuYztzmnE",
"fee": 1000000,
"feeAssetId": null,
"timestamp": 1650521493825,
"version": 2,
"chainId": 84,
"sender": "3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL",
"senderPublicKey": "FuM9F3sAdx6ZQfJfJMCdjC9w4wzTDx6F1KgWCbAM1KRy",
"proofs": [
"xpT9Qo9e7BNdVBpBp3iJkMDrU7PSFKMBcfAManZb12eapU3xexfYM7sjjkFL8BHoU3aNADALsEBj1gB5Wh8dGzk"
],
"script": "base64:AAIFAAAAAAAAAAwIAhIDCgEIEgMKAQEAAAAGAQAAAAVhc0ludAAAAAEAAAAFdmFsdWUEAAAAByRtYXRjaDAFAAAABXZhbHVlAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAA2ludAUAAAAHJG1hdGNoMAUAAAADaW50CQAAAgAAAAECAAAADWV4cGVjdGVkOiBJbnQBAAAAEWFzVXNlckJhbGFuY2VEYXRhAAAAAQAAAAV2YWx1ZQQAAAAHJG1hdGNoMAUAAAAFdmFsdWUDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAIihJbnQsIEludCwgSW50LCBJbnQsIEludCwgQm9vbGVhbikEAAAAAXgFAAAAByRtYXRjaDAIBQAAAAF4AAAAAl8zBAAAAAF0BQAAAAckbWF0Y2gwCQAAAgAAAAECAAAAIndyb25nIHR5cGUsIGV4cGVjdGVkOiBJbnQ1JkJvb2xlYW4AAAAABG1haW4JAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAECAAAAIzNQQVp2OXRnSzFQWDdkS1I3YjRrY2hxNXFkcFV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spentComplexity": 0
}
View: original | compacted
Prev: 2zUQyavBZRUayyPqiDmKu91GoW8Mj9JLU21CxU1y8B5v
Next: 3AP1zzRRsp6oxepcA8WxBBgrfiuKgLSWWTXm6ToGQeRZ
Diff:
Old | New | | Differences |
---|
21 | 21 | | |
---|
22 | 22 | | let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" |
---|
23 | 23 | | |
---|
24 | | - | let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S") |
---|
| 24 | + | let reserveUsdc = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL") |
---|
25 | 25 | | |
---|
26 | 26 | | let assetId = fromBase58String(assetStringUsdc) |
---|
27 | 27 | | |
---|
28 | 28 | | @Callable(i) |
---|
29 | | - | func t1 (minm) = { |
---|
30 | | - | let available = assetBalance(reserveUsdc, assetId) |
---|
31 | | - | if ((minm > available)) |
---|
32 | | - | then { |
---|
33 | | - | let depositUsd = asUserBalanceData(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
34 | | - | throw("1") |
---|
35 | | - | } |
---|
36 | | - | else throw(toString(available)) |
---|
37 | | - | } |
---|
| 29 | + | func userBalance (addr) = $Tuple2(nil, 900000000) |
---|
38 | 30 | | |
---|
39 | 31 | | |
---|
40 | 32 | | |
---|
|
44 | 36 | | if ((minm > available)) |
---|
45 | 37 | | then throw(toString(available)) |
---|
46 | 38 | | else { |
---|
47 | | - | let depositUsd = asUserBalanceData(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
| 39 | + | let depositUsd = asInt(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
48 | 40 | | let v = if ((available > depositUsd)) |
---|
49 | 41 | | then depositUsd |
---|
50 | 42 | | else available |
---|
51 | | - | if ((minm > v)) |
---|
| 43 | + | if ((v == 0)) |
---|
52 | 44 | | then throw(toString(v)) |
---|
53 | 45 | | else { |
---|
54 | 46 | | let amount = asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)) |
---|
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 | 12 | | func asUserBalanceData (value) = match value { |
---|
13 | 13 | | case x: (Int, Int, Int, Int, Int, Boolean) => |
---|
14 | 14 | | x._3 |
---|
15 | 15 | | case t => |
---|
16 | 16 | | throw("wrong type, expected: Int5&Boolean") |
---|
17 | 17 | | } |
---|
18 | 18 | | |
---|
19 | 19 | | |
---|
20 | 20 | | let main = addressFromStringValue("3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT") |
---|
21 | 21 | | |
---|
22 | 22 | | let assetStringUsdc = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" |
---|
23 | 23 | | |
---|
24 | | - | let reserveUsdc = addressFromStringValue("3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S") |
---|
| 24 | + | let reserveUsdc = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL") |
---|
25 | 25 | | |
---|
26 | 26 | | let assetId = fromBase58String(assetStringUsdc) |
---|
27 | 27 | | |
---|
28 | 28 | | @Callable(i) |
---|
29 | | - | func t1 (minm) = { |
---|
30 | | - | let available = assetBalance(reserveUsdc, assetId) |
---|
31 | | - | if ((minm > available)) |
---|
32 | | - | then { |
---|
33 | | - | let depositUsd = asUserBalanceData(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
34 | | - | throw("1") |
---|
35 | | - | } |
---|
36 | | - | else throw(toString(available)) |
---|
37 | | - | } |
---|
| 29 | + | func userBalance (addr) = $Tuple2(nil, 900000000) |
---|
38 | 30 | | |
---|
39 | 31 | | |
---|
40 | 32 | | |
---|
41 | 33 | | @Callable(i) |
---|
42 | 34 | | func byebye (minm) = { |
---|
43 | 35 | | let available = assetBalance(reserveUsdc, assetId) |
---|
44 | 36 | | if ((minm > available)) |
---|
45 | 37 | | then throw(toString(available)) |
---|
46 | 38 | | else { |
---|
47 | | - | let depositUsd = asUserBalanceData(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
| 39 | + | let depositUsd = asInt(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
48 | 40 | | let v = if ((available > depositUsd)) |
---|
49 | 41 | | then depositUsd |
---|
50 | 42 | | else available |
---|
51 | | - | if ((minm > v)) |
---|
| 43 | + | if ((v == 0)) |
---|
52 | 44 | | then throw(toString(v)) |
---|
53 | 45 | | else { |
---|
54 | 46 | | let amount = asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)) |
---|
55 | 47 | | $Tuple2(nil, amount) |
---|
56 | 48 | | } |
---|
57 | 49 | | } |
---|
58 | 50 | | } |
---|
59 | 51 | | |
---|
60 | 52 | | |
---|