tx · GJgHWHssEwXM3uEng789AxfCXnvBHtpa3oYkfh164TtW

3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh:  -0.00800000 Waves

2022.11.30 20:35 [2340142] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves

{ "type": 13, "id": "GJgHWHssEwXM3uEng789AxfCXnvBHtpa3oYkfh164TtW", "fee": 800000, "feeAssetId": null, "timestamp": 1669829740531, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "2MpUXTtGS2RgYQ6TBFi9WZcEZ5Tp3PztEEw32mk3J6kKM9Lqd4tJ8wNG7YMWCY5Cch2HCuN6mjh5RY1LeMn1NWTe" ], "script": "base64:BgIJCAISAwoBCBIAEgAGU2NhbGU2AMCEPQAGU2NhbGU4AIDC1y8AB1NjYWxlMTYJAGgCBQZTY2FsZTgFBlNjYWxlOAAKdmFsaWRhdG9ycwkAzAgCAiMzTkFtcUdqeFJCUlBvUkhaVVVxdmhpTlM2YXhuR3BpbkxIQwUDbmlsAAdhc3NldElkAixISG1hRlFwVW9id0t4emp6NEVDYUJQdG9GNjlrdWpLd1UyY296YVV6VHNndgALcHV6emxlUG9vbHMJAMwIAgIjM042U3RKZGdtVGZBUnNSTm45WHQ1ckRZRXMzcHI0S0d5MXYFA25pbAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgRVbml0BAF4BQckbWF0Y2gwCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQkA8AcCBQR0aGlzCQEFdmFsdWUBBQdhc3NldElkAQl0cnlHZXRJbnQCB2FkZHJlc3MDa2V5BAckbWF0Y2gwCQCaCAIFB2FkZHJlc3MFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtY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FCnZhbGlkYXRvcnMJAKUIAQgFAWkGY2FsbGVyBQR1bml0CQACAQINQWNjZXNzIGRlbmllZAMJAAACBQtjdXJyZW50UG9vbAUGcG9vbElkCQACAQkArAICAhNBbHJlYWR5IHN1cHBsaWVkIHRvBQtjdXJyZW50UG9vbAQKd2l0aGRyYXdUeAkBDndpdGhkcmF3UmVzdWx0AAMJAAACBQp3aXRoZHJhd1R4BQp3aXRoZHJhd1R4CQDOCAIJAQxzdXBwbHlSZXN1bHQBBQZwb29sSWQJAQxyZWNhbGNSZXN1bHQBAAAJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BaQEFc3Rha2UABAR1c2VyCQClCAEIBQFpBmNhbGxlcgQGYW1vdW50CAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAQLY3VycmVudFBvb2wJAQl0cnlHZXRTdHICBQR0aGlzAgtjdXJyZW50UG9vbAMDCQBnAgAABQZhbW91bnQGCQECIT0CCAkAkQMCCAUBaQhwYXltZW50cwAAB2Fzc2V0SWQJANkEAQUHYXNzZXRJZAkAAgECFmludmFsaWQgdG9rZW4gYXR0YWNoZWQDCQAAAgULY3VycmVudFBvb2wCAAkAAgECFFBvb2wgbm90IGluaXRpYWxpemVkCQDOCAIJAQtzdGFrZVJlc3VsdAIFBHVzZXIFBmFtb3VudAkBDHN1cHBseVJlc3VsdAEFC2N1cnJlbnRQb29sAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleSz35Ew=", "height": 2340142, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9nFkN9cAaP6JP4nE4HasH9i22D1swvkewz8zFJKLStZS Next: G3MuSEZ7UCSPQw5t9jCEnG9uKotau9x64PZjbQtw6Po Diff:
OldNewDifferences
77
88 let Scale16 = (Scale8 * Scale8)
99
10-let validators = [""]
10+let validators = ["3NAmqGjxRBRPoRHZUUqvhiNS6axnGpinLHC"]
1111
1212 let assetId = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv"
1313
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let Scale6 = 1000000
55
66 let Scale8 = 100000000
77
88 let Scale16 = (Scale8 * Scale8)
99
10-let validators = [""]
10+let validators = ["3NAmqGjxRBRPoRHZUUqvhiNS6axnGpinLHC"]
1111
1212 let assetId = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv"
1313
1414 let puzzlePools = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"]
1515
1616 func getBalance (assetId) = match assetId {
1717 case x: Unit =>
1818 wavesBalance(this).available
1919 case _ =>
2020 assetBalance(this, value(assetId))
2121 }
2222
2323
2424 func tryGetInt (address,key) = match getInteger(address, key) {
2525 case b: Int =>
2626 b
2727 case _ =>
2828 0
2929 }
3030
3131
3232 func tryGetStr (address,key) = match getString(address, key) {
3333 case b: String =>
3434 b
3535 case _ =>
3636 ""
3737 }
3838
3939
4040 func getAssetString (assetId) = match assetId {
4141 case b: ByteVector =>
4242 toBase58String(b)
4343 case _ =>
4444 "WAVES"
4545 }
4646
4747
4848 func getPuzzlePoolSuppliedAmount (poolId) = {
4949 let balance = assetBalance(Address(fromBase58String(poolId)), fromBase58String(assetId))
5050 balance
5151 }
5252
5353
5454 func getTotalSuppliedAmount () = {
5555 let currentPool = tryGetStr(this, "currentPool")
5656 if ((currentPool == ""))
5757 then throw(("Cannot find pool with id " + currentPool))
5858 else getPuzzlePoolSuppliedAmount(currentPool)
5959 }
6060
6161
6262 func withdrawFromPuzzlePool (poolId,amount) = {
6363 let poolAddress = Address(fromBase58String(poolId))
6464 let withdrawTx = if ((amount > 0))
6565 then invoke(poolAddress, "withdraw", [assetId, amount], nil)
6666 else ""
6767 if ((withdrawTx == withdrawTx))
6868 then withdrawTx
6969 else throw("Strict value is not equal to itself.")
7070 }
7171
7272
7373 func calculateSRate () = {
7474 let lastCheckSRate = tryGetInt(this, "global_lastCheckSRate")
7575 let stakedAmount = tryGetInt(this, "global_staked")
7676 let lastCheckHeight = tryGetInt(this, "global_lastCheckSRateHeight")
7777 let blocks = (height - lastCheckHeight)
7878 let stakingEmission = (getTotalSuppliedAmount() - fraction(stakedAmount, lastCheckSRate, Scale8))
7979 if ((stakedAmount == 0))
8080 then Scale8
8181 else {
8282 let sRate = (lastCheckSRate + fraction((blocks * Scale8), stakingEmission, stakedAmount))
8383 if ((Scale8 > sRate))
8484 then Scale8
8585 else sRate
8686 }
8787 }
8888
8989
9090 func recalcResult (stakedChange) = {
9191 let stakedAmount = tryGetInt(this, "global_staked")
9292 let sRate = calculateSRate()
9393 [IntegerEntry("global_staked", (stakedAmount + stakedChange)), IntegerEntry("global_lastCheckSRate", sRate), IntegerEntry("global_lastCheckSRateHeight", height)]
9494 }
9595
9696
9797 func supplyResult (poolId) = if ((indexOf(puzzlePools, poolId) == unit))
9898 then throw(("Unknown poolId " + poolId))
9999 else {
100100 let assetBytes = fromBase58String(assetId)
101101 let balance = getBalance(assetBytes)
102102 let inv = invoke(Address(fromBase58String(poolId)), "supply", nil, [AttachedPayment(assetBytes, balance)])
103103 if ((inv == inv))
104104 then [StringEntry("currentPool", poolId)]
105105 else throw("Strict value is not equal to itself.")
106106 }
107107
108108
109109 func withdrawResult () = {
110110 let currentPool = tryGetStr(this, "currentPool")
111111 if ((currentPool == ""))
112112 then throw(("Cannot find pool with id " + currentPool))
113113 else {
114114 let amount = getPuzzlePoolSuppliedAmount(currentPool)
115115 let tx = withdrawFromPuzzlePool(currentPool, amount)
116116 if ((tx == tx))
117117 then tx
118118 else throw("Strict value is not equal to itself.")
119119 }
120120 }
121121
122122
123123 func stakeResult (user,amount) = {
124124 let sAmount = fraction(amount, Scale8, calculateSRate())
125125 (recalcResult(sAmount) ++ [IntegerEntry((user + "_staked"), (tryGetInt(this, (user + "_staked")) + sAmount))])
126126 }
127127
128128
129129 @Callable(i)
130130 func rebalance (poolId) = {
131131 let currentPool = tryGetStr(this, "currentPool")
132132 if ((indexOf(validators, toString(i.caller)) == unit))
133133 then throw("Access denied")
134134 else if ((currentPool == poolId))
135135 then throw(("Already supplied to" + currentPool))
136136 else {
137137 let withdrawTx = withdrawResult()
138138 if ((withdrawTx == withdrawTx))
139139 then (supplyResult(poolId) ++ recalcResult(0))
140140 else throw("Strict value is not equal to itself.")
141141 }
142142 }
143143
144144
145145
146146 @Callable(i)
147147 func stake () = {
148148 let user = toString(i.caller)
149149 let amount = i.payments[0].amount
150150 let currentPool = tryGetStr(this, "currentPool")
151151 if (if ((0 >= amount))
152152 then true
153153 else (i.payments[0].assetId != fromBase58String(assetId)))
154154 then throw("invalid token attached")
155155 else if ((currentPool == ""))
156156 then throw("Pool not initialized")
157157 else (stakeResult(user, amount) ++ supplyResult(currentPool))
158158 }
159159
160160
161161 @Verifier(tx)
162162 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
163163

github/deemru/w8io/169f3d6 
26.48 ms