tx · 4DaoepFAZWSLdQLF8tXn5fNxCDqeeQA4pdcqTA8fQqcY 3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph: -0.01400000 Waves 2021.10.26 14:00 [1763174] smart account 3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph > SELF 0.00000000 Waves
{ "type": 13, "id": "4DaoepFAZWSLdQLF8tXn5fNxCDqeeQA4pdcqTA8fQqcY", "fee": 1400000, "feeAssetId": null, "timestamp": 1635246072351, "version": 2, "chainId": 84, "sender": "3N61Cvq5XcnPk9rxpy2Rnp3bSr4syNGUJph", "senderPublicKey": "G7cNXePvAHUHmZfXa1eHnvFeH6DuykPC5wm9v9djTKgD", "proofs": [ "2RokwVWsmgYfkrKKxto14Exdk6FsGdKpTzBzR8MLdWcXyiFHJ2s8gGEA6Pf2tTcmoUkgbKZsjLKTNYs3Qxyy34Jt" ], "script": "base64:AAIFAAAAAAAAABEIAhIAEgASAwoBCBIECgIIAQAAAAUAAAAACXVzZXJBc3NldAIAAAAsR3JmZ3BjemNjcm41QWJydUxjdFh3Qzk0MWRnd2lwQnk2SFpZRGFRWEhidWsAAAAACWRBcHBBc3NldAIAAAAsN2FwU0p4TG54REt1bmI3YUJHYXVnNXFmVFg4OGpwYzNSMjI0OXBidUpVMngAAAAACmRlcG9zaXRGZWUAAAAAAAAAA+gAAAAADWNvbnRyb2xsZXJGZWUAAAAAAAAAJxAAAAAAC3BsYXRmb3JtRmVlAAAAAAAAACcQAAAABAAAAAJhOAEAAAAEaW5pdAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAAMTNQUEg3eDdpcW9iVzV6aXlpUkNpYzE5clFxS3I2blBZYUsxX2Fzc2V0X2JhbGFuY2UAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAATjNQUEg3eDdpcW9iVzV6aXlpUkNpYzE5clFxS3I2blBZYUsxXzNNdGhzdUM1RUR5ZWhHb0t2eXp3aFp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J5AAAAAgUAAAANcG9vbEFtb3VudEtleQUAAAANbmV3UG9vbEFtb3VudAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAARdXNlclBvb2xBbW91bnRLZXkFAAAAEW5ld1VzZXJQb29sQW1vdW50CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAABF1c2VyUG9vbEVhcm5lZEtleQUAAAAPdXNlckVhcm5lZFRvdGFsBQAAAANuaWwJAAACAAAAAQIAAAAmWW91IGhhdmUgbm90IHN1Y2ggYmFsYW5jZSBmb3Igd2l0aGRyYXcAAAABAAAAAmI2AQAAAAJiNwAAAAAJAAH0AAAAAwgFAAAAAmI2AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACYjYAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACYjYAAAAPc2VuZGVyUHVibGljS2V51Bw/IQ==", "height": 1763174, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G4Pba6KgZPq8F8e5RvJKtQDLUvVrrgHwqiwaYiV893vS Next: 98FMcrJd5dRW71fToMq2bpdEB7VLUWXTsrPP2sQsb3CC Diff:
Old | New | Differences | |
---|---|---|---|
76 | 76 | throw("Can't find asset") | |
77 | 77 | } | |
78 | 78 | let userEarnedTotal = (userEarned + userEarnedBefore) | |
79 | - | let amountWithoutFee = ((amount - fraction(amount, 1, platformFee, | |
79 | + | let amountWithoutFee = ((amount - fraction(amount, 1, platformFee, HALFUP)) - fraction(amount, 1, controllerFee, HALFUP)) | |
80 | 80 | let newPoolAmount = (poolAmount - amountWithoutFee) | |
81 | 81 | if ((userAmount >= amount)) | |
82 | 82 | then { |
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 | let depositFee = 1000 | |
9 | 9 | ||
10 | 10 | let controllerFee = 10000 | |
11 | 11 | ||
12 | 12 | let platformFee = 10000 | |
13 | 13 | ||
14 | 14 | @Callable(a8) | |
15 | 15 | func init () = [IntegerEntry("3PPH7x7iqobW5ziyiRCic19rQqKr6nPYaK1_asset_balance", 0), IntegerEntry("3PPH7x7iqobW5ziyiRCic19rQqKr6nPYaK1_3MthsuC5EDyehGoKvyzwhZvMENroHPsgaXS_earned", 0), IntegerEntry("3PPH7x7iqobW5ziyiRCic19rQqKr6nPYaK1_3MthsuC5EDyehGoKvyzwhZvMENroHPsgaXS_asset_balance", 0)] | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | ||
19 | 19 | @Callable(a8) | |
20 | 20 | func call () = { | |
21 | 21 | let a9 = Issue("Asset1", "Asset from dApp", 100000, 2, true, unit, 0) | |
22 | 22 | let b1 = calculateAssetId(a9) | |
23 | 23 | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), a9] | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | 28 | @Callable(i) | |
29 | 29 | func deposit (pool) = { | |
30 | 30 | let amount = i.payments[0].amount | |
31 | 31 | let assetId = i.payments[0].assetId | |
32 | 32 | let poolAmountKey = (pool + "_asset_balance") | |
33 | 33 | let userAddress = toString(i.caller) | |
34 | 34 | let userPoolAmountKey = (((pool + "_") + userAddress) + "_asset_balance") | |
35 | 35 | let dAppAssetAddress = getStringValue(this, (pool + "_service_token")) | |
36 | 36 | let poolAmount = getIntegerValue(this, poolAmountKey) | |
37 | 37 | let userAmount = match getInteger(userPoolAmountKey) { | |
38 | 38 | case int: Int => | |
39 | 39 | int | |
40 | 40 | case nothing => | |
41 | 41 | 0 | |
42 | 42 | } | |
43 | 43 | let newPoolAmount = (poolAmount + amount) | |
44 | 44 | let newUserPoolAmount = (userAmount + ((amount - fraction(amount, 1, depositFee, DOWN)) - fraction(amount, 1, controllerFee, DOWN))) | |
45 | 45 | [ScriptTransfer(i.caller, amount, fromBase58String(dAppAssetAddress)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount)] | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | 50 | @Callable(i) | |
51 | 51 | func withdraw (pool,userEarned) = { | |
52 | 52 | let amount = i.payments[0].amount | |
53 | 53 | let assetId = i.payments[0].assetId | |
54 | 54 | let poolAmountKey = (pool + "_asset_balance") | |
55 | 55 | let userAddress = toString(i.caller) | |
56 | 56 | let userPoolAmountKey = (((pool + "_") + userAddress) + "_asset_balance") | |
57 | 57 | let userPoolEarnedKey = (((pool + "_") + userAddress) + "_earned") | |
58 | 58 | let poolAmount = getIntegerValue(this, poolAmountKey) | |
59 | 59 | let userAmount = match getInteger(userPoolAmountKey) { | |
60 | 60 | case int: Int => | |
61 | 61 | int | |
62 | 62 | case nothing => | |
63 | 63 | 0 | |
64 | 64 | } | |
65 | 65 | let userEarnedBefore = match getInteger(userPoolEarnedKey) { | |
66 | 66 | case int: Int => | |
67 | 67 | int | |
68 | 68 | case nothing => | |
69 | 69 | 0 | |
70 | 70 | } | |
71 | 71 | let dAppAssetAddress = getStringValue(this, (pool + "_liquidity_token")) | |
72 | 72 | let liquidityTokenDecimal = match assetInfo(fromBase58String(dAppAssetAddress)) { | |
73 | 73 | case asset: Asset => | |
74 | 74 | asset.decimals | |
75 | 75 | case _ => | |
76 | 76 | throw("Can't find asset") | |
77 | 77 | } | |
78 | 78 | let userEarnedTotal = (userEarned + userEarnedBefore) | |
79 | - | let amountWithoutFee = ((amount - fraction(amount, 1, platformFee, | |
79 | + | let amountWithoutFee = ((amount - fraction(amount, 1, platformFee, HALFUP)) - fraction(amount, 1, controllerFee, HALFUP)) | |
80 | 80 | let newPoolAmount = (poolAmount - amountWithoutFee) | |
81 | 81 | if ((userAmount >= amount)) | |
82 | 82 | then { | |
83 | 83 | let newUserPoolAmount = (userAmount - amountWithoutFee) | |
84 | 84 | [ScriptTransfer(i.caller, amountWithoutFee, fromBase58String(dAppAssetAddress)), IntegerEntry(poolAmountKey, newPoolAmount), IntegerEntry(userPoolAmountKey, newUserPoolAmount), IntegerEntry(userPoolEarnedKey, userEarnedTotal)] | |
85 | 85 | } | |
86 | 86 | else throw("You have not such balance for withdraw") | |
87 | 87 | } | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | @Verifier(b6) | |
91 | 91 | func b7 () = sigVerify(b6.bodyBytes, b6.proofs[0], b6.senderPublicKey) | |
92 | 92 |
github/deemru/w8io/026f985 35.46 ms ◑