tx · B1yz65pFKbqHwmNfrbj39XzMnYxXQ1hbjyKyuQACSks3

3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy:  -0.01000000 Waves

2022.11.06 18:03 [2305418] smart account 3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy > SELF 0.00000000 Waves

{ "type": 13, "id": "B1yz65pFKbqHwmNfrbj39XzMnYxXQ1hbjyKyuQACSks3", "fee": 1000000, "feeAssetId": null, "timestamp": 1667747075949, "version": 2, "chainId": 84, "sender": "3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy", "senderPublicKey": "65hdh3BQVcB4NhB1URp1RBWMK7AWDhrCSVjwbFjS64jo", "proofs": [ "4smgVg1mJKqs8wXwdJaf2GFoWdqWfjggM76wdk4SwsDXuyRjuhoQBEsasEiFem7QtZNQcN23fWwAPfzKvy6WbBJE" ], "script": "base64:AAIFAAAAAAAAAA0IAhIAEgMKAQgSABIAAAAADwAAAAAJcHJlY2lzaW9uAA3gtrOnZAAAAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAkABCIAAAABAgAAABBtYW5hZ2VyUHVibGljS2V5AQAAABZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAAAAAQAAAAHJG1hdGNoMAkBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAXMFAAAAByRtYXRjaDAJAAJZAAAAAQUAAAABcwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAUAAAAEdW5pdAkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgEAAAALbXVzdE1hbmFnZXIAAAABAAAAAWkEAAAAAnBkCQAAAgAAAAECAAAAEXBlcm1pc3Npb24gZGVuaWVkBAAAAAckbWF0Y2gwCQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAADCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGV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bW91bnQEAAAABXJhdGlvCQEAAAARQGV4dHJOYXRpdmUoMTA1NSkAAAABAgAAAAVyYXRpbwQAAAAKdG9UcmFuc2ZlcgkAAGsAAAADCAUAAAAHcGF5bWVudAAAAAZhbW91bnQFAAAABXJhdGlvBQAAAAlwcmVjaXNpb24JAARNAAAAAgkABE0AAAACCQEAAAAFbGVhc2UAAAABCQEAAAABLQAAAAEFAAAACnRvVHJhbnNmZXIJAQAAAApidXJuU1dhdmVzAAAAAQgFAAAAB3BheW1lbnQAAAAGYW1vdW50CQEAAAAJc2VuZFdhdmVzAAAAAggFAAAAAWkAAAAGY2FsbGVyBQAAAAp0b1RyYW5zZmVyAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkxLC2u", "height": 2305418, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ezgMxguCVu6kcBiLpxzgkEcYUjWp6EmRPaNrPEaiXy2 Next: 4Eouaqckyijs7VAZU4N7WupKPZvva2o4DNDD9DfLPkj2 Diff:
OldNewDifferences
9494 func sendWaves (recipient,amount) = ScriptTransfer(recipient, amount, unit)
9595
9696
97+func sWavesQuantity () = {
98+ let assetId = fromBase58String(getStringValue("sWavesAssetId"))
99+ match assetInfo(assetId) {
100+ case asset: Asset =>
101+ asset.quantity
102+ case _ =>
103+ throw("Can't find asset")
104+ }
105+ }
106+
107+
108+func getMinerBalance () = {
109+ let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress")))
110+ wavesBalance(leaserAddress).regular
111+ }
112+
113+
114+func calculateRatio () = {
115+ let leasedAmount = getIntegerValue("leasedAmount")
116+ let sWavesTotal = sWavesQuantity()
117+ let minerBalance = getMinerBalance()
118+ let wavesTotal = (leasedAmount + minerBalance)
119+ fraction(wavesTotal, precision, sWavesTotal)
120+ }
121+
122+
123+@Callable(i)
124+func compound () = {
125+ let ratio = calculateRatio()
126+[IntegerEntry("ratio", ratio)]
127+ }
128+
129+
130+
97131 @Callable(i)
98132 func init (leaserAddress) = {
99133 let checks = [mustManager(i), mustNotInited()]
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 setLeasedAmount (amount) = IntegerEntry("leasedAmount", amount)
5959
6060
6161 func lease (amount) = {
6262 let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress")))
6363 let currentAmount = getIntegerValue("leasedAmount")
6464 let newAmount = (currentAmount + amount)
6565 let leaseActions = if ((newAmount > 0))
6666 then {
6767 let newLease = Lease(leaserAddress, newAmount)
6868 let newLeaseId = calculateLeaseId(newLease)
6969 [newLease, BinaryEntry("leaseId", newLeaseId)]
7070 }
7171 else nil
7272 ((cancelLease() ++ leaseActions) :+ setLeasedAmount(newAmount))
7373 }
7474
7575
7676 func issueSWaves (amount) = {
7777 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
7878 Reissue(sWavesAssetId, amount, true)
7979 }
8080
8181
8282 func burnSWaves (amount) = {
8383 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
8484 Burn(sWavesAssetId, amount)
8585 }
8686
8787
8888 func sendSWaves (recipient,amount) = {
8989 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
9090 ScriptTransfer(recipient, amount, sWavesAssetId)
9191 }
9292
9393
9494 func sendWaves (recipient,amount) = ScriptTransfer(recipient, amount, unit)
9595
9696
97+func sWavesQuantity () = {
98+ let assetId = fromBase58String(getStringValue("sWavesAssetId"))
99+ match assetInfo(assetId) {
100+ case asset: Asset =>
101+ asset.quantity
102+ case _ =>
103+ throw("Can't find asset")
104+ }
105+ }
106+
107+
108+func getMinerBalance () = {
109+ let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress")))
110+ wavesBalance(leaserAddress).regular
111+ }
112+
113+
114+func calculateRatio () = {
115+ let leasedAmount = getIntegerValue("leasedAmount")
116+ let sWavesTotal = sWavesQuantity()
117+ let minerBalance = getMinerBalance()
118+ let wavesTotal = (leasedAmount + minerBalance)
119+ fraction(wavesTotal, precision, sWavesTotal)
120+ }
121+
122+
123+@Callable(i)
124+func compound () = {
125+ let ratio = calculateRatio()
126+[IntegerEntry("ratio", ratio)]
127+ }
128+
129+
130+
97131 @Callable(i)
98132 func init (leaserAddress) = {
99133 let checks = [mustManager(i), mustNotInited()]
100134 if ((checks == checks))
101135 then {
102136 let sWaves = Issue("sWaves", "", 0, 8, true, unit, 0)
103137 let sWavesAssetId = calculateAssetId(sWaves)
104138 [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(sWavesAssetId)), StringEntry("leaserAddress", leaserAddress), IntegerEntry("ratio", precision), IntegerEntry("leasedAmount", 0), sWaves]
105139 }
106140 else throw("Strict value is not equal to itself.")
107141 }
108142
109143
110144
111145 @Callable(i)
112146 func stake () = {
113147 let payment = i.payments[0]
114148 if ((payment.assetId != unit))
115149 then throw("Only WAVES supported")
116150 else if ((size(i.payments) != 1))
117151 then throw("Wrong payments amount")
118152 else {
119153 let ratio = getIntegerValue("ratio")
120154 let toReissue = fraction(payment.amount, precision, ratio)
121155 ((lease(payment.amount) :+ issueSWaves(toReissue)) :+ sendSWaves(i.caller, toReissue))
122156 }
123157 }
124158
125159
126160
127161 @Callable(i)
128162 func withdraw () = {
129163 let payment = i.payments[0]
130164 let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId"))
131165 if ((payment.assetId != sWavesAssetId))
132166 then throw("Only sWAVES supported")
133167 else if ((size(i.payments) != 1))
134168 then throw("Wrong payments amount")
135169 else {
136170 let ratio = getIntegerValue("ratio")
137171 let toTransfer = fraction(payment.amount, ratio, precision)
138172 ((lease(-(toTransfer)) :+ burnSWaves(payment.amount)) :+ sendWaves(i.caller, toTransfer))
139173 }
140174 }
141175
142176
143177 @Verifier(tx)
144178 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
145179

github/deemru/w8io/026f985 
33.88 ms