tx · Hpceu4bwHHwaz1wedPk49Mz6om5k9uQP13v51UVpYAWt 3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph: -0.01400000 Waves 2021.09.20 17:44 [1711517] smart account 3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph > SELF 0.00000000 Waves
{ "type": 13, "id": "Hpceu4bwHHwaz1wedPk49Mz6om5k9uQP13v51UVpYAWt", "fee": 1400000, "feeAssetId": null, "timestamp": 1632149163411, "version": 2, "chainId": 84, "sender": "3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph", "senderPublicKey": "G7cNXePvAHUHmZfXa1eHnvFeH6DuykPC5wm9v9djTKgD", "proofs": [ "huA8kHsydjM91s5zh6utZxckR5WkDMdBDgEeD2MNcXnxeG39fUTSn4mxfkNTr7azghyGQ9UjAA5fVWpRJ9CoW6t" ], "script": "base64:AAIFAAAAAAAAABEIAhIAEgASAwoBCBIECgIIAQAAAAIAAAAACXVzZXJBc3NldAIAAAAsR3JmZ3BjemNjcm41QWJydUxjdFh3Qzk0MWRnd2lwQnk2SFpZRGFRWEhidWsAAAAACWRBcHBBc3NldAIAAAAsN2FwU0p4TG54REt1bmI3YUJHYXVnNXFmVFg4OGpwYzNSMjI0OXBidUpVMngAAAAEAAAAAmE4AQAAAARpbml0AAAAAAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAAxM1BQSDd4N2lxb2JXNXppeWlSQ2ljMTlyUXFLcjZuUFlhSzFfYXNzZXRfYmFsYW5jZQAAAAAAAAAAAAUAAAADbmlsAAAAAmE4AQAAAARjYWxsAAAAAAQAAAACYTkJAARDAAAABwIAAAAGQXNzZXQxAgAAAA9Bc3NldCBmcm9tIGRBcHAAAAAAAAABhqAAAAAAAAAAAAIGBQAAAAR1bml0AAAAAAAAAAAABAAAAAJiMQkABDgAAAABBQAAAAJhOQkABEwAAAACCQEAAAALQmluYXJ5RW50cnkAAAACAgAAAANiaW4BAAAAAAkABEwAAAACCQE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AfQAAAADCAUAAAACYjYAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJiNgAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJiNgAAAA9zZW5kZXJQdWJsaWNLZXn22c8s", "height": 1711517, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DP2q2Dp5ZoibTj1xpNDzGNUkLhRNuNCgGrhZNKkYA37U Next: BGKuoQNYWdN4t8nd2LKjzqtaWdCKMi38PDEfpvdTUdno Diff:
Old | New | Differences | |
---|---|---|---|
41 | 41 | ||
42 | 42 | ||
43 | 43 | @Callable(i) | |
44 | - | func withdraw (pool) = { | |
44 | + | func withdraw (pool,shareTokenCost) = { | |
45 | 45 | let amount = i.payments[0].amount | |
46 | 46 | let assetId = i.payments[0].assetId | |
47 | 47 | let poolAmountKey = (pool + "_asset_balance") | |
48 | 48 | let userAddress = toString(i.caller) | |
49 | 49 | let userPoolAmountKey = (((pool + "_") + userAddress) + "_asset_balance") | |
50 | + | let userPoolEarnedKey = (((pool + "_") + userAddress) + "_earned") | |
50 | 51 | let poolAmount = getIntegerValue(this, poolAmountKey) | |
51 | 52 | let userAmount = match getInteger(userPoolAmountKey) { | |
52 | 53 | case int: Int => | |
54 | 55 | case nothing => | |
55 | 56 | 0 | |
56 | 57 | } | |
58 | + | let userEarned = match getInteger(userPoolAmountKey) { | |
59 | + | case int: Int => | |
60 | + | int | |
61 | + | case nothing => | |
62 | + | 0 | |
63 | + | } | |
64 | + | let newUserEarned = (userEarned + (amount * shareTokenCost)) | |
57 | 65 | let newPoolAmount = (poolAmount - amount) | |
58 | 66 | if ((userAmount >= amount)) | |
59 | 67 | then { | |
60 | 68 | let newUserPoolAmount = (userAmount - amount) | |
61 | - | [ScriptTransfer(i.caller, amount, fromBase58String(userAsset)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount)] | |
69 | + | [ScriptTransfer(i.caller, amount, fromBase58String(userAsset)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount), IntegerEntry(userPoolEarnedKey, newUserEarned)] | |
62 | 70 | } | |
63 | 71 | else throw("You have not such balance for withdraw") | |
64 | 72 | } |
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_asset_balance", 0)] | |
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 poolAmount = getIntegerValue(this, poolAmountKey) | |
30 | 30 | let userAmount = match getInteger(userPoolAmountKey) { | |
31 | 31 | case int: Int => | |
32 | 32 | int | |
33 | 33 | case nothing => | |
34 | 34 | 0 | |
35 | 35 | } | |
36 | 36 | let newPoolAmount = (poolAmount + amount) | |
37 | 37 | let newUserPoolAmount = (userAmount + amount) | |
38 | 38 | [ScriptTransfer(i.caller, amount, fromBase58String(dAppAsset)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount)] | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | ||
43 | 43 | @Callable(i) | |
44 | - | func withdraw (pool) = { | |
44 | + | func withdraw (pool,shareTokenCost) = { | |
45 | 45 | let amount = i.payments[0].amount | |
46 | 46 | let assetId = i.payments[0].assetId | |
47 | 47 | let poolAmountKey = (pool + "_asset_balance") | |
48 | 48 | let userAddress = toString(i.caller) | |
49 | 49 | let userPoolAmountKey = (((pool + "_") + userAddress) + "_asset_balance") | |
50 | + | let userPoolEarnedKey = (((pool + "_") + userAddress) + "_earned") | |
50 | 51 | let poolAmount = getIntegerValue(this, poolAmountKey) | |
51 | 52 | let userAmount = match getInteger(userPoolAmountKey) { | |
52 | 53 | case int: Int => | |
53 | 54 | int | |
54 | 55 | case nothing => | |
55 | 56 | 0 | |
56 | 57 | } | |
58 | + | let userEarned = match getInteger(userPoolAmountKey) { | |
59 | + | case int: Int => | |
60 | + | int | |
61 | + | case nothing => | |
62 | + | 0 | |
63 | + | } | |
64 | + | let newUserEarned = (userEarned + (amount * shareTokenCost)) | |
57 | 65 | let newPoolAmount = (poolAmount - amount) | |
58 | 66 | if ((userAmount >= amount)) | |
59 | 67 | then { | |
60 | 68 | let newUserPoolAmount = (userAmount - amount) | |
61 | - | [ScriptTransfer(i.caller, amount, fromBase58String(userAsset)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount)] | |
69 | + | [ScriptTransfer(i.caller, amount, fromBase58String(userAsset)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount), IntegerEntry(userPoolEarnedKey, newUserEarned)] | |
62 | 70 | } | |
63 | 71 | else throw("You have not such balance for withdraw") | |
64 | 72 | } | |
65 | 73 | ||
66 | 74 | ||
67 | 75 | @Verifier(b6) | |
68 | 76 | func b7 () = sigVerify(b6.bodyBytes, b6.proofs[0], b6.senderPublicKey) | |
69 | 77 |
github/deemru/w8io/026f985 74.01 ms ◑