tx · HmX4xJkmJCztmw4HA8EHAVYbYmcrmzUBT7dNyZNQEqpT 3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph: -0.01400000 Waves 2021.10.25 17:20 [1761954] smart account 3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph > SELF 0.00000000 Waves
{ "type": 13, "id": "HmX4xJkmJCztmw4HA8EHAVYbYmcrmzUBT7dNyZNQEqpT", "fee": 1400000, "feeAssetId": null, "timestamp": 1635171680610, "version": 2, "chainId": 84, "sender": "3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph", "senderPublicKey": "G7cNXePvAHUHmZfXa1eHnvFeH6DuykPC5wm9v9djTKgD", "proofs": [ "2qFkwNCQBdmcu22N18pPRa9T9egrsQwxtzTXfnC58CRLbrTQdoW8h3D1oBwo1oxdNwiawexdSuh9V2uji1fXyzab" ], "script": "base64:AAIFAAAAAAAAABEIAhIAEgASAwoBCBIECgIIAQAAAAIAAAAACXVzZXJBc3NldAIAAAAsR3JmZ3BjemNjcm41QWJydUxjdFh3Qzk0MWRnd2lwQnk2SFpZRGFRWEhidWsAAAAACWRBcHBBc3NldAIAAAAsN2FwU0p4TG54REt1bmI3YUJHYXVnNXFmVFg4OGpwYzNSMjI0OXBidUpVMngAAAAEAAAAAmE4AQAAAARpbml0AAAAAAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAA7M1BQSDd4N2lxb2JXNXppeWlSQ2ljMTlyUXFLcjZuUFlhSzFfbGlxdWlkaXR5X3Rva2VuX2RlY2ltYWwAAAAAAAAAAAYFAAAAA25pbAAAAAJhOAEAAAAEY2FsbAAAAAAEAAAAAmE5CQAEQwAAAAcCAAAABkFzc2V0MQIAAAAPQXNzZXQgZnJvbSBkQXBwAAAAAAAAAYagAAAAAAAAAAACBgUAAAAEdW5pdAAAAAAAAAAAAAQAAAACYjEJAAQ4AAAAAQUAAAACYTkJAARMAAAAAgkBAAAAC0JpbmFyeUVudHJ5AAAAAg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Db3N0BAAAAA1uZXdQb29sQW1vdW50CQAAZQAAAAIFAAAACnBvb2xBbW91bnQFAAAABmFtb3VudAMJAABnAAAAAgUAAAAKdXNlckFtb3VudAUAAAAGYW1vdW50BAAAABFuZXdVc2VyUG9vbEFtb3VudAkAAGUAAAACBQAAAAp1c2VyQW1vdW50BQAAAAZhbW91bnQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQJAAJZAAAAAQUAAAAQZEFwcEFzc2V0QWRkcmVzcwkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAANcG9vbEFtb3VudEtleQUAAAANbmV3UG9vbEFtb3VudAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAARdXNlclBvb2xBbW91bnRLZXkFAAAAEW5ld1VzZXJQb29sQW1vdW50CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAABF1c2VyUG9vbEVhcm5lZEtleQUAAAANbmV3VXNlckVhcm5lZAUAAAADbmlsCQAAAgAAAAECAAAAJllvdSBoYXZlIG5vdCBzdWNoIGJhbGFuY2UgZm9yIHdpdGhkcmF3AAAAAQAAAAJiNgEAAAACYjcAAAAACQAB9AAAAAMIBQAAAAJiNgAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAmI2AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAmI2AAAAD3NlbmRlclB1YmxpY0tlebZdMtU=", "height": 1761954, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5PwVVuDvUepuf5QPjmcnYpJq4KJh5hYdGo31sKA5jaeq Next: CqPsHMZeRhH1FGaR6PKs9a4KspGLSjqxFyU9VWGHGtKx Diff:
Old | New | Differences | |
---|---|---|---|
62 | 62 | case nothing => | |
63 | 63 | 0 | |
64 | 64 | } | |
65 | - | let newUserEarned = (userEarned + (amount * shareTokenCost)) | |
65 | + | let dAppAssetAddress = getStringValue(this, (pool + "_liquidity_token")) | |
66 | + | let liquidityTokenDecimal = match assetInfo(fromBase58String(dAppAssetAddress)) { | |
67 | + | case asset: Asset => | |
68 | + | asset.decimals | |
69 | + | case _ => | |
70 | + | throw("Can't find asset") | |
71 | + | } | |
72 | + | let newUserEarned = (userEarned + ((amount / pow(10, 0, liquidityTokenDecimal, 0, 0, DOWN)) * shareTokenCost)) | |
66 | 73 | let newPoolAmount = (poolAmount - amount) | |
67 | - | let dAppAssetAddress = getStringValue(this, (pool + "_service_token")) | |
68 | 74 | if ((userAmount >= amount)) | |
69 | 75 | then { | |
70 | 76 | let newUserPoolAmount = (userAmount - amount) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let userAsset = "Grfgpczccrn5AbruLctXwC941dgwipBy6HZYDaQXHbuk" | |
5 | 5 | ||
6 | 6 | let dAppAsset = "7apSJxLnxDKunb7aBGaug5qfTX88jpc3R2249pbuJU2x" | |
7 | 7 | ||
8 | 8 | @Callable(a8) | |
9 | 9 | func init () = [IntegerEntry("3PPH7x7iqobW5ziyiRCic19rQqKr6nPYaK1_liquidity_token_decimal", 6)] | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | ||
13 | 13 | @Callable(a8) | |
14 | 14 | func call () = { | |
15 | 15 | let a9 = Issue("Asset1", "Asset from dApp", 100000, 2, true, unit, 0) | |
16 | 16 | let b1 = calculateAssetId(a9) | |
17 | 17 | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), a9] | |
18 | 18 | } | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | ||
22 | 22 | @Callable(i) | |
23 | 23 | func deposit (pool) = { | |
24 | 24 | let amount = i.payments[0].amount | |
25 | 25 | let assetId = i.payments[0].assetId | |
26 | 26 | let poolAmountKey = (pool + "_asset_balance") | |
27 | 27 | let userAddress = toString(i.caller) | |
28 | 28 | let userPoolAmountKey = (((pool + "_") + userAddress) + "_asset_balance") | |
29 | 29 | let dAppAssetAddress = getStringValue(this, (pool + "_service_token")) | |
30 | 30 | let poolAmount = getIntegerValue(this, poolAmountKey) | |
31 | 31 | let userAmount = match getInteger(userPoolAmountKey) { | |
32 | 32 | case int: Int => | |
33 | 33 | int | |
34 | 34 | case nothing => | |
35 | 35 | 0 | |
36 | 36 | } | |
37 | 37 | let newPoolAmount = (poolAmount + amount) | |
38 | 38 | let newUserPoolAmount = (userAmount + amount) | |
39 | 39 | [ScriptTransfer(i.caller, amount, fromBase58String(dAppAssetAddress)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount)] | |
40 | 40 | } | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | ||
44 | 44 | @Callable(i) | |
45 | 45 | func withdraw (pool,shareTokenCost) = { | |
46 | 46 | let amount = i.payments[0].amount | |
47 | 47 | let assetId = i.payments[0].assetId | |
48 | 48 | let poolAmountKey = (pool + "_asset_balance") | |
49 | 49 | let userAddress = toString(i.caller) | |
50 | 50 | let userPoolAmountKey = (((pool + "_") + userAddress) + "_asset_balance") | |
51 | 51 | let userPoolEarnedKey = (((pool + "_") + userAddress) + "_earned") | |
52 | 52 | let poolAmount = getIntegerValue(this, poolAmountKey) | |
53 | 53 | let userAmount = match getInteger(userPoolAmountKey) { | |
54 | 54 | case int: Int => | |
55 | 55 | int | |
56 | 56 | case nothing => | |
57 | 57 | 0 | |
58 | 58 | } | |
59 | 59 | let userEarned = match getInteger(userPoolAmountKey) { | |
60 | 60 | case int: Int => | |
61 | 61 | int | |
62 | 62 | case nothing => | |
63 | 63 | 0 | |
64 | 64 | } | |
65 | - | let newUserEarned = (userEarned + (amount * shareTokenCost)) | |
65 | + | let dAppAssetAddress = getStringValue(this, (pool + "_liquidity_token")) | |
66 | + | let liquidityTokenDecimal = match assetInfo(fromBase58String(dAppAssetAddress)) { | |
67 | + | case asset: Asset => | |
68 | + | asset.decimals | |
69 | + | case _ => | |
70 | + | throw("Can't find asset") | |
71 | + | } | |
72 | + | let newUserEarned = (userEarned + ((amount / pow(10, 0, liquidityTokenDecimal, 0, 0, DOWN)) * shareTokenCost)) | |
66 | 73 | let newPoolAmount = (poolAmount - amount) | |
67 | - | let dAppAssetAddress = getStringValue(this, (pool + "_service_token")) | |
68 | 74 | if ((userAmount >= amount)) | |
69 | 75 | then { | |
70 | 76 | let newUserPoolAmount = (userAmount - amount) | |
71 | 77 | [ScriptTransfer(i.caller, amount, fromBase58String(dAppAssetAddress)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount), IntegerEntry(userPoolEarnedKey, newUserEarned)] | |
72 | 78 | } | |
73 | 79 | else throw("You have not such balance for withdraw") | |
74 | 80 | } | |
75 | 81 | ||
76 | 82 | ||
77 | 83 | @Verifier(b6) | |
78 | 84 | func b7 () = sigVerify(b6.bodyBytes, b6.proofs[0], b6.senderPublicKey) | |
79 | 85 |
github/deemru/w8io/169f3d6 41.73 ms ◑