tx · A23uyJcPFbSeJSK1YvxF1druv295S4vMd9oPuLYTUvMJ

3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH:  -0.03400000 Waves

2022.11.25 19:32 [2332867] smart account 3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH > SELF 0.00000000 Waves

{ "type": 13, "id": "A23uyJcPFbSeJSK1YvxF1druv295S4vMd9oPuLYTUvMJ", "fee": 3400000, "feeAssetId": null, "timestamp": 1669394020376, "version": 2, "chainId": 84, "sender": "3NADcxHXbecCheinqFbvhDjfzZhsMFZJUuH", "senderPublicKey": "DKfzQgvVdTqPHgGbdZptWYA8G5xVfmSMAwL3UnhwQmdy", "proofs": [ "3AKVucqfD7PxPFgB8WaCBMY7t1bCvFy6ezxYCZat82JCTgJJGB31hMsyhQ4ez9YVsViZ8G7ayuxNwAvLU2oBCLEH" ], "script": "base64:BgIhCAISAwoBCBIAEgMKAQESABIAEgMKAQESAwoBARIDCgEILwANa190b3RhbFN1cHBseQINa190b3RhbFN1cHBseQAPa19sb2NrZWRCYWxhbmNlAg9rX2xvY2tlZEJhbGFuY2UADWtfZnJlZUJhbGFuY2UCDWtfZnJlZUJhbGFuY2UABmtfcmF0ZQIGa19yYXRlAAlrX2JhbGFuY2UCCWtfYmFsYW5jZQAOa19hdmVyYWdlX3JhdGUCDmtfYXZlcmFnZV9yYXRlAA9rX3dpdGhkcmF3X3JhdGUCD2tfd2l0aGRyYXdfcmF0ZQANa19pbml0aWFsaXplZAINa19pbml0aWFsaXplZAAUa19jb29yZGluYXRvckFkZHJlc3MCFGtfY29vcmRpbmF0b3JBZGRyZXNzAAVrX2FtbQIFa19hbW0ADWtfcXVvdGVfYXNzZXQCDWtfcXVvdGVfYXNzZXQAEmtfYWRtaW5fcHVibGljX2tleQISa19hZG1pbl9wdWJsaWNfa2V5AA9rX2FkbWluX2FkZHJlc3MCD2tfYWRtaW5fYWRkcmVzcwARa19tYW5hZ2VyX2FkZHJlc3MCEWtfbWFuYWdlcl9hZGR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AS0BBRJhbW91bnRPZlF1b3RlQXNzZXQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyBQdfYW1vdW50CQEKcXVvdGVBc3NldAAFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQt2aWV3X3Jld2FyZAEHX3RyYWRlcgQHYmFsYW5jZQkBCWJhbGFuY2VPZgEFB190cmFkZXIED2RlcG9zaXRlZEFtb3VudAkBBG11bGQCCQELYXZlcmFnZVJhdGUBBQdfdHJhZGVyBQdiYWxhbmNlBA1jdXJyZW50QW1vdW50CQEEbXVsZAIJAQRyYXRlAAUHYmFsYW5jZQQGZWFybmVkCQBlAgUNY3VycmVudEFtb3VudAUPZGVwb3NpdGVkQW1vdW50CQACAQkApAMBBQZlYXJuZWQBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACQEOYWRtaW5QdWJsaWNLZXkA82JmFQ==", "height": 2332867, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: CePWAsvbqcM4ypm1268t74p7MsF7Bo5GFNqxSfGUZCej Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let k_totalSupply = "k_totalSupply"
5+
6+let k_lockedBalance = "k_lockedBalance"
7+
8+let k_freeBalance = "k_freeBalance"
9+
10+let k_rate = "k_rate"
11+
12+let k_balance = "k_balance"
13+
14+let k_average_rate = "k_average_rate"
15+
16+let k_withdraw_rate = "k_withdraw_rate"
17+
18+let k_initialized = "k_initialized"
19+
20+let k_coordinatorAddress = "k_coordinatorAddress"
21+
22+let k_amm = "k_amm"
23+
24+let k_quote_asset = "k_quote_asset"
25+
26+let k_admin_public_key = "k_admin_public_key"
27+
28+let k_admin_address = "k_admin_address"
29+
30+let k_manager_address = "k_manager_address"
31+
32+func toCompositeKey (_key,_address) = ((_key + "_") + _address)
33+
34+
35+func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
36+
37+
38+func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
39+
40+
41+func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
42+
43+
44+func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set"))
45+
46+
47+func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
48+
49+
50+func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set")
51+
52+
53+let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10))
54+
55+let DURATION = ((60 * 60) * 24)
56+
57+let NO_ADDRESS = ""
58+
59+let NO_STAKER = 0
60+
61+func usdnFromDecimals (_amount) = (_amount / 100)
62+
63+
64+func usdnToDecimals (_amount) = (_amount * 100)
65+
66+
67+func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
68+
69+
70+func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
71+
72+
73+func abs (_x) = if ((_x > 0))
74+ then _x
75+ else -(_x)
76+
77+
78+func minv (_x,_y) = if ((_x > _y))
79+ then _y
80+ else _x
81+
82+
83+func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
84+
85+
86+func int0 (k) = valueOrElse(getInteger(this, k), 0)
87+
88+
89+func int1 (k) = valueOrElse(getInteger(this, k), DECIMAL_UNIT)
90+
91+
92+func totalSupply () = int0(k_totalSupply)
93+
94+
95+func rate () = int1(k_rate)
96+
97+
98+func balanceOf (_staker) = int0(toCompositeKey(k_balance, _staker))
99+
100+
101+func averageRate (_staker) = int0(toCompositeKey(k_average_rate, _staker))
102+
103+
104+func freeBalance () = int0(k_freeBalance)
105+
106+
107+func lockedBalance () = int0(k_lockedBalance)
108+
109+
110+func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
111+
112+
113+func updateUserBalance (_user,_change) = [IntegerEntry(toCompositeKey(k_balance, _user), (balanceOf(_user) + _change))]
114+
115+
116+func updateUserAverageRate (_user,_rate) = [IntegerEntry(toCompositeKey(k_average_rate, _user), _rate)]
117+
118+
119+func updateFreeBalance (_change) = [IntegerEntry(k_freeBalance, (freeBalance() + _change))]
120+
121+
122+func updateLockedBalance (_change) = [IntegerEntry(k_lockedBalance, (lockedBalance() + _change))]
123+
124+
125+func updateTotalSupply (_change) = [IntegerEntry(k_totalSupply, (totalSupply() + _change))]
126+
127+
128+func updateRate (_rate) = [IntegerEntry(k_rate, _rate)]
129+
130+
131+@Callable(i)
132+func initialize (_coordinator) = if (initialized())
133+ then throw("Already initialized")
134+ else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)]
135+
136+
137+
138+@Callable(i)
139+func stake () = {
140+ let _staker = toString(i.caller)
141+ let _amount = i.payments[0].amount
142+ if (if ((i.payments[0].assetId != quoteAsset()))
143+ then true
144+ else !(initialized()))
145+ then throw("Invalid call to stake")
146+ else {
147+ let currentRate = rate()
148+ let prevAverageRate = averageRate(_staker)
149+ let vAmount = divd(usdnToDecimals(_amount), currentRate)
150+ let newAverageRate = divd((muld(vAmount, currentRate) + muld(balanceOf(_staker), prevAverageRate)), (currentRate + prevAverageRate))
151+ let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
152+ if ((unstake == unstake))
153+ then (((updateFreeBalance(_amount) ++ updateUserBalance(_staker, vAmount)) ++ updateUserAverageRate(_staker, newAverageRate)) ++ updateTotalSupply(vAmount))
154+ else throw("Strict value is not equal to itself.")
155+ }
156+ }
157+
158+
159+
160+@Callable(i)
161+func unStake (_vAmount) = {
162+ let _staker = toString(i.caller)
163+ if (if (if ((_vAmount > balanceOf(_staker)))
164+ then true
165+ else (i.payments != nil))
166+ then true
167+ else !(initialized()))
168+ then throw("Invalid call to unStake")
169+ else {
170+ let amountOfQuoteAsset = muld(_vAmount, rate())
171+ if ((freeBalance() > amountOfQuoteAsset))
172+ then throw("Balance to low")
173+ else {
174+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), usdnFromDecimals(amountOfQuoteAsset)], nil)
175+ if ((unstake == unstake))
176+ then (((updateFreeBalance(-(amountOfQuoteAsset)) ++ updateUserBalance(_staker, -(_vAmount))) ++ updateTotalSupply(-(_vAmount))) ++ [ScriptTransfer(i.caller, usdnFromDecimals(amountOfQuoteAsset), quoteAsset())])
177+ else throw("Strict value is not equal to itself.")
178+ }
179+ }
180+ }
181+
182+
183+
184+@Callable(i)
185+func addFree () = {
186+ let _amount = i.payments[0].amount
187+ if (if (if ((i.payments[0].assetId != quoteAsset()))
188+ then true
189+ else !(initialized()))
190+ then true
191+ else !(if (isWhitelist(toString(i.caller)))
192+ then true
193+ else (i.caller == adminAddress())))
194+ then throw("Invalid addFree params")
195+ else {
196+ let amountOfQuoteAsset = usdnToDecimals(_amount)
197+ let newRate = if ((totalSupply() > 0))
198+ then divd((freeBalance() + amountOfQuoteAsset), totalSupply())
199+ else DECIMAL_UNIT
200+ let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
201+ if ((unstake == unstake))
202+ then (updateFreeBalance(amountOfQuoteAsset) ++ updateRate(newRate))
203+ else throw("Strict value is not equal to itself.")
204+ }
205+ }
206+
207+
208+
209+@Callable(i)
210+func addLocked () = {
211+ let _amount = i.payments[0].amount
212+ if (if (if ((i.payments[0].assetId != quoteAsset()))
213+ then true
214+ else !(initialized()))
215+ then true
216+ else !(if (isWhitelist(toString(i.caller)))
217+ then true
218+ else (i.caller == adminAddress())))
219+ then throw("Invalid addLocked params")
220+ else {
221+ let amountOfQuoteAsset = usdnToDecimals(_amount)
222+ let unstake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
223+ if ((unstake == unstake))
224+ then updateLockedBalance(amountOfQuoteAsset)
225+ else throw("Strict value is not equal to itself.")
226+ }
227+ }
228+
229+
230+
231+@Callable(i)
232+func exchangeFreeAndLocked (_amount) = if (if (!(initialized()))
233+ then true
234+ else !(if (isWhitelist(toString(i.caller)))
235+ then true
236+ else (i.caller == adminAddress())))
237+ then throw("Invalid exchangeFreeAndLocked params")
238+ else {
239+ let amountOfQuoteAsset = usdnToDecimals(_amount)
240+ let newRate = if ((totalSupply() > 0))
241+ then divd((freeBalance() - amountOfQuoteAsset), totalSupply())
242+ else DECIMAL_UNIT
243+ ((updateLockedBalance(amountOfQuoteAsset) ++ updateFreeBalance(-(amountOfQuoteAsset))) ++ updateRate(newRate))
244+ }
245+
246+
247+
248+@Callable(i)
249+func withdrawLocked (_amount) = if (if (if (!(initialized()))
250+ then true
251+ else (0 >= _amount))
252+ then true
253+ else !(isWhitelist(toString(i.caller))))
254+ then throw("Invalid withdrawLocked params")
255+ else {
256+ let amountOfQuoteAsset = usdnToDecimals(_amount)
257+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil)
258+ if ((unstake == unstake))
259+ then (updateLockedBalance(-(amountOfQuoteAsset)) ++ [ScriptTransfer(i.caller, _amount, quoteAsset())])
260+ else throw("Strict value is not equal to itself.")
261+ }
262+
263+
264+
265+@Callable(i)
266+func view_reward (_trader) = {
267+ let balance = balanceOf(_trader)
268+ let depositedAmount = muld(averageRate(_trader), balance)
269+ let currentAmount = muld(rate(), balance)
270+ let earned = (currentAmount - depositedAmount)
271+ throw(toString(earned))
272+ }
273+
274+
275+@Verifier(tx)
276+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
277+

github/deemru/w8io/169f3d6 
24.95 ms