tx · GXnNSuXDiUGj5n6i2WCUaUBt7gRZN5wSXGdbasePbgsQ 3NBGYJLwHsU6eJXLi74dB8cBbMfiTS2cTtu: -0.01400000 Waves 2022.07.29 20:02 [2161394] smart account 3NBGYJLwHsU6eJXLi74dB8cBbMfiTS2cTtu > SELF 0.00000000 Waves
{ "type": 13, "id": "GXnNSuXDiUGj5n6i2WCUaUBt7gRZN5wSXGdbasePbgsQ", "fee": 1400000, "feeAssetId": null, "timestamp": 1659114206189, "version": 2, "chainId": 84, "sender": "3NBGYJLwHsU6eJXLi74dB8cBbMfiTS2cTtu", "senderPublicKey": "DqoxVw7QE15hy21jZuVxZXM9E7WXmheH1up4dwp57Yb8", "proofs": [ "yKasUvWBk3ApVpkYmdA8RjfgoL6duHGZWNbLYCCDeGLtMnSZe4YT8cWqhefvXnS8DKUDArRmKiDdDBaFoR6NRaR" ], "script": "base64:AAIFAAAAAAAAABQIAhIAEgMKAQgSABIDCgEBEgASAAAAAA8AAAAACW9yYWNsZUtleQIAAAAJb3JhY2xlS2V5AAAAAAVTY2FsZQAAAAAAAA9CQAEAAAANdHJ5R2V0SW50ZWdlcgAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAAAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQIAAAAAAAAAAAZvcmFjbGUJAQAAAAx0cnlHZXRTdHJpbmcAAAABBQAAAAlvcmFjbGVLZXkAAAAACW9yYWNsZUZlZQkBAAAABXZhbHVlAAAAAQkABCYAAAABBQAAAAZvcmFjbGUBAAAAGWdldEludGVnZXJCeU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AAAQkABEwAAAACCQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAABQAAAANuaWwJAQAAAAtjbGFpbVJlc3VsdAAAAAEIBQAAAAFpAAAABmNhbGxlcgAAAAFpAQAAAAt0b3BVcFJld2FyZAAAAAAJAQAAABN0b3BVcFJld2FyZEludGVybmFsAAAAAQgFAAAAAWkAAAAIcGF5bWVudHMAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tledVaFfk=", "height": 2161394, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DxLt8nWgQfxLKMZ3vJv6Y4G2ndQYexkXdivTbQKKUEGx Next: AvRLjWyNmNTFGPM9Uen8sEo3snWMm9ztGLnRLrkQmeeF Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let oracleKey = "oracleKey" | |
5 | 5 | ||
6 | 6 | let Scale = 1000000 | |
7 | 7 | ||
8 | 8 | func tryGetInteger (key) = match getInteger(this, key) { | |
9 | 9 | case b: Int => | |
10 | 10 | b | |
11 | 11 | case _ => | |
12 | 12 | 0 | |
13 | 13 | } | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func tryGetString (key) = match getString(this, key) { | |
17 | 17 | case a: String => | |
18 | 18 | a | |
19 | 19 | case _ => | |
20 | 20 | "" | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | let oracle = tryGetString(oracleKey) | |
25 | 25 | ||
26 | 26 | let oracleFee = value(addressFromString(oracle)) | |
27 | 27 | ||
28 | 28 | func getIntegerByKeyFromOracle (key) = valueOrErrorMessage(getInteger(oracleFee, key), "Integer undefine or 0 in oracle") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | let SconexAssetId = fromBase58String(getStringValue(oracleFee, "SconexAssetId")) | |
32 | 32 | ||
33 | 33 | let currentFeeSconex = getIntegerByKeyFromOracle(("fee_" + toBase58String(SconexAssetId))) | |
34 | 34 | ||
35 | 35 | let stakeDapp = addressFromString(valueOrErrorMessage(getString(oracleFee, "stakeDapp"), "sconexDapp not found")) | |
36 | 36 | ||
37 | 37 | func claimResult (address) = { | |
38 | 38 | let addressStr = toString(address) | |
39 | 39 | let currentInterest = tryGetInteger("global_lastCheck_SCONEX_interest") | |
40 | 40 | let lastCheckInterest = tryGetInteger((addressStr + "_lastCheck_SCONEX_interest")) | |
41 | 41 | let stakedAmount = tryGetInteger((addressStr + "_SCONEX_staked")) | |
42 | 42 | let reward = if ((lastCheckInterest > 0)) | |
43 | 43 | then fraction((currentInterest - lastCheckInterest), stakedAmount, Scale) | |
44 | 44 | else 0 | |
45 | 45 | [IntegerEntry((addressStr + "_lastCheck_SCONEX_interest"), currentInterest), IntegerEntry((addressStr + "_SCONEX_claimed"), (tryGetInteger((addressStr + "_SCONEX_claimed")) + reward)), ScriptTransfer(address, reward, SconexAssetId)] | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func isPayment (i) = if ((size(i) != 1)) | |
50 | 50 | then throw("Wrong payments attached") | |
51 | 51 | else { | |
52 | 52 | let payment = value(i[0]) | |
53 | 53 | let amount = value(payment.amount) | |
54 | 54 | $Tuple2(payment, amount) | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func validatePayment (i) = { | |
59 | 59 | let t089829018 = isPayment(i) | |
60 | 60 | let payment = t089829018._1 | |
61 | 61 | let amount = t089829018._2 | |
62 | 62 | let assetId = if (if (isDefined(payment.assetId)) | |
63 | 63 | then (payment.assetId == SconexAssetId) | |
64 | 64 | else false) | |
65 | 65 | then payment.assetId | |
66 | 66 | else throw((("Only " + toBase58String(SconexAssetId)) + " token accepted as transaction fee")) | |
67 | 67 | if ((amount != currentFeeSconex)) | |
68 | 68 | then throw(((("Payment amount should be " + toString(currentFeeSconex)) + " but is: ") + toString(amount))) | |
69 | 69 | else $Tuple2(amount, assetId) | |
70 | 70 | } | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func topUpRewardInternal (i) = { | |
74 | 74 | let amount = fraction(i[0].amount, 9, 10) | |
75 | 75 | let currentInterest = tryGetInteger("global_lastCheck_SCONEX_interest") | |
76 | 76 | let totalStakedAmount = tryGetInteger("global_staked") | |
77 | 77 | let interestDelta = if ((totalStakedAmount > 0)) | |
78 | 78 | then fraction(amount, Scale, totalStakedAmount) | |
79 | 79 | else 0 | |
80 | 80 | if ((i[0].assetId != SconexAssetId)) | |
81 | 81 | then throw("wrong asset attached") | |
82 | 82 | else [IntegerEntry("global_SCONEX_earnings", (tryGetInteger("global_SCONEX_earnings") + amount)), IntegerEntry("global_lastCheck_SCONEX_interest", (currentInterest + interestDelta))] | |
83 | 83 | } | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | func validateAndProcessPaymentInternal (i) = { | |
87 | 87 | let validP = validatePayment(i) | |
88 | 88 | let amountP = validP._1 | |
89 | 89 | let assetIdP = validP._2 | |
90 | 90 | if (!(isDefined(amountP))) | |
91 | 91 | then throw("Something went wrong") | |
92 | 92 | else topUpRewardInternal(i) | |
93 | 93 | } | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | @Callable(i) | |
97 | 97 | func validateAndProcessPayment () = validateAndProcessPaymentInternal(i.payments) | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | ||
101 | 101 | @Callable(i) | |
102 | 102 | func initDapp (dappKey) = if ((i.caller != this)) | |
103 | 103 | then throw("You cannot do this action") | |
104 | 104 | else if ((oracle != "")) | |
105 | 105 | then throw("oracle already set, you can't override!") | |
106 | 106 | else [StringEntry(oracleKey, dappKey)] | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | @Callable(i) | |
111 | 111 | func stake () = { | |
112 | 112 | let paymentData = validateAndProcessPaymentInternal([i.payments[0]]) | |
113 | 113 | let amount = i.payments[1].amount | |
114 | 114 | let addressStr = toString(i.caller) | |
115 | 115 | let totalStakedAmount = tryGetInteger("global_staked") | |
116 | 116 | if ((i.payments[1].assetId != SconexAssetId)) | |
117 | 117 | then throw("wrong asset attached") | |
118 | 118 | else ((claimResult(i.caller) ++ [IntegerEntry("global_staked", (totalStakedAmount + amount)), IntegerEntry((addressStr + "_SCONEX_staked"), (tryGetInteger((addressStr + "_SCONEX_staked")) + amount))]) ++ paymentData) | |
119 | 119 | } | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | 123 | @Callable(i) | |
124 | 124 | func unStake (amount) = { | |
125 | 125 | let paymentData = validateAndProcessPaymentInternal([i.payments[0]]) | |
126 | 126 | let addressStr = toString(i.caller) | |
127 | 127 | let stakedAmount = tryGetInteger((addressStr + "_SCONEX_staked")) | |
128 | 128 | if ((amount > stakedAmount)) | |
129 | 129 | then throw("you don't have tokens available") | |
130 | 130 | else ((claimResult(i.caller) ++ [IntegerEntry((addressStr + "_SCONEX_staked"), (stakedAmount - amount)), IntegerEntry("global_staked", (tryGetInteger("global_staked") - amount)), ScriptTransfer(i.caller, amount, SconexAssetId)]) ++ paymentData) | |
131 | 131 | } | |
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | 135 | @Callable(i) | |
136 | 136 | func claimReward () = (validateAndProcessPaymentInternal([i.payments[0]]) ++ claimResult(i.caller)) | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | ||
140 | 140 | @Callable(i) | |
141 | 141 | func topUpReward () = topUpRewardInternal(i.payments) | |
142 | 142 | ||
143 | 143 | ||
144 | 144 | @Verifier(tx) | |
145 | 145 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
146 | 146 |
github/deemru/w8io/169f3d6 36.16 ms ◑