tx · GDCV9izPX1v5AkRUCBmMpYN7L1mW6qmAMhFJ7eNA5pSp 3NCCpaecUeQcHCJGnv1ZocqT3xAz2wiXFwe: -0.05000000 Waves 2022.05.11 12:17 [2046808] smart account 3NCCpaecUeQcHCJGnv1ZocqT3xAz2wiXFwe > SELF 0.00000000 Waves
{ "type": 13, "id": "GDCV9izPX1v5AkRUCBmMpYN7L1mW6qmAMhFJ7eNA5pSp", "fee": 5000000, "feeAssetId": null, "timestamp": 1652260734371, "version": 2, "chainId": 84, "sender": "3NCCpaecUeQcHCJGnv1ZocqT3xAz2wiXFwe", "senderPublicKey": "FX5ZmtqMuiefGRPoKkAcBUEDvaHBS4FSzt8VW49mzcjM", "proofs": [ "2Upf3B9A7muQvLUaFyWYyCMMBKT3Qbm6XSQgCzjvKksorhr3aL1dpAr4m2nYA9xJEu36jtu17YY472sEYsfm7Ksx" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAAAwAAAAACSUQBAAAAIP8QR3aaHO4gAEH6GV3RAr44yVLBwb023LSVkrkR45liAAAAAAJMUAEAAAAgf1BDCThONgyo3aXVGaZPHbvUVh7DJtZBDkYdxqjt6R0AAAAACWlzU3RvcHBlZAcAAAABAAAAAWkBAAAABXN0YWtlAAAAAAQAAAADcG10CQEAAAAFdmFsdWUAAAABCQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAABAAAAAlwbXRBbW91bnQIBQAAAANwbXQAAAAGYW1vdW50BAAAAAlrZXlTdGFrZWQCAAAACVNUQUtFRF9MUAMJAQAAAAIhPQAAAAIIBQAAAANwbXQAAAAHYXNzZXRJZAUAAAACSUQJAAACAAAAAQIAAAAbYXR0YWNoIHRlc3ROU0JUIHRva2VucyBvbmx5AwUAAAAJaXNTdG9wcGVkCQAAAgAAAAECAAAAGXNtYXJ0IGNvbnRyYWN0IGlzIG9uIGxvY2sEAAAACmluVHJlYXN1cnkJAAPwAAAAAgUAAAAEdGhpcwUAAAACSUQEAAAAC3RvdGFsSXNzdWVkBAAAAAckbWF0Y2gwCQAD7AAAAAEFAAAAAkxQAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAVBc3NldAQAAAAFYXNzZXQFAAAAByRtYXRjaDAIBQAAAAVhc3NldAAAAAhxdWFudGl0eQkAAAIAAAABAgAAABBDYW4ndCBmaW5kIGFzc2V0BAAAAAh0cmVhc3VyeQkAAGUAAAACBQAAAAppblRyZWFzdXJ5BQAAAAlwbXRBbW91bnQEAAAAD3NpbmdsZUxQaW5WYWx1ZQkAAGsAAAADBQAAAAt0b3RhbElzc3VlZAAAAAAABfXhAAUAAAAIdHJlYXN1cnkEAAAADWFtb3VudFRvSXNzdWUJAABrAAAAAwUAAAAJcG10QW1vdW50BQAAAA9zaW5nbGVMUGluVmFsdWUAAAAAAAX14QAEAAAAB0xQSXNzdWUJAQAAAAdSZWlzc3VlAAAAAwUAAAACTFAFAAAADWFtb3VudFRvSXNzdWUGBAAAAAh0cmFuc2ZlcgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA1hbW91bnRUb0lzc3VlBQAAAAJMUAQAAAAGc3Rha2VkCQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIFAAAABHRoaXMFAAAACWtleVN0YWtlZAAAAAAAAAAAAAQAAAALdXBkYXRlU3RhdGUJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAlrZXlTdGFrZWQJAABkAAAAAgUAAAAGc3Rha2VkCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAZhbW91bnQJAARMAAAAAgUAAAAHTFBJc3N1ZQkABEwAAAACBQAAAAh0cmFuc2ZlcgkABEwAAAACBQAAAAt1cGRhdGVTdGF0ZQUAAAADbmlsAAAAAN8Tomg=", "height": 2046808, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5fSgVcVzPT8PRVdxvmTKrjQWMwAT39wBLKU1w1aMeXGr Next: GHMshr3656d58JDiHN3buqoj8i2b6HwbyCJTkP8akYFe Diff:
Old | New | Differences | |
---|---|---|---|
11 | 11 | func stake () = { | |
12 | 12 | let e = value(d.payments[0]) | |
13 | 13 | let f = e.amount | |
14 | + | let g = "STAKED_LP" | |
14 | 15 | if ((e.assetId != a)) | |
15 | 16 | then throw("attach testNSBT tokens only") | |
16 | 17 | else if (c) | |
17 | 18 | then throw("smart contract is on lock") | |
18 | 19 | else { | |
19 | - | let | |
20 | - | let | |
21 | - | let | |
22 | - | if ($isInstanceOf( | |
20 | + | let h = assetBalance(this, a) | |
21 | + | let i = { | |
22 | + | let j = assetInfo(b) | |
23 | + | if ($isInstanceOf(j, "Asset")) | |
23 | 24 | then { | |
24 | - | let | |
25 | - | | |
25 | + | let k = j | |
26 | + | k.quantity | |
26 | 27 | } | |
27 | 28 | else throw("Can't find asset") | |
28 | 29 | } | |
29 | - | let k = ((h * 100000000) / g) | |
30 | - | let l = ((f * k) / 100000000) | |
31 | - | let m = Reissue(b, l, true) | |
32 | - | let n = ScriptTransfer(d.caller, l, b) | |
33 | - | [m, n] | |
30 | + | let l = (h - f) | |
31 | + | let m = fraction(i, 100000000, l) | |
32 | + | let n = fraction(f, m, 100000000) | |
33 | + | let o = Reissue(b, n, true) | |
34 | + | let p = ScriptTransfer(d.caller, n, b) | |
35 | + | let q = valueOrElse(getInteger(this, g), 0) | |
36 | + | let r = IntegerEntry(g, (q + d.payments[0].amount)) | |
37 | + | [o, p, r] | |
34 | 38 | } | |
35 | 39 | } | |
36 | 40 | ||
37 | - | ||
38 | - | ||
39 | - | @Callable(d) | |
40 | - | func withdraw (o) = { | |
41 | - | let p = d.payments[0] | |
42 | - | let q = d.payments[0].assetId | |
43 | - | if ((q != b)) | |
44 | - | then throw("Attach the correct LP token") | |
45 | - | else { | |
46 | - | let r = (p.amount - o) | |
47 | - | if ((0 > o)) | |
48 | - | then throw("Can't withdraw negative amount") | |
49 | - | else if ((0 > r)) | |
50 | - | then throw("Not enough balance") | |
51 | - | else { | |
52 | - | let s = Burn(b, o) | |
53 | - | let n = ScriptTransfer(d.caller, r, a) | |
54 | - | [s, n] | |
55 | - | } | |
56 | - | } | |
57 | - | } | |
58 | - | ||
59 | - | ||
60 | - | @Verifier(t) | |
61 | - | func u () = sigVerify(t.bodyBytes, t.proofs[0], t.senderPublicKey) | |
62 | 41 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = base58'JAfMu2seKNzTVfqi5w5Pjh4kwwPTZPCEFpc2q2vDyFeh' | |
5 | 5 | ||
6 | 6 | let b = base58'9ZymB4TJF6oQ3HwYgYFKizAf6m64sQF896mUzcsDJ4Wx' | |
7 | 7 | ||
8 | 8 | let c = false | |
9 | 9 | ||
10 | 10 | @Callable(d) | |
11 | 11 | func stake () = { | |
12 | 12 | let e = value(d.payments[0]) | |
13 | 13 | let f = e.amount | |
14 | + | let g = "STAKED_LP" | |
14 | 15 | if ((e.assetId != a)) | |
15 | 16 | then throw("attach testNSBT tokens only") | |
16 | 17 | else if (c) | |
17 | 18 | then throw("smart contract is on lock") | |
18 | 19 | else { | |
19 | - | let | |
20 | - | let | |
21 | - | let | |
22 | - | if ($isInstanceOf( | |
20 | + | let h = assetBalance(this, a) | |
21 | + | let i = { | |
22 | + | let j = assetInfo(b) | |
23 | + | if ($isInstanceOf(j, "Asset")) | |
23 | 24 | then { | |
24 | - | let | |
25 | - | | |
25 | + | let k = j | |
26 | + | k.quantity | |
26 | 27 | } | |
27 | 28 | else throw("Can't find asset") | |
28 | 29 | } | |
29 | - | let k = ((h * 100000000) / g) | |
30 | - | let l = ((f * k) / 100000000) | |
31 | - | let m = Reissue(b, l, true) | |
32 | - | let n = ScriptTransfer(d.caller, l, b) | |
33 | - | [m, n] | |
30 | + | let l = (h - f) | |
31 | + | let m = fraction(i, 100000000, l) | |
32 | + | let n = fraction(f, m, 100000000) | |
33 | + | let o = Reissue(b, n, true) | |
34 | + | let p = ScriptTransfer(d.caller, n, b) | |
35 | + | let q = valueOrElse(getInteger(this, g), 0) | |
36 | + | let r = IntegerEntry(g, (q + d.payments[0].amount)) | |
37 | + | [o, p, r] | |
34 | 38 | } | |
35 | 39 | } | |
36 | 40 | ||
37 | - | ||
38 | - | ||
39 | - | @Callable(d) | |
40 | - | func withdraw (o) = { | |
41 | - | let p = d.payments[0] | |
42 | - | let q = d.payments[0].assetId | |
43 | - | if ((q != b)) | |
44 | - | then throw("Attach the correct LP token") | |
45 | - | else { | |
46 | - | let r = (p.amount - o) | |
47 | - | if ((0 > o)) | |
48 | - | then throw("Can't withdraw negative amount") | |
49 | - | else if ((0 > r)) | |
50 | - | then throw("Not enough balance") | |
51 | - | else { | |
52 | - | let s = Burn(b, o) | |
53 | - | let n = ScriptTransfer(d.caller, r, a) | |
54 | - | [s, n] | |
55 | - | } | |
56 | - | } | |
57 | - | } | |
58 | - | ||
59 | - | ||
60 | - | @Verifier(t) | |
61 | - | func u () = sigVerify(t.bodyBytes, t.proofs[0], t.senderPublicKey) | |
62 | 41 |
github/deemru/w8io/026f985 26.23 ms ◑