tx · 3AP1zzRRsp6oxepcA8WxBBgrfiuKgLSWWTXm6ToGQeRZ
3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL: -0.01000000 Waves
2022.04.21 09:22 [2017935] smart account 3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL > SELF 0.00000000 Waves
{
"type": 13,
"id": "3AP1zzRRsp6oxepcA8WxBBgrfiuKgLSWWTXm6ToGQeRZ",
"fee": 1000000,
"feeAssetId": null,
"timestamp": 1650522193470,
"version": 2,
"chainId": 84,
"sender": "3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL",
"senderPublicKey": "FuM9F3sAdx6ZQfJfJMCdjC9w4wzTDx6F1KgWCbAM1KRy",
"proofs": [
"4hD8VQNKmCSKDhkAZbQMrxgahkc3sESfStu5WwoXKiw4sknkeKnv1Z2tNVBipxDi6dXccRMZ9dLVgeNh67iQhdEu"
],
"script": "base64:AAIFAAAAAAAAAAwIAhIDCgEIEgMKAQEAAAAGAQAAAAVhc0ludAAAAAEAAAAFdmFsdWUEAAAAByRtYXRjaDAFAAAABXZhbHVlAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAA2ludAUAAAAHJG1hdGNoMAUAAAADaW50CQAAAgAAAAECAAAADWV4cGVjdGVkOiBJbnQBAAAAEWFzVXNlckJhbGFuY2VEYXRhAAAAAQAAAAV2YWx1ZQQAAAAHJG1hdGNoMAUAAAAFdmFsdWUDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAIihJbnQsIEludCwgSW50LCBJbnQsIEludCwgQm9vbGVhbikEAAAAAXgFAAAAByRtYXRjaDAIBQAAAAF4AAAAAl8zBAAAAAF0BQAAAAckbWF0Y2gwCQAAAgAAAAECAAAAIndyb25nIHR5cGUsIGV4cGVjdGVkOiBJbnQ1JkJvb2xlYW4AAAAABG1haW4JAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAECAAAAIzNQQVp2OXRnSzFQWDdkS1I3YjRrY2hxNXFkcFVTM0c1c1lUAAAAAA9hc3NldFN0cmluZ1VzZGMCAAAALDZYdEhqcFhiczlSUkpQMlNyOUdVeVZxekFDY2J5OVRrVGhIWG5qVkM1Q0RKAAAAAAtyZXNlcnZlVXNkYwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQIAAAAjM01zUlFocDJjYlhKUXhIRVR6ZFpRZGoyUWZQNGIzTXA2VUwAAAAAB2Fzc2V0SWQJAAJZAAAAAQUAAAAPYXNzZXRTdHJpbmdVc2RjAAAAAgAAAAFpAQAAAAt1c2VyQmFsYW5jZQAAAAEAAAAEYWRkcgkABRQAAAACBQAAAANuaWwAAAAAADWk6QAAAAABaQEAAAAGYnllYnllAAAAAQAAAARtaW5tBAAAAAlhdmFpbGFibGUJAAPwAAAAAgUAAAAEbWFpbgUAAAAHYXNzZXRJZAMJAABmAAAAAgUAAAAEbWlubQUAAAAJYXZhaWxhYmxlCQAFFAAAAAIFAAAAA25pbAkAAaQAAAABBQAAAARtaW5tBAAAAApkZXBvc2l0VXNkCQEAAAAFYXNJbnQAAAABCQAD/AAAAAQFAAAAC3Jlc2VydmVVc2RjAgAAAAt1c2VyQmFsYW5jZQkABEwAAAACCQAEJQAAAAEFAAAABHRoaXMFAAAAA25pbAUAAAADbmlsBAAAAAF2AwkAAGYAAAACBQAAAApkZXBvc2l0VXNkBQAAAAlhdmFpbGFibGUFAAAACmRlcG9zaXRVc2QFAAAACWF2YWlsYWJsZQkABRQAAAACBQAAAANuaWwJAAGkAAAAAQUAAAABdgAAAAA5JiuZ",
"height": 2017935,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 2sSdTEDee55h4KAjazCZKfEbgSMGgMS5RUApuYztzmnE
Next: GiqnqJJKqraFiusjxdjnXLXpsppzVNEDP4JsAfpdDfbW
Diff:
Old | New | | Differences |
---|
32 | 32 | | |
---|
33 | 33 | | @Callable(i) |
---|
34 | 34 | | func byebye (minm) = { |
---|
35 | | - | let available = assetBalance(reserveUsdc, assetId) |
---|
| 35 | + | let available = assetBalance(main, assetId) |
---|
36 | 36 | | if ((minm > available)) |
---|
37 | | - | then throw(toString(available)) |
---|
| 37 | + | then $Tuple2(nil, toString(minm)) |
---|
38 | 38 | | else { |
---|
39 | 39 | | let depositUsd = asInt(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
40 | | - | let v = if ((available > depositUsd)) |
---|
| 40 | + | let v = if ((depositUsd > available)) |
---|
41 | 41 | | then depositUsd |
---|
42 | 42 | | else available |
---|
43 | | - | if ((v == 0)) |
---|
44 | | - | then throw(toString(v)) |
---|
45 | | - | else { |
---|
46 | | - | let amount = asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)) |
---|
47 | | - | $Tuple2(nil, amount) |
---|
48 | | - | } |
---|
| 43 | + | $Tuple2(nil, toString(v)) |
---|
49 | 44 | | } |
---|
50 | 45 | | } |
---|
51 | 46 | | |
---|
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 | 24 | | let reserveUsdc = addressFromStringValue("3MsRQhp2cbXJQxHETzdZQdj2QfP4b3Mp6UL") |
---|
25 | 25 | | |
---|
26 | 26 | | let assetId = fromBase58String(assetStringUsdc) |
---|
27 | 27 | | |
---|
28 | 28 | | @Callable(i) |
---|
29 | 29 | | func userBalance (addr) = $Tuple2(nil, 900000000) |
---|
30 | 30 | | |
---|
31 | 31 | | |
---|
32 | 32 | | |
---|
33 | 33 | | @Callable(i) |
---|
34 | 34 | | func byebye (minm) = { |
---|
35 | | - | let available = assetBalance(reserveUsdc, assetId) |
---|
| 35 | + | let available = assetBalance(main, assetId) |
---|
36 | 36 | | if ((minm > available)) |
---|
37 | | - | then throw(toString(available)) |
---|
| 37 | + | then $Tuple2(nil, toString(minm)) |
---|
38 | 38 | | else { |
---|
39 | 39 | | let depositUsd = asInt(invoke(reserveUsdc, "userBalance", [toString(this)], nil)) |
---|
40 | | - | let v = if ((available > depositUsd)) |
---|
| 40 | + | let v = if ((depositUsd > available)) |
---|
41 | 41 | | then depositUsd |
---|
42 | 42 | | else available |
---|
43 | | - | if ((v == 0)) |
---|
44 | | - | then throw(toString(v)) |
---|
45 | | - | else { |
---|
46 | | - | let amount = asInt(invoke(main, "withdraw", [assetStringUsdc, v], nil)) |
---|
47 | | - | $Tuple2(nil, amount) |
---|
48 | | - | } |
---|
| 43 | + | $Tuple2(nil, toString(v)) |
---|
49 | 44 | | } |
---|
50 | 45 | | } |
---|
51 | 46 | | |
---|
52 | 47 | | |
---|