tx · ohpvgop4CtT6XGyHfb3Wk9mpusxeppx6EmACh4Smfym

3N8WSSin2pToGPd2QkoaJMERdKaxzsWc6wb:  -0.05000000 Waves

2023.07.12 15:24 [2662676] smart account 3N8WSSin2pToGPd2QkoaJMERdKaxzsWc6wb > SELF 0.00000000 Waves

{ "type": 13, "id": "ohpvgop4CtT6XGyHfb3Wk9mpusxeppx6EmACh4Smfym", "fee": 5000000, "feeAssetId": null, "timestamp": 1689164703332, "version": 2, "chainId": 84, "sender": "3N8WSSin2pToGPd2QkoaJMERdKaxzsWc6wb", "senderPublicKey": "FchMK5eDR5y83keF9EsE6eb2kCkCT6XPRCs2Nc2esDwp", "proofs": [ "4X7rumSZGAr9DY9Vs8G9x1XgaW3yxynS9MQ8QhPR3taEqjoSrZonXXGRMx2HkcHAethfFNuMNpjj87JT3qpBcAQJ" ], "script": "base64:BgLaBwgCEgUKAwgICBIAEgMKAQESACIDU0VQIglQUkVDSVNJT04iBGpvaW4iAmFyIg5rZXlJbml0aWFsaXplZCIVa2V5Q29vcmRpbmF0b3JBZGRyZXNzIhJrZXlWZXJpZmllckFkZHJlc3MiGWtleVJld2FyZEV4Y2hhbmdlckFkZHJlc3MiEmtleVN1YnZhdWx0QWRkcmVzcyIJa2V5U2lnbmVkIghfYWRkcmVzcyIFX3R4SWQiEWtleVByb3RvY29sQWN0aXZlIg1pc0luaXRpYWxpemVkIhJtdXN0Tm90SW5pdGlhbGl6ZWQiCG11c3RTZWxmIgFpIgtjb29yZGluYXRvciIIdmVyaWZpZXIiByRtYXRjaDAiAXMiCmdldEFkZHJlc3MiA2tleSIDZXJyIhlnZXRSZXdhcmRFeGNoYW5nZXJBZGRyZXNzIghpc0FjdGl2ZSIKbXVzdEFjdGl2ZSISbXVzdEhhdmVPbmVQYXltZW50Igppc1Bvc2l0aXZlIgZudW1iZXIiDGNoZWNrQWRkcmVzcyIHYWRkcmVzcyIQbXVzdFdhdmVzUGF5bWVudCIFY2hlY2siCnBtdEFzc2V0SWQi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mFpBQR1bml0BQNuaWwFAmFpCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJhdQECYXYABAF0CQEBcwADCQABAgUBdAIGU3RyaW5nBAFGBQF0CQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFAUYJAQFqAgkApQgBBQR0aGlzCQDYBAEIBQJhdQJpZAcJAPQDAwgFAmF1CWJvZHlCeXRlcwkAkQMCCAUCYXUGcHJvb2ZzAAAIBQJhdQ9zZW5kZXJQdWJsaWNLZXmV+lrj", "height": 2662676, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let SEP = "__"
5+
6+let PRECISION = 1000000000000
7+
8+func join (ar) = makeString(ar, SEP)
9+
10+
11+func keyInitialized () = join(["%s", "initialized"])
12+
13+
14+func keyCoordinatorAddress () = join(["%s", "coordinatorAddress"])
15+
16+
17+func keyVerifierAddress () = join(["%s", "verifierAddress"])
18+
19+
20+func keyRewardExchangerAddress () = join(["%s", "rewardExchangeAddress"])
21+
22+
23+func keySubvaultAddress () = join(["%s", "subvaultAddress"])
24+
25+
26+func keySigned (_address,_txId) = join(["%s%s%s", "signed", _address, _txId])
27+
28+
29+func keyProtocolActive () = join(["%s", "protocolActive"])
30+
31+
32+func isInitialized () = valueOrElse(getBoolean(this, keyInitialized()), false)
33+
34+
35+func mustNotInitialized () = if (isInitialized())
36+ then throw("Already initialized")
37+ else unit
38+
39+
40+func mustSelf (i) = if ((i.caller != this))
41+ then throw("Only self invocation allowed.")
42+ else unit
43+
44+
45+func coordinator () = addressFromStringValue(valueOrErrorMessage(getString(keyCoordinatorAddress()), "Coordinator is not set"))
46+
47+
48+func verifier () = match getString(keyCoordinatorAddress()) {
49+ case s: String =>
50+ getString(addressFromStringValue(s), keyVerifierAddress())
51+ case _: Unit =>
52+ unit
53+ case _ =>
54+ throw("Match error")
55+}
56+
57+
58+func getAddress (key,err) = addressFromStringValue(valueOrErrorMessage(getString(coordinator(), key), err))
59+
60+
61+func getRewardExchangerAddress () = getAddress(keyRewardExchangerAddress(), "Reward exchanger is not set")
62+
63+
64+func isActive () = valueOrElse(getBoolean(coordinator(), keyProtocolActive()), false)
65+
66+
67+func mustActive () = if (if (!(isActive()))
68+ then true
69+ else !(isInitialized()))
70+ then throw("Protocol is disabled. Please contact support.")
71+ else unit
72+
73+
74+func mustHaveOnePayment (i) = if ((size(i.payments) != 1))
75+ then throw("Must have one payment.")
76+ else unit
77+
78+
79+func isPositive (number) = if ((0 >= number))
80+ then throw("Attribute should be positive.")
81+ else unit
82+
83+
84+func checkAddress (_address) = match addressFromString(_address) {
85+ case address: Address =>
86+ true
87+ case _: Unit =>
88+ throw("Invalid address")
89+ case _ =>
90+ throw("Match error")
91+}
92+
93+
94+func mustWavesPayment (i) = {
95+ let check = mustHaveOnePayment(i)
96+ if ((check == check))
97+ then {
98+ let pmtAssetId = i.payments[0].assetId
99+ match pmtAssetId {
100+ case a: Unit =>
101+ unit
102+ case _ =>
103+ throw("Only WAVES accepted")
104+ }
105+ }
106+ else throw("Strict value is not equal to itself.")
107+ }
108+
109+
110+func keySWavesAddress () = join(["%s", "sWavesAddress"])
111+
112+
113+func keySWavesAsset () = join(["%s", "sWavesAsset"])
114+
115+
116+func keyBalance () = join(["%s", "balance"])
117+
118+
119+func keyTotalProfit () = join(["%s", "totalProfit"])
120+
121+
122+func getSWavesAddressStr () = valueOrErrorMessage(getString(this, keySWavesAddress()), "sWaves address is not set")
123+
124+
125+func sWavesAddress () = addressFromStringValue(getSWavesAddressStr())
126+
127+
128+func getSWavesAssetStr () = valueOrErrorMessage(getString(this, keySWavesAsset()), "sWaves asset is not set")
129+
130+
131+func sWavesAsset () = fromBase58String(getSWavesAssetStr())
132+
133+
134+func getBalance () = valueOrElse(getInteger(keyBalance()), 0)
135+
136+
137+func getTotalProfit () = valueOrElse(getInteger(keyTotalProfit()), 0)
138+
139+
140+func getSubvaultAddressStr () = valueOrErrorMessage(getString(this, keySubvaultAddress()), "Subvault address is not set")
141+
142+
143+func getSubvaultAddress () = addressFromString(getSubvaultAddressStr())
144+
145+
146+func mustSubvault (i) = if ((i.caller != getSubvaultAddress()))
147+ then throw("Not allowed")
148+ else unit
149+
150+
151+func mustExchanger (i) = if ((i.caller != getRewardExchangerAddress()))
152+ then throw("Not allowed")
153+ else unit
154+
155+
156+func sWavesToWithdraw (_amount) = {
157+ let rate = {
158+ let @ = invoke(sWavesAddress(), "getRate", nil, nil)
159+ if ($isInstanceOf(@, "String"))
160+ then @
161+ else throw(($getType(@) + " couldn't be cast to String"))
162+ }
163+ if ((rate == rate))
164+ then toInt(fraction(toBigInt(_amount), toBigInt(PRECISION), parseBigIntValue(rate), CEILING))
165+ else throw("Strict value is not equal to itself.")
166+ }
167+
168+
169+func extractProfit () = {
170+ let sWavesAmount = assetBalance(this, sWavesAsset())
171+ if ((sWavesAmount == sWavesAmount))
172+ then {
173+ let sWavesPayment = AttachedPayment(sWavesAsset(), sWavesAmount)
174+ if ((sWavesPayment == sWavesPayment))
175+ then {
176+ let doWithdraw = invoke(sWavesAddress(), "withdraw", nil, [sWavesPayment])
177+ if ((doWithdraw == doWithdraw))
178+ then {
179+ let wavesActualBalance = wavesBalance(this).regular
180+ if ((wavesActualBalance == wavesActualBalance))
181+ then {
182+ let accountingBalance = getBalance()
183+ if ((accountingBalance == accountingBalance))
184+ then if ((accountingBalance > wavesActualBalance))
185+ then throw("Unable to proceed. Invalid state: wavesActualBalance < accountingBalance")
186+ else {
187+ let profit = (wavesActualBalance - accountingBalance)
188+ if ((profit == profit))
189+ then {
190+ let wavesPayment = AttachedPayment(unit, accountingBalance)
191+ if ((wavesPayment == wavesPayment))
192+ then {
193+ let doDeposit = invoke(sWavesAddress(), "deposit", nil, [wavesPayment])
194+ if ((doDeposit == doDeposit))
195+ then profit
196+ else throw("Strict value is not equal to itself.")
197+ }
198+ else throw("Strict value is not equal to itself.")
199+ }
200+ else throw("Strict value is not equal to itself.")
201+ }
202+ else throw("Strict value is not equal to itself.")
203+ }
204+ else throw("Strict value is not equal to itself.")
205+ }
206+ else throw("Strict value is not equal to itself.")
207+ }
208+ else throw("Strict value is not equal to itself.")
209+ }
210+ else throw("Strict value is not equal to itself.")
211+ }
212+
213+
214+@Callable(i)
215+func initialize (_coordinatorAddress,_subvaultAddress,_sWavesAddress) = {
216+ let checks = [mustSelf(i), mustNotInitialized(), checkAddress(_coordinatorAddress), checkAddress(_subvaultAddress), checkAddress(_sWavesAddress)]
217+ if ((checks == checks))
218+ then {
219+ let sWaves = addressFromStringValue(_sWavesAddress)
220+ let sWavesAssetStr = valueOrErrorMessage(getString(sWaves, "ASSET"), "No sWaves Asset")
221+[StringEntry(keyCoordinatorAddress(), _coordinatorAddress), StringEntry(keySubvaultAddress(), _subvaultAddress), StringEntry(keySWavesAddress(), _sWavesAddress), StringEntry(keySWavesAsset(), sWavesAssetStr), BooleanEntry(keyInitialized(), true)]
222+ }
223+ else throw("Strict value is not equal to itself.")
224+ }
225+
226+
227+
228+@Callable(i)
229+func stake () = {
230+ let checks = [mustActive(), mustSubvault(i), mustWavesPayment(i)]
231+ if ((checks == checks))
232+ then {
233+ let payment = i.payments[0]
234+ let doDeposit = invoke(sWavesAddress(), "deposit", nil, [payment])
235+ if ((doDeposit == doDeposit))
236+ then {
237+ let newAssetBalance = (getBalance() + payment.amount)
238+[IntegerEntry(keyBalance(), newAssetBalance)]
239+ }
240+ else throw("Strict value is not equal to itself.")
241+ }
242+ else throw("Strict value is not equal to itself.")
243+ }
244+
245+
246+
247+@Callable(i)
248+func unstake (_amount) = {
249+ let checks = [mustActive(), mustSubvault(i), isPositive(_amount)]
250+ if ((checks == checks))
251+ then if ((_amount > getBalance()))
252+ then throw("Unable to proceed. Amount larger than balance.")
253+ else {
254+ let newAssetBalance = (getBalance() - _amount)
255+ let sWavesAmount = sWavesToWithdraw(_amount)
256+ if ((sWavesAmount == sWavesAmount))
257+ then {
258+ let payment = AttachedPayment(sWavesAsset(), sWavesAmount)
259+ let doWithdraw = invoke(sWavesAddress(), "withdraw", nil, [payment])
260+ if ((doWithdraw == doWithdraw))
261+ then [IntegerEntry(keyBalance(), newAssetBalance), ScriptTransfer(i.caller, _amount, unit)]
262+ else throw("Strict value is not equal to itself.")
263+ }
264+ else throw("Strict value is not equal to itself.")
265+ }
266+ else throw("Strict value is not equal to itself.")
267+ }
268+
269+
270+
271+@Callable(i)
272+func claimProfit () = {
273+ let checks = [mustActive(), mustExchanger(i)]
274+ if ((checks == checks))
275+ then {
276+ let profit = extractProfit()
277+ if ((profit == profit))
278+ then {
279+ let totalProfit = (getTotalProfit() + profit)
280+ $Tuple2([IntegerEntry(keyTotalProfit(), totalProfit), ScriptTransfer(i.caller, profit, unit)], profit)
281+ }
282+ else throw("Strict value is not equal to itself.")
283+ }
284+ else throw("Strict value is not equal to itself.")
285+ }
286+
287+
288+@Verifier(tx)
289+func verify () = match verifier() {
290+ case address: String =>
291+ valueOrElse(getBoolean(addressFromStringValue(address), keySigned(toString(this), toBase58String(tx.id))), false)
292+ case _ =>
293+ sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
294+}
295+

github/deemru/w8io/026f985 
19.19 ms