tx · 32tXatg2WK2ghkUCLQKfH8jsfn3a2sUBwraKYXmZb1CX 3MyNtNaUpXUhUnrrebTTMtez8gjR68G5ZXZ: -0.01000000 Waves 2023.09.21 11:35 [2764908] smart account 3MyNtNaUpXUhUnrrebTTMtez8gjR68G5ZXZ > SELF 0.00000000 Waves
{ "type": 13, "id": "32tXatg2WK2ghkUCLQKfH8jsfn3a2sUBwraKYXmZb1CX", "fee": 1000000, "feeAssetId": null, "timestamp": 1695285218067, "version": 2, "chainId": 84, "sender": "3MyNtNaUpXUhUnrrebTTMtez8gjR68G5ZXZ", "senderPublicKey": "BKqibw8SSGuuMGSzbqvEU3EQy98znGV6NbQ16tX5CoMf", "proofs": [ "2cPHXQEoWTQnKDZ1iZFiKsETd2WaHuG3gvesSWZuVumUmrWkCxCgwyFerd2T4TJitHt8cyEMp4X9TieF31SKgLxB" ], "script": "base64:BgIKCAISABIAEgASAA4ACXd4QXNzZXRJZAEgM1Kp0g5+advMxKQnvIKrDTRAE/WbFcGgKo+DMmTBTQkABk1VTFQxMACAyK+gJQADU0VQAgJfXwAGcG9vbElkAAEAEnBvb2xMUFRva2VuQWRkcmVzcwEgM1Kp0g5+advMxKQnvIKrDTRAE/WbFcGgKo+DMmTBTQkAF3N0YWtlYm9vc3RlclJvb3RBZGRyZXNzARoBVIjFcN5G9OJsOhwdJuqY/GjHC7IJwkxSPQAMYWRtaW5BZGRyZXNzARoBVIxhil+sdwu2jS1p0aM0qMpq9rr6QP5z7QAUdG90YWxQb29sTFBTdGFrZWRLZXkCFHRvdGFsX3Bvb2xfbHBfc3Rha2VkABJ0b3RhbFBvb2xFYXJuZWRLZXkCEXRvdGFsX3Bvb2xfZWFybmVkABVwb29sQ3VycmVudENsYWltSWRLZXkCFXBvb2xfY3VycmVudF9jbGFpbV9pZAEJYXNQYXltZW50AQF2BAckbWF0Y2gwBQF2AwkAAQIFByRtYXRjaDACD0F0dGFjaGVkUGF5bWVudAQBcAUHJG1hdGNoMAUBcAkAAgECIWZ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bFBvb2xFYXJuZWQFFmN1cnJlbnRDbGFpbUlkRWFybmluZ3MFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXn57HA1", "height": 2764908, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let wxAssetId = base58'4TLuEDo8QjPsxUGjfRPyqqvAk4JtnYMXK1ypGo8uKrb2' | |
5 | + | ||
6 | + | let MULT10 = 10000000000 | |
7 | + | ||
8 | + | let SEP = "__" | |
9 | + | ||
10 | + | let poolId = 1 | |
11 | + | ||
12 | + | let poolLPTokenAddress = base58'4TLuEDo8QjPsxUGjfRPyqqvAk4JtnYMXK1ypGo8uKrb2' | |
13 | + | ||
14 | + | let stakeboosterRootAddress = base58'3N2PGCSexF2nUN9SmgsaLedFix3M67A9reg' | |
15 | + | ||
16 | + | let adminAddress = base58'3N2iME1bcpy9zdFi2S1rmQDjPvvN5X8t3qW' | |
17 | + | ||
18 | + | let totalPoolLPStakedKey = "total_pool_lp_staked" | |
19 | + | ||
20 | + | let totalPoolEarnedKey = "total_pool_earned" | |
21 | + | ||
22 | + | let poolCurrentClaimIdKey = "pool_current_claim_id" | |
23 | + | ||
24 | + | func asPayment (v) = match v { | |
25 | + | case p: AttachedPayment => | |
26 | + | p | |
27 | + | case _ => | |
28 | + | throw("fail to cast into AttachedPayment") | |
29 | + | } | |
30 | + | ||
31 | + | ||
32 | + | func asInt (val) = match val { | |
33 | + | case valInt: Int => | |
34 | + | valInt | |
35 | + | case _ => | |
36 | + | throw("fail to cast into Int") | |
37 | + | } | |
38 | + | ||
39 | + | ||
40 | + | func asString (val) = match val { | |
41 | + | case valString: String => | |
42 | + | valString | |
43 | + | case _ => | |
44 | + | throw("fail to cast into String") | |
45 | + | } | |
46 | + | ||
47 | + | ||
48 | + | func isUserHaveUnclaimedRewards (address) = if (!(isDefined(getString(address)))) | |
49 | + | then false | |
50 | + | else { | |
51 | + | let currentPoolClaimId = getIntegerValue(poolCurrentClaimIdKey) | |
52 | + | let userData = split(getStringValue(address), SEP) | |
53 | + | let userLastClaimedRewardsAtPoolClaimId = asInt(parseInt(userData[2])) | |
54 | + | (currentPoolClaimId > userLastClaimedRewardsAtPoolClaimId) | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | @Callable(i) | |
59 | + | func stakeLP () = if ((size(i.payments) != 1)) | |
60 | + | then throw("One Payment expected") | |
61 | + | else { | |
62 | + | let callerAddress = toBase58String(i.caller.bytes) | |
63 | + | let payment = asPayment(i.payments[0]) | |
64 | + | if (isUserHaveUnclaimedRewards(callerAddress)) | |
65 | + | then throw("You have unclaimed rewards on contract, claim them first") | |
66 | + | else { | |
67 | + | let currentTotalPoolClaimId = valueOrElse(getInteger(poolCurrentClaimIdKey), 0) | |
68 | + | let currentTotalPoolLPStaked = valueOrElse(getInteger(totalPoolLPStakedKey), 0) | |
69 | + | let currentTotalPoolEarned = valueOrElse(getInteger(totalPoolEarnedKey), 0) | |
70 | + | let result = invoke(Address(stakeboosterRootAddress), "stakePoolLps", [poolId], [payment]) | |
71 | + | if ((result == result)) | |
72 | + | then { | |
73 | + | let userDataOpt = getString(callerAddress) | |
74 | + | let userData = if (isDefined(userDataOpt)) | |
75 | + | then { | |
76 | + | let userData = split(asString(userDataOpt), SEP) | |
77 | + | let userTotalStakedAmount = asInt(parseInt(userData[0])) | |
78 | + | let newUserData = [toString((userTotalStakedAmount + payment.amount)), removeByIndex(userData, 0)] | |
79 | + | makeString(newUserData, SEP) | |
80 | + | } | |
81 | + | else makeString([toString(payment.amount), "0", toString(currentTotalPoolClaimId), toString(currentTotalPoolEarned)], SEP) | |
82 | + | [StringEntry(callerAddress, userData), IntegerEntry(poolCurrentClaimIdKey, currentTotalPoolClaimId), IntegerEntry(totalPoolEarnedKey, currentTotalPoolEarned), IntegerEntry(totalPoolLPStakedKey, (currentTotalPoolLPStaked + payment.amount))] | |
83 | + | } | |
84 | + | else throw("Strict value is not equal to itself.") | |
85 | + | } | |
86 | + | } | |
87 | + | ||
88 | + | ||
89 | + | ||
90 | + | @Callable(i) | |
91 | + | func withdrawLP () = { | |
92 | + | let callerAddress = toBase58String(i.caller.bytes) | |
93 | + | if (isUserHaveUnclaimedRewards(callerAddress)) | |
94 | + | then throw("You have unclaimed rewards on contract, claim them first") | |
95 | + | else nil | |
96 | + | } | |
97 | + | ||
98 | + | ||
99 | + | ||
100 | + | @Callable(i) | |
101 | + | func claimRewards () = { | |
102 | + | let callerAddress = toBase58String(i.caller.bytes) | |
103 | + | if (!(isUserHaveUnclaimedRewards(callerAddress))) | |
104 | + | then throw("Nothing to claim, wait for a while, pool will collect the rewards from WX soon") | |
105 | + | else { | |
106 | + | let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey) | |
107 | + | let totalPoolEarned = getIntegerValue(totalPoolEarnedKey) | |
108 | + | let userData = split(getStringValue(callerAddress), SEP) | |
109 | + | let userTotalLPStaked = asInt(parseInt(userData[0])) | |
110 | + | let userTotalRewardsClaimed = asInt(parseInt(userData[1])) | |
111 | + | let userLastClaimPoolClaimId = asInt(parseInt(userData[2])) | |
112 | + | let poolEarnedRewardsWithUser = asInt(parseInt(userData[3])) | |
113 | + | let totalPoolEarningsWithUser = (totalPoolEarned - poolEarnedRewardsWithUser) | |
114 | + | let userClaim = fraction(totalPoolEarningsWithUser, userTotalLPStaked, MULT10) | |
115 | + | let currentEarnedRewards = fraction(userClaim, MULT10, userTotalLPStaked) | |
116 | + | let newUserData = makeString([userData[0], toString((userTotalRewardsClaimed + userClaim)), toString(poolCurrentClaimId), toString((poolEarnedRewardsWithUser + currentEarnedRewards))], SEP) | |
117 | + | [StringEntry(callerAddress, newUserData), ScriptTransfer(i.caller, userClaim, wxAssetId)] | |
118 | + | } | |
119 | + | } | |
120 | + | ||
121 | + | ||
122 | + | ||
123 | + | @Callable(i) | |
124 | + | func claimPoolRewards () = if ((i.caller.bytes != adminAddress)) | |
125 | + | then throw("Admin only") | |
126 | + | else { | |
127 | + | let totalPoolLPStaked = getIntegerValue(totalPoolLPStakedKey) | |
128 | + | let totalPoolEarned = getIntegerValue(totalPoolEarnedKey) | |
129 | + | let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey) | |
130 | + | let currentWxOnContract = assetBalance(this, wxAssetId) | |
131 | + | if ((currentWxOnContract == currentWxOnContract)) | |
132 | + | then { | |
133 | + | let result = invoke(Address(stakeboosterRootAddress), "claimPoolRewards", [poolId], nil) | |
134 | + | if ((result == result)) | |
135 | + | then { | |
136 | + | let newWxOnContract = assetBalance(this, wxAssetId) | |
137 | + | let claimedWxAmount = (newWxOnContract - currentWxOnContract) | |
138 | + | let currentClaimIdEarnings = fraction(claimedWxAmount, MULT10, totalPoolLPStaked) | |
139 | + | [IntegerEntry("CURRENT_WX_ON_CONTRACT", currentWxOnContract), IntegerEntry("NEW_WX_ON_CONTRACT", newWxOnContract), IntegerEntry(poolCurrentClaimIdKey, (poolCurrentClaimId + 1)), IntegerEntry(totalPoolEarnedKey, (totalPoolEarned + currentClaimIdEarnings))] | |
140 | + | } | |
141 | + | else throw("Strict value is not equal to itself.") | |
142 | + | } | |
143 | + | else throw("Strict value is not equal to itself.") | |
144 | + | } | |
145 | + | ||
146 | + | ||
147 | + | @Verifier(tx) | |
148 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
149 | + |
github/deemru/w8io/026f985 29.37 ms ◑