tx · 6ZAaHhj1he28UkFKT3YcTsLXLfvhizgYniWba3Rkta6x

3MxovCV2pBS5Z6YEcj3Gap5ish6dX3YERfP:  -0.05000000 Waves

2022.11.09 20:51 [2309921] smart account 3MxovCV2pBS5Z6YEcj3Gap5ish6dX3YERfP > SELF 0.00000000 Waves

{ "type": 13, "id": "6ZAaHhj1he28UkFKT3YcTsLXLfvhizgYniWba3Rkta6x", "fee": 5000000, "feeAssetId": null, "timestamp": 1668016288985, "version": 2, "chainId": 84, "sender": "3MxovCV2pBS5Z6YEcj3Gap5ish6dX3YERfP", "senderPublicKey": "6aZUzHaTgW7zPizjKqNFNAaKdYXVUaNwstd6E3NsD3YF", "proofs": [ "2HZX8dJ7ZrUeg2Qer7iCdb3JLdAUP5JYuAV3fh3gd78vfPVXbkbvvEpXRj4954VKEbYN4v5JSBZgoacFBza9M4ci" ], "script": "base64:AAIFAAAAAAAAAA0IAhIDCgEIEgASABIAAAAAEwAAAAAJcHJlY2lzaW9uAA3gtrOnZAAAAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAkABCIAAAABAgAAABBtYW5hZ2VyUHVibGljS2V5AQAAABZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAAAAAQAAAAHJG1hdGNoMAkBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAXMFAAAAByRtYXRjaDAJAAJZAAAAAQUAAAABcwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAUAAAAEdW5pdAkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgEAAAALbXVzdE1hbmFnZXIAAAABAAAAAWkEAAAAAnBkCQAAAgAAAAECAAAAEXBlcm1pc3Npb24gZGVuaWVkBAAAAAckbWF0Y2gwCQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAADCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGVWZWN0b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QAAAAGYW1vdW50CQEAAAAJc2VuZFdhdmVzAAAAAggFAAAAAWkAAAAGY2FsbGVyBQAAAA50cmFuc2ZlckFtb3VudAkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleRgWASc=", "height": 2309921, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: mKTDV39acEKVnuZwHoV7AFvZpFVAPPNkaT1MTBidUGL Next: 2u3faHFP2Kn2Gsp5oiLk9QUFc3PhWj3ogPyf3PG5t52o Diff:
OldNewDifferences
116116 }
117117
118118
119-func setRate (rate,growthRate) = [IntegerEntry("lastRate", rate), IntegerEntry("lastTimestamp", lastBlock.timestamp)]
119+func setRate (rate,growthRate) = [IntegerEntry("lastRate", rate), IntegerEntry("lastTimestamp", lastBlock.timestamp), IntegerEntry("growthRate", growthRate)]
120120
121121
122122 func withdraw () = {
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let precision = 1000000000000000000
55
66 func keyManagerPublicKey () = getString("managerPublicKey")
77
88
99 func managerPublicKeyOrUnit () = match keyManagerPublicKey() {
1010 case s: String =>
1111 fromBase58String(s)
1212 case _: Unit =>
1313 unit
1414 case _ =>
1515 throw("Match error")
1616 }
1717
1818
1919 func mustManager (i) = {
2020 let pd = throw("permission denied")
2121 match managerPublicKeyOrUnit() {
2222 case pk: ByteVector =>
2323 if ((i.callerPublicKey == pk))
2424 then true
2525 else pd
2626 case _: Unit =>
2727 if ((i.caller == this))
2828 then true
2929 else pd
3030 case _ =>
3131 throw("Match error")
3232 }
3333 }
3434
3535
3636 func mustNotInited () = match getBoolean("inited") {
3737 case inited: Boolean =>
3838 if ((inited == false))
3939 then true
4040 else throw("Already inited")
4141 case _: Unit =>
4242 false
4343 case _ =>
4444 throw("Match error")
4545 }
4646
4747
4848 func cancelLease () = match getBinary("leaseId") {
4949 case id: ByteVector =>
5050 [LeaseCancel(id), DeleteEntry("leaseId")]
5151 case _: Unit =>
5252 nil
5353 case _ =>
5454 throw("Match error")
5555 }
5656
5757
5858 func getBalance () = valueOrElse(getInteger("balance"), 0)
5959
6060
6161 func setBalance (amount) = IntegerEntry("balance", amount)
6262
6363
6464 func lease (amount) = if ((amount == 0))
6565 then nil
6666 else {
6767 let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress")))
6868 let currentAmount = getBalance()
6969 let newAmount = (currentAmount + amount)
7070 let leaseActions = if ((newAmount > 0))
7171 then {
7272 let newLease = Lease(leaserAddress, newAmount)
7373 let newLeaseId = calculateLeaseId(newLease)
7474 [newLease, BinaryEntry("leaseId", newLeaseId)]
7575 }
7676 else nil
7777 ((cancelLease() ++ leaseActions) :+ setBalance(newAmount))
7878 }
7979
8080
8181 func issueSWaves (amount) = {
8282 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
8383 Reissue(sWavesAssetId, amount, true)
8484 }
8585
8686
8787 func burnSWaves (amount) = {
8888 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
8989 Burn(sWavesAssetId, amount)
9090 }
9191
9292
9393 func sendSWaves (recipient,amount) = {
9494 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
9595 ScriptTransfer(recipient, amount, sWavesAssetId)
9696 }
9797
9898
9999 func sendWaves (recipient,amount) = ScriptTransfer(recipient, amount, unit)
100100
101101
102102 func sWavesQuantity () = {
103103 let assetId = fromBase58String(getStringValue("sWavesAssetId"))
104104 match assetInfo(assetId) {
105105 case asset: Asset =>
106106 asset.quantity
107107 case _ =>
108108 throw("Can't find asset")
109109 }
110110 }
111111
112112
113113 func getExcessWaves () = {
114114 let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress")))
115115 wavesBalance(leaserAddress).regular
116116 }
117117
118118
119-func setRate (rate,growthRate) = [IntegerEntry("lastRate", rate), IntegerEntry("lastTimestamp", lastBlock.timestamp)]
119+func setRate (rate,growthRate) = [IntegerEntry("lastRate", rate), IntegerEntry("lastTimestamp", lastBlock.timestamp), IntegerEntry("growthRate", growthRate)]
120120
121121
122122 func withdraw () = {
123123 let minerAddress = Address(fromBase58String(getStringValue("leaserAddress")))
124124 let result = invoke(minerAddress, "withdraw", nil, nil)
125125 if ((result == result))
126126 then result
127127 else throw("Strict value is not equal to itself.")
128128 }
129129
130130
131131 func currentRate (dt) = (getIntegerValue("lastRate") + (getIntegerValue("growthRate") * dt))
132132
133133
134134 func getCompoundTimestampDiff () = (lastBlock.timestamp - getIntegerValue("lastTimestamp"))
135135
136136
137137 @Callable(i)
138138 func init (leaserAddress) = {
139139 let checks = [mustManager(i), mustNotInited()]
140140 if ((checks == checks))
141141 then {
142142 let sWaves = Issue("sWaves", "", 0, 8, true, unit, 0)
143143 let sWavesAssetId = calculateAssetId(sWaves)
144144 [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(sWavesAssetId)), StringEntry("leaserAddress", leaserAddress), IntegerEntry("lastRate", precision), IntegerEntry("lastTimestamp", lastBlock.timestamp), IntegerEntry("growthRate", 0), IntegerEntry("balance", 0), sWaves]
145145 }
146146 else throw("Strict value is not equal to itself.")
147147 }
148148
149149
150150
151151 @Callable(i)
152152 func compound () = {
153153 let dt = getCompoundTimestampDiff()
154154 let sWavesTotal = sWavesQuantity()
155155 if (if ((dt == 0))
156156 then true
157157 else (sWavesTotal == 0))
158158 then nil
159159 else {
160160 let rate = currentRate(dt)
161161 let excessWaves = getExcessWaves()
162162 let growthRate = (fraction(excessWaves, precision, sWavesTotal) / dt)
163163 let withdrawResult = withdraw()
164164 if ((withdrawResult == withdrawResult))
165165 then (lease(excessWaves) ++ setRate(rate, growthRate))
166166 else throw("Strict value is not equal to itself.")
167167 }
168168 }
169169
170170
171171
172172 @Callable(i)
173173 func stake () = {
174174 let payment = i.payments[0]
175175 if ((payment.assetId != unit))
176176 then throw("Only WAVES supported")
177177 else if ((size(i.payments) != 1))
178178 then throw("Wrong payments amount")
179179 else {
180180 let dt = getCompoundTimestampDiff()
181181 let rate = currentRate(dt)
182182 let toReissue = fraction(payment.amount, precision, rate)
183183 let result = invoke(this, "compound", nil, nil)
184184 if ((result == result))
185185 then ((lease(payment.amount) :+ issueSWaves(toReissue)) :+ sendSWaves(i.caller, toReissue))
186186 else throw("Strict value is not equal to itself.")
187187 }
188188 }
189189
190190
191191
192192 @Callable(i)
193193 func unstake () = {
194194 let payment = i.payments[0]
195195 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
196196 if ((payment.assetId != sWavesAssetId))
197197 then throw("Only sWAVES supported")
198198 else if ((size(i.payments) != 1))
199199 then throw("Wrong payments amount")
200200 else {
201201 let dt = getCompoundTimestampDiff()
202202 let rate = currentRate(dt)
203203 let transferAmount = fraction(payment.amount, rate, precision)
204204 let result = invoke(this, "compound", nil, nil)
205205 if ((result == result))
206206 then ((lease(-(transferAmount)) :+ burnSWaves(payment.amount)) :+ sendWaves(i.caller, transferAmount))
207207 else throw("Strict value is not equal to itself.")
208208 }
209209 }
210210
211211
212212 @Verifier(tx)
213213 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
214214

github/deemru/w8io/169f3d6 
31.67 ms