tx · BfjixFRijMbyFrua6ujJpJH7BoZ2hW1Ks42VKdBYqKtB

3PBbLJcBjLWUZZrFFUk5s53TdTUneHXDc7e:  -0.00500000 Waves

2023.12.01 15:35 [3933453] smart account 3PBbLJcBjLWUZZrFFUk5s53TdTUneHXDc7e > SELF 0.00000000 Waves

{ "type": 13, "id": "BfjixFRijMbyFrua6ujJpJH7BoZ2hW1Ks42VKdBYqKtB", "fee": 500000, "feeAssetId": null, "timestamp": 1701434121308, "version": 2, "chainId": 87, "sender": "3PBbLJcBjLWUZZrFFUk5s53TdTUneHXDc7e", "senderPublicKey": "qv5sHFvV7GyNRm1A2r8BR9oX2nhkc1yNa1QfWLkaja8", "proofs": [ "4mBL45j9MWmm5M7YHG62h5iHcyVdkt86MzBvrxxLmMXj3JRb1Vxixt7hZp4Z4iWdxVQ7cczWsAeU8JDTWwJqPduR" ], "script": null, "height": 3933453, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BENDQ4yDNTxnTX3TqTXTDHr8XNPt4EDzri3Sb22iVfYC Next: 4UGDFhGW7AeHRNuWKPjWqQJufPNHs7vWDp1jJSAVnQqR Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-func tryGetInteger (address,key) = match getInteger(address, key) {
5- case b: Int =>
6- b
7- case _ =>
8- 0
9-}
10-
11-
12-func tryGetString (address,key) = match getString(address, key) {
13- case b: String =>
14- b
15- case _ =>
16- ""
17-}
18-
19-
20-let d8 = 100000000
21-
22-let d16 = (d8 * d8)
23-
24-let unlockBlock = (30 * 1440)
25-
26-let heirPubKey = base58'2kpmuzw1ZbrtgAN3BrR7vbEW1XrJoJKCstL7mf7XNf2P'
27-
28-let unlockBlock2 = (90 * 1440)
29-
30-let PuzzleMasterPubKey = base58'4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU'
31-
32-let keyActivated = "Activated blockheight"
33-
34-let keySurplusReceived = "surplus received in wavelets"
35-
36-let keyWaveletsReceived = "total WAVES received in wavelets"
37-
38-let keyWaveletsReceivedBT = "total wavelets received for base treasury"
39-
40-let keyWaveletsPaidOut = "total WAVES paid out in wavelets"
41-
42-let keyROI = "ROI basis points"
43-
44-let keyWhirlpoolIssuePrice = "WHIRLPOOL issue price in wavelets"
45-
46-let burnxtnPPTpoolId = base58'3PQHndCUVrv3wBuQjbvVP9SnGmfbfitGxfx'
47-
48-let projectOwner = base58'3PEtLVxDT8mxAh1SDAn8m7JTGNkdpkaFxBk'
49-
50-let whirlpoolPoolId = base58'3P2myTbd5zpEHcYmNpdWTp5gXS5B8tL1RCY'
51-
52-let whirlpool = base58'fHJWWsh2hZAc4Atv8VRhKy3jNbHLeMwQMsLpdaBY51Y'
53-
54-let whirlpoolString = toBase58String(base58'73tY3E6Gd5AWYmsuq8m8Kek7KnJNAYyS3GoveTbc6jCi')
55-
56-let waves = base58'WAVES'
57-
58-let usdterc = base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi'
59-
60-let usdcerc = base58'HGgabTqUS8WtVFUJzfmrTDMgEccJuZLBPhFgQFxvnsoW'
61-
62-let usdtbsc = base58'A81p1LTRyoq2rDR2TNxB2dWYxsiNwCSSi8sXef2SEkwb'
63-
64-let usdcbsc = base58'4BKKSp6NoNcrFHyorZogDyctq1fq6w7114Ym1pw6HUtC'
65-
66-let burnxtn = base58'3SjxA2YLdfF9fTRbzLm9xFn27C6MW34W1YsdJ6Axefns'
67-
68-let eth = base58'3VuV5WTmDz47Dmdn3QpcYjzbSdipjQE4JMdNe1xZpX13'
69-
70-let bnb = base58'66a1br3BrkoaJgP7yEar9hJcSTvJPoH6PYBLqscXcMGo'
71-
72-let wbtc = base58'2Fge5HEBRD3XTeg7Xg3FW5yiB9HVJFQtMXiWMQo72Up6'
73-
74-let btcb = base58'EW1uGLVo21Wd9i2Rhq8o4VKDTCQTGCGXE8DqayHGrLg8'
75-
76-let east = base58'6phK22ztGBW127gUFmdMEHKB3CVd6ZhWox2WtwJkbqTq'
77-
78-let steast = base58'GAB8JowY9UANZ4TQy2TzJyhxjPqXX3DUrb2cdMWrrJus'
79-
80-let swaves = base58'YiNbofFzC17jEHHCMwrRcpy9MrrjabMMLZxg8g5xmf7'
81-
82-let surf = base58'At8D6NFFpheCbvKVnjVoeLL84Eo8NZn6ovManxfLaFWL'
83-
84-let poolboostSC = base58'3P8eeDzUnoDNbQjW617pAe76cEUDQsP1m1V'
85-
86-let PL_Main = Address(base58'3P4uA5etnZi4AmBabKinq2bMiWU8KcnHZdH')
87-
88-let PL_Defi = Address(base58'3P4DK5VzDwL3vfc5ahUEhtoe5ByZNyacJ3X')
89-
90-let PL_Low = Address(base58'3PHpuQUPVUoR3AYzFeJzeWJfYLsLTmWssVH')
91-
92-let EAST_stake = Address(base58'3P2hbtheN5apNppqqUK7L7qAwmRFXy91CNa')
93-
94-let WX_WAVES_EAST = Address(base58'3PJVwjfi2fF5Jv9AauayU6xLxrYBn8bpGH1')
95-
96-let SWAVES_stake = Address(base58'3PDPzZVLhN1EuzGy4xAxjjTVkawKDLEaHiV')
97-
98-let WX_ETH_WAVES = Address(base58'3P2yiVnK48evTLr8MAZWavpE4WA4fw1weQg')
99-
100-let wavesInPool = tryGetInteger(Address(burnxtnPPTpoolId), (("global_" + toBase58String(waves)) + "_balance"))
101-
102-let projectStake = tryGetInteger(Address(burnxtnPPTpoolId), (toString(this) + "_indexStaked"))
103-
104-let totalStake = tryGetInteger(Address(burnxtnPPTpoolId), "global_poolToken_amount")
105-
106-func PL_value (dAppAddress,asset) = fraction(tryGetInteger(dAppAddress, ((toString(this) + "_supplied_") + toBase58String(asset))), tryGetInteger(dAppAddress, (toBase58String(asset) + "_sRate")), d16)
107-
108-
109-func _loadInt (key_,default_) = match getInteger(SWAVES_stake, key_) {
110- case a: Int =>
111- a
112- case _ =>
113- default_
114-}
115-
116-
117-func _loadBigInt (key_,default_) = match getBinary(SWAVES_stake, key_) {
118- case a: ByteVector =>
119- toBigInt(a)
120- case _ =>
121- default_
122-}
123-
124-
125-let lastRate = _loadBigInt("LAST_RATE", toBigInt(1000000000000))
126-
127-let currentRate = _loadBigInt("CURRENT_RATE", toBigInt(0))
128-
129-let lastHeight = _loadInt("LAST_HEIGHT", 0)
130-
131-let targetHeight = min([_loadInt("TARGET_HEIGHT", 0), height])
132-
133-let lastRateUpdated = (lastRate + (currentRate * toBigInt((targetHeight - lastHeight))))
134-
135-let baseAmount = toInt(fraction(toBigInt(assetBalance(WX_WAVES_EAST, swaves)), lastRateUpdated, toBigInt(1000000000000), FLOOR))
136-
137-let baseAmount2 = toInt(fraction(toBigInt(assetBalance(WX_ETH_WAVES, swaves)), lastRateUpdated, toBigInt(1000000000000), FLOOR))
138-
139-let wavesInWX = (wavesBalance(WX_WAVES_EAST).regular + baseAmount)
140-
141-let eastInWX = assetBalance(WX_WAVES_EAST, east)
142-
143-let wavesEast = fraction((d8 * 100), eastInWX, wavesInWX)
144-
145-let waves2InWX = (wavesBalance(WX_ETH_WAVES).regular + baseAmount2)
146-
147-let ethInWX = assetBalance(WX_ETH_WAVES, eth)
148-
149-let ethWaves = fraction(d8, waves2InWX, ethInWX)
150-
151-let wavesInWhirlpool = tryGetInteger(Address(whirlpoolPoolId), (("global_" + toBase58String(waves)) + "_balance"))
152-
153-let whirlInWhirlpool = tryGetInteger(Address(whirlpoolPoolId), (("global_" + whirlpoolString) + "_balance"))
154-
155-let projectStakeWhirl = tryGetInteger(Address(whirlpoolPoolId), (toString(this) + "_indexStaked"))
156-
157-let totalStakeWhirl = tryGetInteger(Address(whirlpoolPoolId), "global_poolToken_amount")
158-
159-let stEastInWaves = (fraction((fraction(assetBalance(this, steast), tryGetInteger(EAST_stake, "%s__rate"), 1000000000000, HALFEVEN) / 100), d8, wavesEast) * 100)
160-
161-let eastInStaking = (fraction(assetBalance(this, steast), tryGetInteger(EAST_stake, "%s__rate"), 1000000000000, HALFEVEN) / 100)
162-
163-let keyVaultAsset = tryGetString(Address(base58'3PMtGnf3LXiEG6isDQLq1xMDKUqjQGqNHLb'), (("%s%s%s__vault__" + toString(this)) + "__WAVES"))
164-
165-let WAVESinEAST = parseIntValue(split(keyVaultAsset, "__")[2])
166-
167-let dAppaddress = Address(base58'3PHxubMUtynEY2AeHq3K1kUizRPN9HUC2rt')
168-
169-let ETHatoken = tryGetInteger(dAppaddress, (toString(this) + "_aTokenBalance"))
170-
171-let ETHatokenTotal = tryGetInteger(dAppaddress, "aTokenCirculation")
172-
173-let reserveStr = tryGetString(dAppaddress, "reserveGlobalData")
174-
175-let get1Str = split(reserveStr, "|")[1]
176-
177-let strToInt = parseIntValue(get1Str)
178-
179-let ETHtotalReserve = parseIntValue(split(tryGetString(dAppaddress, "reserveGlobalData"), "|")[1])
180-
181-let ETHinVires = fraction(ETHatoken, ETHtotalReserve, ETHatokenTotal)
182-
183-let ETHinViresWavelets = fraction(ETHinVires, ethWaves, d8)
184-
185-let tvlInWaves = ((fraction((wavesInPool * 10), projectStake, totalStake) + fraction((wavesInWhirlpool * 10), projectStakeWhirl, totalStakeWhirl)) + ETHinViresWavelets)
186-
187-let totalBT = WAVESinEAST
188-
189-let totalTreasury = (totalBT + tvlInWaves)
190-
191-let whirlpoolSupply = match assetInfo(whirlpool) {
192- case asset: Asset =>
193- asset.quantity
194- case _ =>
195- throw("Can't find asset")
196-}
197-
198-let price = if (((fraction((tvlInWaves + tryGetInteger(this, keySurplusReceived)), d8, whirlpoolSupply) + d8) >= tryGetInteger(this, keyWhirlpoolIssuePrice)))
199- then (fraction((tvlInWaves + tryGetInteger(this, keySurplusReceived)), d8, whirlpoolSupply) + d8)
200- else tryGetInteger(this, keyWhirlpoolIssuePrice)
201-
202-@Callable(i)
203-func buyWHIRLPOOLwithWAVES () = {
204- let WhirlpoolBalanceBefore = assetBalance(this, whirlpool)
205- if ((WhirlpoolBalanceBefore == WhirlpoolBalanceBefore))
206- then {
207- let pmt = value(i.payments[0])
208- let surplus = fraction((price - d8), pmt.amount, d8)
209- let IssueAmount = if ((pmt.amount >= fraction(pmt.amount, d8, price)))
210- then fraction(pmt.amount, d8, price)
211- else throw("please contact project owner: issue amount error")
212- let cleanAmountIn = (pmt.amount - fraction(pmt.amount, 200, 10000))
213- let AmountOut = fraction(whirlInWhirlpool, ((d8 * d8) - toInt(pow(fraction(toBigInt(wavesInWhirlpool), toBigInt((d8 * d8)), toBigInt((wavesInWhirlpool + cleanAmountIn)), HALFUP), 16, toBigInt(fraction(100000, 10000, 900000)), 4, 16, CEILING))), (d8 * d8), DOWN)
214- if (((d8 / 20) > pmt.amount))
215- then throw("minimum payment 0.05 WAVES")
216- else if ((pmt.assetId != unit))
217- then throw("attach WAVES token only")
218- else {
219- let buy = if ((AmountOut > IssueAmount))
220- then invoke(Address(whirlpoolPoolId), "swap", [whirlpoolString, (IssueAmount + 1)], [AttachedPayment(unit, pmt.amount)])
221- else unit
222- if ((buy == buy))
223- then {
224- let WhirlpoolBalanceAfter = assetBalance(this, whirlpool)
225- let WhirlpoolFromSwap = (WhirlpoolBalanceAfter - WhirlpoolBalanceBefore)
226-[Reissue(whirlpool, if ((IssueAmount >= AmountOut))
227- then IssueAmount
228- else 0, true), if ((AmountOut > IssueAmount))
229- then ScriptTransfer(i.caller, WhirlpoolFromSwap, whirlpool)
230- else ScriptTransfer(i.caller, IssueAmount, whirlpool), IntegerEntry(keyWhirlpoolIssuePrice, price), IntegerEntry(if ((AmountOut > IssueAmount))
231- then "price WHIRLPOOL/WAVES"
232- else "WHIRLPOOL/WAVES mid market price", if ((AmountOut > IssueAmount))
233- then fraction(d8, pmt.amount, WhirlpoolFromSwap)
234- else fraction(d8, (wavesInWhirlpool * 9), whirlInWhirlpool)), IntegerEntry(keyWaveletsReceived, if ((IssueAmount >= AmountOut))
235- then (pmt.amount + tryGetInteger(this, keyWaveletsReceived))
236- else tryGetInteger(this, keyWaveletsReceived)), IntegerEntry(keyWaveletsReceived, if ((IssueAmount >= AmountOut))
237- then ((pmt.amount - surplus) + tryGetInteger(this, keyWaveletsReceived))
238- else tryGetInteger(this, keyWaveletsReceived)), IntegerEntry(keySurplusReceived, if ((AmountOut > IssueAmount))
239- then getIntegerValue(this, keySurplusReceived)
240- else (surplus + getIntegerValue(this, keySurplusReceived)))]
241- }
242- else throw("Strict value is not equal to itself.")
243- }
244- }
245- else throw("Strict value is not equal to itself.")
246- }
247-
248-
249-
250-@Callable(i)
251-func priceAndTreasuryStats () = [IntegerEntry("ETH/WAVES price", ethWaves), IntegerEntry("BT WAVES in EAST vault", WAVESinEAST), IntegerEntry("ST BURN-XTN x PepeTeam in wavelets", fraction((wavesInPool * 10), projectStake, totalStake)), IntegerEntry("ST WHIRLPOOL AMM in wavelets", fraction((wavesInWhirlpool * 10), projectStakeWhirl, totalStakeWhirl)), IntegerEntry("ST vETH", ETHinVires), IntegerEntry("ST vETH in wavelets", ETHinViresWavelets), IntegerEntry("Total ST in wavelets", tvlInWaves), IntegerEntry(keyWhirlpoolIssuePrice, price), IntegerEntry("WHIRLPOOL/WAVES mid market price", fraction(d8, (wavesInWhirlpool * 9), whirlInWhirlpool)), IntegerEntry("WHIRLPOOL total supply", whirlpoolSupply), IntegerEntry("Total treasury", totalTreasury), IntegerEntry("NAV WHIRLPOOL", fraction(d8, totalTreasury, whirlpoolSupply)), IntegerEntry(keyWaveletsReceived, tryGetInteger(this, keyWaveletsReceived)), IntegerEntry(keySurplusReceived, tryGetInteger(this, keySurplusReceived)), IntegerEntry(keyWaveletsReceived, tryGetInteger(this, keyWaveletsReceived)), IntegerEntry(keyWaveletsPaidOut, tryGetInteger(this, keyWaveletsPaidOut)), IntegerEntry("total WAVES received", (tryGetInteger(this, keyWaveletsReceived) / d8)), IntegerEntry("Total treasury in WAVES", (totalTreasury / d8)), IntegerEntry("surplus received in WAVES", (tryGetInteger(this, keySurplusReceived) / d8)), IntegerEntry("total WAVES received for base treasury", (tryGetInteger(this, keyWaveletsReceived) / d8)), IntegerEntry("total WAVES paid out in WAVES", (tryGetInteger(this, keyWaveletsPaidOut) / d8)), IntegerEntry(keyROI, tryGetInteger(this, keyROI))]
252-
253-
254-
255-@Callable(i)
256-func boostPoolAPY () = if ((i.caller != this))
257- then throw("access only by project owner")
258- else {
259- let balance = if ((d8 > wavesBalance(this).available))
260- then throw("not enough WAVES")
261- else (wavesBalance(this).available - d8)
262- let boost80 = fraction(balance, 80, 100)
263- if ((boost80 == boost80))
264- then {
265- let amountBoost = fraction(boost80, 80, 100)
266- if ((amountBoost == amountBoost))
267- then {
268- let amountOwner = fraction(boost80, 20, 100)
269- if ((amountOwner == amountOwner))
270- then {
271- let boost = invoke(Address(poolboostSC), "addBoosting", [toBase58String(whirlpoolPoolId), 7], [AttachedPayment(unit, amountBoost)])
272- if ((boost == boost))
273- then [ScriptTransfer(Address(projectOwner), amountOwner, unit), IntegerEntry(keyWaveletsPaidOut, (amountBoost + tryGetInteger(this, keyWaveletsPaidOut))), IntegerEntry(keyROI, fraction(tryGetInteger(this, keyWaveletsPaidOut), 10000, tryGetInteger(this, keyWaveletsReceived))), IntegerEntry(keyActivated, height)]
274- else throw("Strict value is not equal to itself.")
275- }
276- else throw("Strict value is not equal to itself.")
277- }
278- else throw("Strict value is not equal to itself.")
279- }
280- else throw("Strict value is not equal to itself.")
281- }
282-
283-
284-
285-@Callable(i)
286-func boostPoolAPY_all () = if ((i.caller != this))
287- then throw("access only by project owner")
288- else {
289- let balance = if ((d8 > wavesBalance(this).available))
290- then throw("not enough WAVES")
291- else (wavesBalance(this).available - d8)
292- let amountBoost = fraction(balance, 80, 100)
293- if ((amountBoost == amountBoost))
294- then {
295- let amountOwner = fraction(balance, 20, 100)
296- if ((amountOwner == amountOwner))
297- then {
298- let boost = invoke(Address(poolboostSC), "addBoosting", [toBase58String(whirlpoolPoolId), 7], [AttachedPayment(unit, amountBoost)])
299- if ((boost == boost))
300- then [ScriptTransfer(Address(projectOwner), amountOwner, unit), IntegerEntry(keyWaveletsPaidOut, (amountBoost + tryGetInteger(this, keyWaveletsPaidOut))), IntegerEntry(keyROI, fraction(tryGetInteger(this, keyWaveletsPaidOut), 10000, tryGetInteger(this, keyWaveletsReceived))), IntegerEntry(keyActivated, height)]
301- else throw("Strict value is not equal to itself.")
302- }
303- else throw("Strict value is not equal to itself.")
304- }
305- else throw("Strict value is not equal to itself.")
306- }
307-
308-
309-
310-@Callable(i)
311-func transferPoolAPY () = if ((i.caller != this))
312- then throw("access only by project owner")
313- else {
314- let balance = if ((d8 > wavesBalance(this).available))
315- then throw("not enough WAVES")
316- else (wavesBalance(this).available - d8)
317- let boost80 = fraction(balance, 80, 100)
318- if ((boost80 == boost80))
319- then {
320- let amountBoost = fraction(boost80, 80, 100)
321- if ((amountBoost == amountBoost))
322- then {
323- let amountOwner = fraction(boost80, 20, 100)
324- if ((amountOwner == amountOwner))
325- then [ScriptTransfer(Address(whirlpoolPoolId), amountBoost, unit), ScriptTransfer(Address(projectOwner), amountOwner, unit), IntegerEntry(keyWaveletsPaidOut, (amountBoost + tryGetInteger(this, keyWaveletsPaidOut))), IntegerEntry(keyROI, fraction(tryGetInteger(this, keyWaveletsPaidOut), 10000, tryGetInteger(this, keyWaveletsReceived))), IntegerEntry(keyActivated, height)]
326- else throw("Strict value is not equal to itself.")
327- }
328- else throw("Strict value is not equal to itself.")
329- }
330- else throw("Strict value is not equal to itself.")
331- }
332-
333-
334-
335-@Callable(i)
336-func transferPoolAPY_all () = if ((i.caller != this))
337- then throw("access only by project owner")
338- else {
339- let balance = if ((d8 > wavesBalance(this).available))
340- then throw("not enough WAVES")
341- else (wavesBalance(this).available - d8)
342- let amountBoost = fraction(balance, 80, 100)
343- if ((amountBoost == amountBoost))
344- then {
345- let amountOwner = fraction(balance, 20, 100)
346- if ((amountOwner == amountOwner))
347- then [ScriptTransfer(Address(whirlpoolPoolId), amountBoost, unit), ScriptTransfer(Address(projectOwner), amountOwner, unit), IntegerEntry(keyWaveletsPaidOut, (amountBoost + tryGetInteger(this, keyWaveletsPaidOut))), IntegerEntry(keyROI, fraction(tryGetInteger(this, keyWaveletsPaidOut), 10000, tryGetInteger(this, keyWaveletsReceived))), IntegerEntry(keyActivated, height)]
348- else throw("Strict value is not equal to itself.")
349- }
350- else throw("Strict value is not equal to itself.")
351- }
352-
353-
354-
355-@Callable(i)
356-func poolOneTokenSurplus () = if ((i.caller != this))
357- then throw("access only by project owner")
358- else {
359- let surplusAmount = tryGetInteger(this, keySurplusReceived)
360- let PoolOneTokenSurplus = invoke(Address(base58'3PR1Qvi9mHT35SwWEkLSqqE2L8thiPLdVWU'), "generateIndexWithOneTokenAndStake", [toBase58String(burnxtnPPTpoolId)], [AttachedPayment(unit, surplusAmount)])
361- if ((PoolOneTokenSurplus == PoolOneTokenSurplus))
362- then [IntegerEntry(keySurplusReceived, (tryGetInteger(this, keySurplusReceived) - surplusAmount))]
363- else throw("Strict value is not equal to itself.")
364- }
365-
366-
367-
368-@Callable(i)
369-func surplusInvested (amountWAVES) = if ((i.caller != this))
370- then throw("access only by project owner")
371- else {
372- let investedAmount = (amountWAVES * d8)
373-[IntegerEntry(keySurplusReceived, (tryGetInteger(this, keySurplusReceived) - investedAmount))]
374- }
375-
376-
377-
378-@Callable(i)
379-func changeIntegerEntry (keyString,integer) = if ((i.caller != this))
380- then throw("access only by project owner")
381- else [IntegerEntry(keyString, integer)]
382-
383-
384-
385-@Callable(i)
386-func activated () = if ((i.caller != this))
387- then throw("you are not allowed")
388- else [IntegerEntry(keyActivated, height)]
389-
390-
391-@Verifier(tx)
392-func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey))
393- then true
394- else if (((getIntegerValue(this, keyActivated) + unlockBlock) > height))
395- then false
396- else if (sigVerify(tx.bodyBytes, tx.proofs[0], heirPubKey))
397- then true
398- else if (((getIntegerValue(this, keyActivated) + unlockBlock2) > height))
399- then false
400- else sigVerify(tx.bodyBytes, tx.proofs[0], PuzzleMasterPubKey)
401-
1+# no script

github/deemru/w8io/0e76f2f 
43.59 ms