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:AAIFAAAAAAAAAA0IAhIAEgMKAQgSABIAAAAADwAAAAAJcHJlY2lzaW9uAA3gtrOnZAAAAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAkABCIAAAABAgAAABBtYW5hZ2VyUHVibGljS2V5AQAAABZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAAAAAQAAAAHJG1hdGNoMAkBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAXMFAAAAByRtYXRjaDAJAAJZAAAAAQUAAAABcwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAUAAAAEdW5pdAkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgEAAAALbXVzdE1hbmFnZXIAAAABAAAAAWkEAAAAAnBkCQAAAgAAAAECAAAAEXBlcm1pc3Npb24gZGVuaWVkBAAAAAckbWF0Y2gwCQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAADCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGVW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W91bnQEAAAABXJhdGlvCQEAAAARQGV4dHJOYXRpdmUoMTA1NSkAAAABAgAAAAVyYXRpbwQAAAAKdG9UcmFuc2ZlcgkAAGsAAAADCAUAAAAHcGF5bWVudAAAAAZhbW91bnQFAAAABXJhdGlvBQAAAAlwcmVjaXNpb24JAARNAAAAAgkABE0AAAACCQEAAAAFbGVhc2UAAAABCQEAAAABLQAAAAEFAAAACnRvVHJhbnNmZXIJAQAAAApidXJuU1dhdmVzAAAAAQgFAAAAB3BheW1lbnQAAAAGYW1vdW50CQEAAAAJc2VuZFdhdmVzAAAAAggFAAAAAWkAAAAGY2FsbGVyBQAAAAp0b1RyYW5zZmVyAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkxLC2u", "height": 2305418, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ezgMxguCVu6kcBiLpxzgkEcYUjWp6EmRPaNrPEaiXy2 Next: 4Eouaqckyijs7VAZU4N7WupKPZvva2o4DNDD9DfLPkj2 Diff:
Old | New | Differences | |
---|---|---|---|
94 | 94 | func sendWaves (recipient,amount) = ScriptTransfer(recipient, amount, unit) | |
95 | 95 | ||
96 | 96 | ||
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 | + | ||
97 | 131 | @Callable(i) | |
98 | 132 | func init (leaserAddress) = { | |
99 | 133 | let checks = [mustManager(i), mustNotInited()] |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let precision = 1000000000000000000 | |
5 | 5 | ||
6 | 6 | func keyManagerPublicKey () = getString("managerPublicKey") | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func managerPublicKeyOrUnit () = match keyManagerPublicKey() { | |
10 | 10 | case s: String => | |
11 | 11 | fromBase58String(s) | |
12 | 12 | case _: Unit => | |
13 | 13 | unit | |
14 | 14 | case _ => | |
15 | 15 | throw("Match error") | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func mustManager (i) = { | |
20 | 20 | let pd = throw("permission denied") | |
21 | 21 | match managerPublicKeyOrUnit() { | |
22 | 22 | case pk: ByteVector => | |
23 | 23 | if ((i.callerPublicKey == pk)) | |
24 | 24 | then true | |
25 | 25 | else pd | |
26 | 26 | case _: Unit => | |
27 | 27 | if ((i.caller == this)) | |
28 | 28 | then true | |
29 | 29 | else pd | |
30 | 30 | case _ => | |
31 | 31 | throw("Match error") | |
32 | 32 | } | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func mustNotInited () = match getBoolean("inited") { | |
37 | 37 | case inited: Boolean => | |
38 | 38 | if ((inited == false)) | |
39 | 39 | then true | |
40 | 40 | else throw("Already inited") | |
41 | 41 | case _: Unit => | |
42 | 42 | false | |
43 | 43 | case _ => | |
44 | 44 | throw("Match error") | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func cancelLease () = match getBinary("leaseId") { | |
49 | 49 | case id: ByteVector => | |
50 | 50 | [LeaseCancel(id), DeleteEntry("leaseId")] | |
51 | 51 | case _: Unit => | |
52 | 52 | nil | |
53 | 53 | case _ => | |
54 | 54 | throw("Match error") | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func setLeasedAmount (amount) = IntegerEntry("leasedAmount", amount) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func lease (amount) = { | |
62 | 62 | let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress"))) | |
63 | 63 | let currentAmount = getIntegerValue("leasedAmount") | |
64 | 64 | let newAmount = (currentAmount + amount) | |
65 | 65 | let leaseActions = if ((newAmount > 0)) | |
66 | 66 | then { | |
67 | 67 | let newLease = Lease(leaserAddress, newAmount) | |
68 | 68 | let newLeaseId = calculateLeaseId(newLease) | |
69 | 69 | [newLease, BinaryEntry("leaseId", newLeaseId)] | |
70 | 70 | } | |
71 | 71 | else nil | |
72 | 72 | ((cancelLease() ++ leaseActions) :+ setLeasedAmount(newAmount)) | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func issueSWaves (amount) = { | |
77 | 77 | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
78 | 78 | Reissue(sWavesAssetId, amount, true) | |
79 | 79 | } | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func burnSWaves (amount) = { | |
83 | 83 | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
84 | 84 | Burn(sWavesAssetId, amount) | |
85 | 85 | } | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func sendSWaves (recipient,amount) = { | |
89 | 89 | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
90 | 90 | ScriptTransfer(recipient, amount, sWavesAssetId) | |
91 | 91 | } | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func sendWaves (recipient,amount) = ScriptTransfer(recipient, amount, unit) | |
95 | 95 | ||
96 | 96 | ||
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 | + | ||
97 | 131 | @Callable(i) | |
98 | 132 | func init (leaserAddress) = { | |
99 | 133 | let checks = [mustManager(i), mustNotInited()] | |
100 | 134 | if ((checks == checks)) | |
101 | 135 | then { | |
102 | 136 | let sWaves = Issue("sWaves", "", 0, 8, true, unit, 0) | |
103 | 137 | let sWavesAssetId = calculateAssetId(sWaves) | |
104 | 138 | [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(sWavesAssetId)), StringEntry("leaserAddress", leaserAddress), IntegerEntry("ratio", precision), IntegerEntry("leasedAmount", 0), sWaves] | |
105 | 139 | } | |
106 | 140 | else throw("Strict value is not equal to itself.") | |
107 | 141 | } | |
108 | 142 | ||
109 | 143 | ||
110 | 144 | ||
111 | 145 | @Callable(i) | |
112 | 146 | func stake () = { | |
113 | 147 | let payment = i.payments[0] | |
114 | 148 | if ((payment.assetId != unit)) | |
115 | 149 | then throw("Only WAVES supported") | |
116 | 150 | else if ((size(i.payments) != 1)) | |
117 | 151 | then throw("Wrong payments amount") | |
118 | 152 | else { | |
119 | 153 | let ratio = getIntegerValue("ratio") | |
120 | 154 | let toReissue = fraction(payment.amount, precision, ratio) | |
121 | 155 | ((lease(payment.amount) :+ issueSWaves(toReissue)) :+ sendSWaves(i.caller, toReissue)) | |
122 | 156 | } | |
123 | 157 | } | |
124 | 158 | ||
125 | 159 | ||
126 | 160 | ||
127 | 161 | @Callable(i) | |
128 | 162 | func withdraw () = { | |
129 | 163 | let payment = i.payments[0] | |
130 | 164 | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
131 | 165 | if ((payment.assetId != sWavesAssetId)) | |
132 | 166 | then throw("Only sWAVES supported") | |
133 | 167 | else if ((size(i.payments) != 1)) | |
134 | 168 | then throw("Wrong payments amount") | |
135 | 169 | else { | |
136 | 170 | let ratio = getIntegerValue("ratio") | |
137 | 171 | let toTransfer = fraction(payment.amount, ratio, precision) | |
138 | 172 | ((lease(-(toTransfer)) :+ burnSWaves(payment.amount)) :+ sendWaves(i.caller, toTransfer)) | |
139 | 173 | } | |
140 | 174 | } | |
141 | 175 | ||
142 | 176 | ||
143 | 177 | @Verifier(tx) | |
144 | 178 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
145 | 179 |
github/deemru/w8io/026f985 33.88 ms ◑