tx · 33vDGHWc2Mg7i6Hr1oqm2EL1z79kUrVcBEewdbYR91hD

3MpMsKowU1BqibQgMGvj6wBFUHv3N1vmQUR:  -0.01000000 Waves

2023.09.21 11:07 [2764884] smart account 3MpMsKowU1BqibQgMGvj6wBFUHv3N1vmQUR > SELF 0.00000000 Waves

{ "type": 13, "id": "33vDGHWc2Mg7i6Hr1oqm2EL1z79kUrVcBEewdbYR91hD", "fee": 1000000, "feeAssetId": null, "timestamp": 1695283659094, "version": 2, "chainId": 84, "sender": "3MpMsKowU1BqibQgMGvj6wBFUHv3N1vmQUR", "senderPublicKey": "J4qLv7kHj72gGHRT348ncmmJpznDqXMdtWYTpEyky9KN", "proofs": [ "5TNCoyx7b3r2CzMpLv7dCSuYLRTcXBZnk4fC2WxaZM5QYv8RqMMNuyWqPzSeoBnUnqE1CNKZKQYK2qzX645U3NUy" ], "script": "base64:BgIKCAISABIAEgASAA4ACXd4QXNzZXRJZAEgM1Kp0g5+advMxKQnvIKrDTRAE/WbFcGgKo+DMmTBTQkABk1VTFQxMACAyK+gJQADU0VQAgJfXwAGcG9vbElkAAEAEnBvb2xMUFRva2VuQWRkcmVzcwEgM1Kp0g5+advMxKQnvIKrDTRAE/WbFcGgKo+DMmTBTQkAF3N0YWtlYm9vc3RlclJvb3RBZGRyZXNzARoBVIjFcN5G9OJsOhwdJuqY/GjHC7IJwkxSPQAMYWRtaW5BZGRyZXNzARoBVIxhil+sdwu2jS1p0aM0qMpq9rr6QP5z7QAUdG90YWxQb29sTFBTdGFrZWRLZXkCFHRvdGFsX3Bvb2xfbHBfc3Rha2VkABJ0b3RhbFBvb2xFYXJuZWRLZXkCEXRvdGFsX3Bvb2xfZWFybmVkABVwb29sQ3VycmVudENsYWltSWRLZXkCFXBvb2xfY3VycmVudF9jbGFpbV9pZAEJYXNQYXltZW50AQF2BAckbWF0Y2gwBQF2AwkAAQIFByRtYXRjaDACD0F0dGFjaGVkUGF5bWVudAQBcAUHJG1hdGNoMAUBcAkAAgECI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sRWFybmVkBRZjdXJyZW50Q2xhaW1JZEVhcm5pbmdzBQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5QJos5g==", "height": 2764884, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3Gj1FUriVof63Du6icHoRgGcga8zmFoST67JmjwP4Jku Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let wxAssetId = base58'4TLuEDo8QjPsxUGjfRPyqqvAk4JtnYMXK1ypGo8uKrb2'
55
66 let MULT10 = 10000000000
77
88 let SEP = "__"
99
1010 let poolId = 1
1111
1212 let poolLPTokenAddress = base58'4TLuEDo8QjPsxUGjfRPyqqvAk4JtnYMXK1ypGo8uKrb2'
1313
1414 let stakeboosterRootAddress = base58'3N2PGCSexF2nUN9SmgsaLedFix3M67A9reg'
1515
1616 let adminAddress = base58'3N2iME1bcpy9zdFi2S1rmQDjPvvN5X8t3qW'
1717
1818 let totalPoolLPStakedKey = "total_pool_lp_staked"
1919
2020 let totalPoolEarnedKey = "total_pool_earned"
2121
2222 let poolCurrentClaimIdKey = "pool_current_claim_id"
2323
2424 func asPayment (v) = match v {
2525 case p: AttachedPayment =>
2626 p
2727 case _ =>
2828 throw("fail to cast into AttachedPayment")
2929 }
3030
3131
3232 func asInt (val) = match val {
3333 case valInt: Int =>
3434 valInt
3535 case _ =>
3636 throw("fail to cast into Int")
3737 }
3838
3939
4040 func asString (val) = match val {
4141 case valString: String =>
4242 valString
4343 case _ =>
4444 throw("fail to cast into String")
4545 }
4646
4747
4848 func isUserHaveUnclaimedRewards (address) = if (!(isDefined(getString(address))))
4949 then false
5050 else {
5151 let currentPoolClaimId = getIntegerValue(poolCurrentClaimIdKey)
5252 let userData = split(getStringValue(address), SEP)
5353 let userLastClaimedRewardsAtPoolClaimId = asInt(parseInt(userData[2]))
5454 (currentPoolClaimId > userLastClaimedRewardsAtPoolClaimId)
5555 }
5656
5757
5858 @Callable(i)
5959 func stakeLP () = if ((size(i.payments) != 1))
6060 then throw("One Payment expected")
6161 else {
6262 let callerAddress = toBase58String(i.caller.bytes)
6363 let payment = asPayment(i.payments[0])
6464 if (isUserHaveUnclaimedRewards(callerAddress))
6565 then throw("You have unclaimed rewards on contract, claim them first")
6666 else {
6767 let currentTotalPoolClaimId = valueOrElse(getInteger(poolCurrentClaimIdKey), 0)
6868 let currentTotalPoolLPStaked = valueOrElse(getInteger(totalPoolLPStakedKey), 0)
6969 let currentTotalPoolEarned = valueOrElse(getInteger(totalPoolEarnedKey), 0)
7070 let result = invoke(Address(stakeboosterRootAddress), "stakePoolLps", [poolId], [payment])
7171 if ((result == result))
7272 then {
7373 let userDataOpt = getString(callerAddress)
7474 let userData = if (isDefined(userDataOpt))
7575 then {
7676 let userData = split(asString(userDataOpt), SEP)
7777 let userTotalStakedAmount = asInt(parseInt(userData[0]))
7878 let newUserData = [toString((userTotalStakedAmount + payment.amount)), removeByIndex(userData, 0)]
7979 makeString(newUserData, SEP)
8080 }
8181 else makeString([toString(payment.amount), "0", toString(currentTotalPoolClaimId), toString(currentTotalPoolEarned)], SEP)
8282 [StringEntry(callerAddress, userData), IntegerEntry(poolCurrentClaimIdKey, currentTotalPoolClaimId), IntegerEntry(totalPoolEarnedKey, currentTotalPoolEarned), IntegerEntry(totalPoolLPStakedKey, (currentTotalPoolLPStaked + payment.amount))]
8383 }
8484 else throw("Strict value is not equal to itself.")
8585 }
8686 }
8787
8888
8989
9090 @Callable(i)
9191 func withdrawLP () = {
9292 let callerAddress = toBase58String(i.caller.bytes)
9393 if (isUserHaveUnclaimedRewards(callerAddress))
9494 then throw("You have unclaimed rewards on contract, claim them first")
9595 else nil
9696 }
9797
9898
9999
100100 @Callable(i)
101101 func claimRewards () = {
102102 let callerAddress = toBase58String(i.caller.bytes)
103103 if (!(isUserHaveUnclaimedRewards(callerAddress)))
104104 then throw("Nothing to claim, wait for a while, pool will collect the rewards from WX soon")
105105 else {
106106 let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey)
107107 let totalPoolEarned = getIntegerValue(totalPoolEarnedKey)
108108 let userData = split(getStringValue(callerAddress), SEP)
109109 let userTotalLPStaked = asInt(parseInt(userData[0]))
110110 let userTotalRewardsClaimed = asInt(parseInt(userData[1]))
111111 let userLastClaimPoolClaimId = asInt(parseInt(userData[2]))
112112 let poolEarnedRewardsWithoutUser = asInt(parseInt(userData[3]))
113113 let totalPoolEarningsWithUser = (totalPoolEarned - poolEarnedRewardsWithoutUser)
114114 let userTotalClaim = fraction(totalPoolEarningsWithUser, userTotalLPStaked, MULT10)
115115 let userAvailableClaim = (userTotalClaim - userTotalRewardsClaimed)
116116 let newUserData = makeString([userData[0], toString((userTotalRewardsClaimed + userAvailableClaim)), toString(poolCurrentClaimId), userData[3]], SEP)
117117 [StringEntry(callerAddress, newUserData), ScriptTransfer(i.caller, userAvailableClaim, wxAssetId)]
118118 }
119119 }
120120
121121
122122
123123 @Callable(i)
124124 func claimPoolRewards () = if ((i.caller.bytes != adminAddress))
125125 then throw("Admin only")
126126 else {
127127 let totalPoolLPStaked = getIntegerValue(totalPoolLPStakedKey)
128128 let totalPoolEarned = getIntegerValue(totalPoolEarnedKey)
129129 let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey)
130130 let currentWxOnContract = assetBalance(this, wxAssetId)
131131 if ((currentWxOnContract == currentWxOnContract))
132132 then {
133133 let result = invoke(Address(stakeboosterRootAddress), "claimPoolRewards", [poolId], nil)
134134 if ((result == result))
135135 then {
136136 let newWxOnContract = assetBalance(this, wxAssetId)
137137 let claimedWxAmount = (newWxOnContract - currentWxOnContract)
138138 let currentClaimIdEarnings = fraction(claimedWxAmount, MULT10, totalPoolLPStaked)
139139 [IntegerEntry("CURRENT_WX_ON_CONTRACT", currentWxOnContract), IntegerEntry("NEW_WX_ON_CONTRACT", newWxOnContract), IntegerEntry(poolCurrentClaimIdKey, (poolCurrentClaimId + 1)), IntegerEntry(totalPoolEarnedKey, (totalPoolEarned + currentClaimIdEarnings))]
140140 }
141141 else throw("Strict value is not equal to itself.")
142142 }
143143 else throw("Strict value is not equal to itself.")
144144 }
145145
146146
147147 @Verifier(tx)
148148 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
149149

github/deemru/w8io/169f3d6 
35.10 ms