tx · ETRoECZU6TLbvmsqXvDkWqnodQdFVX5YLcCPQs5a9rd9

3MweDUGicjorwUViyXBcfCM15fQXXEDU3gN:  -0.00500000 Waves

2023.09.22 09:31 [2766230] smart account 3MweDUGicjorwUViyXBcfCM15fQXXEDU3gN > SELF 0.00000000 Waves

{ "type": 13, "id": "ETRoECZU6TLbvmsqXvDkWqnodQdFVX5YLcCPQs5a9rd9", "fee": 500000, "feeAssetId": null, "timestamp": 1695364372555, "version": 2, "chainId": 84, "sender": "3MweDUGicjorwUViyXBcfCM15fQXXEDU3gN", "senderPublicKey": "DGFm8ntnNPVthPrdcaZNWKYZi1wYzD3vhJETwHnF2emk", "proofs": [ "5LW7dMUMdbKKGo3PoFR2QKTefuWH9XEej9XeHFahbiYFb7iAr3mxMCTdn1Fjfk5gmn3LHyV8XFcHVftR8PMNZ6RU" ], "script": "base64:BgIYCAISABIDCgEIEgMKAQESAwoBARIDCgEBBAAQaXNDb25zdHJ1Y3RlZEtleQIOaXNfY29uc3RydWN0ZWQACmFzc2V0SWRLZXkCB2Fzc2V0SWQADWxwUG9vbEFzc2V0SWQCDWxwUG9vbEFzc2V0SWQAGGN1cnJlbnRSZXdhcmRBbW91bnRJZEtleQIQcmV3YXJkX2Ftb3VudF9pZAUBaQELY29uc3RydWN0b3IAAwkBCWlzRGVmaW5lZAEJAKAIAQUQaXNDb25zdHJ1Y3RlZEtleQkAAgECIkNvbnN0cnVjdG9yIGNhbiBiZSBjYWxsZWQgb25lIHRpbWUEBWFzc2V0CQDDCAcCBldYVGVzdAIAAICAmqbqr+MBAAgHBQR1bml0AAAEB2Fzc2V0SWQJALgIAQUFYXNzZXQJAMwIAgUFYXNzZXQJAMwIAgkBC1N0cmluZ0VudHJ5AgUKYXNzZXRJZEtleQkA2AQBBQdhc3NldElkCQDMCAIJAQxCb29sZWFuRW50cnkCBRBpc0NvbnN0cnVjdGVkS2V5BgkAzAgCCQEMSW50ZWdlckVudHJ5AgUYY3VycmVudFJld2FyZEFtb3V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IFGGN1cnJlbnRSZXdhcmRBbW91bnRJZEtleQUYbmV3Q3VycmVudFJld2FyZEFtb3VudElkCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgUGYW1vdW50CQDZBAEFB2Fzc2V0SWQFA25pbAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXk83dG2", "height": 2766230, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ah854Rvi6f23qwmyUuJnuYWA9PmhVbrHZWS1z9KwkZ4b Next: EToW9996YEmZaqjf5RMh4fWxAgcBxk7XSng7pWn7v3zu Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let wxAssetId = base58'4TLuEDo8QjPsxUGjfRPyqqvAk4JtnYMXK1ypGo8uKrb2'
4+let isConstructedKey = "is_constructed"
55
6-let MULT10 = 10000000000
6+let assetIdKey = "assetId"
77
8-let SEP = "__"
8+let lpPoolAssetId = "lpPoolAssetId"
99
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-
10+let currentRewardAmountIdKey = "reward_amount_id"
5711
5812 @Callable(i)
59-func stakeLP () = if ((size(i.payments) != 1))
60- then throw("One Payment expected")
13+func constructor () = if (isDefined(getBoolean(isConstructedKey)))
14+ then throw("Constructor can be called one time")
6115 else {
62- let callerAddress = toBase58String(i.caller.bytes)
63- let payment = asPayment(i.payments[0])
64- if (if ((payment.assetId != poolLPTokenAddress))
65- then true
66- else (0 >= payment.amount))
67- then throw("Wrong asset id or negative amount")
68- else if (isUserHaveUnclaimedRewards(callerAddress))
69- then throw("You have unclaimed rewards on contract, claim them first")
70- else {
71- let currentTotalPoolClaimId = valueOrElse(getInteger(poolCurrentClaimIdKey), 0)
72- let currentTotalPoolLPStaked = valueOrElse(getInteger(totalPoolLPStakedKey), 0)
73- let currentTotalPoolEarned = valueOrElse(getInteger(totalPoolEarnedKey), 0)
74- let result = invoke(Address(stakeboosterRootAddress), "stakePoolLps", [poolId], [payment])
75- if ((result == result))
76- then {
77- let userDataOpt = getString(callerAddress)
78- let userData = if (isDefined(userDataOpt))
79- then {
80- let userData = split(asString(userDataOpt), SEP)
81- let userTotalStakedAmount = asInt(parseInt(userData[0]))
82- let newUserData = [toString((userTotalStakedAmount + payment.amount)), removeByIndex(userData, 0)]
83- makeString(newUserData, SEP)
84- }
85- else makeString([toString(payment.amount), "0", toString(currentTotalPoolClaimId), toString(currentTotalPoolEarned)], SEP)
86-[StringEntry(callerAddress, userData), IntegerEntry(poolCurrentClaimIdKey, currentTotalPoolClaimId), IntegerEntry(totalPoolEarnedKey, currentTotalPoolEarned), IntegerEntry(totalPoolLPStakedKey, (currentTotalPoolLPStaked + payment.amount))]
87- }
88- else throw("Strict value is not equal to itself.")
89- }
16+ let asset = Issue("WXTest", "", 1000000000000000, 8, false, unit, 0)
17+ let assetId = calculateAssetId(asset)
18+[asset, StringEntry(assetIdKey, toBase58String(assetId)), BooleanEntry(isConstructedKey, true), IntegerEntry(currentRewardAmountIdKey, 0)]
9019 }
9120
9221
9322
9423 @Callable(i)
95-func withdrawLP () = {
96- let callerAddress = toBase58String(i.caller.bytes)
97- if (isUserHaveUnclaimedRewards(callerAddress))
98- then throw("You have unclaimed rewards on contract, claim them first")
99- else nil
24+func issueLPAsset (recipient) = {
25+ let asset = Issue("LPPool", "", 1000000000000000, 8, false, unit, 0)
26+ let assetId = calculateAssetId(asset)
27+[asset, StringEntry(lpPoolAssetId, toBase58String(assetId)), ScriptTransfer(Address(fromBase58String(recipient)), 1000000000000, assetId)]
10028 }
10129
10230
10331
10432 @Callable(i)
105-func claimRewards () = {
106- let callerAddress = toBase58String(i.caller.bytes)
107- if (!(isUserHaveUnclaimedRewards(callerAddress)))
108- then throw("Nothing to claim, wait for a while, pool will collect the rewards from WX soon")
109- else {
110- let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey)
111- let totalPoolEarned = getIntegerValue(totalPoolEarnedKey)
112- let userData = split(getStringValue(callerAddress), SEP)
113- let userTotalLPStaked = asInt(parseInt(userData[0]))
114- let userTotalRewardsClaimed = asInt(parseInt(userData[1]))
115- let userLastClaimPoolClaimId = asInt(parseInt(userData[2]))
116- let poolEarnedRewardsWithoutUser = asInt(parseInt(userData[3]))
117- let totalPoolEarningsWithUser = (totalPoolEarned - poolEarnedRewardsWithoutUser)
118- let unclaimedRewards = (totalPoolEarningsWithUser - (userTotalRewardsClaimed * MULT10))
119- let userCurrentClaim = fraction(unclaimedRewards, userTotalLPStaked, MULT10)
120- let newUserData = makeString([userData[0], toString((userTotalRewardsClaimed + userCurrentClaim)), toString(poolCurrentClaimId), userData[3]], SEP)
121-[StringEntry(callerAddress, newUserData), ScriptTransfer(i.caller, userCurrentClaim, wxAssetId)]
122- }
123- }
33+func stakePoolLps (poolId) = [IntegerEntry("stakePoolLpsFuncCalled", height)]
12434
12535
12636
12737 @Callable(i)
128-func claimPoolRewards () = if ((i.caller.bytes != adminAddress))
129- then throw("Admin only")
130- else {
131- let totalPoolLPStaked = getIntegerValue(totalPoolLPStakedKey)
132- let totalPoolEarned = getIntegerValue(totalPoolEarnedKey)
133- let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey)
134- let currentWxOnContract = assetBalance(this, wxAssetId)
135- if ((currentWxOnContract == currentWxOnContract))
136- then {
137- let result = invoke(Address(stakeboosterRootAddress), "claimPoolRewards", [poolId], nil)
138- if ((result == result))
139- then {
140- let newWxOnContract = assetBalance(this, wxAssetId)
141- let claimedWxAmount = (newWxOnContract - currentWxOnContract)
142- let currentClaimIdEarnings = fraction(claimedWxAmount, MULT10, totalPoolLPStaked)
143-[IntegerEntry("CURRENT_WX_ON_CONTRACT", currentWxOnContract), IntegerEntry("NEW_WX_ON_CONTRACT", newWxOnContract), IntegerEntry(poolCurrentClaimIdKey, (poolCurrentClaimId + 1)), IntegerEntry(totalPoolEarnedKey, (totalPoolEarned + currentClaimIdEarnings))]
144- }
145- else throw("Strict value is not equal to itself.")
146- }
147- else throw("Strict value is not equal to itself.")
148- }
38+func withdrawPoolLps (poolId) = [IntegerEntry("withdrawPoolLpsFuncCalled", height)]
39+
40+
41+
42+@Callable(i)
43+func claimPoolRewards (poolId) = {
44+ let currentRewardAmountId = getIntegerValue(currentRewardAmountIdKey)
45+ let assetId = getStringValue(assetIdKey)
46+ let amount = if ((currentRewardAmountId == 0))
47+ then 10000000000
48+ else if ((currentRewardAmountId == 1))
49+ then 20000000000
50+ else if ((currentRewardAmountId == 2))
51+ then 5000000000
52+ else if ((currentRewardAmountId == 3))
53+ then 35000000000
54+ else 22000000000
55+ let newCurrentRewardAmountId = if ((currentRewardAmountId == 4))
56+ then 0
57+ else (currentRewardAmountId + 1)
58+[IntegerEntry(currentRewardAmountIdKey, newCurrentRewardAmountId), ScriptTransfer(i.caller, amount, fromBase58String(assetId))]
59+ }
14960
15061
15162 @Verifier(tx)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let wxAssetId = base58'4TLuEDo8QjPsxUGjfRPyqqvAk4JtnYMXK1ypGo8uKrb2'
4+let isConstructedKey = "is_constructed"
55
6-let MULT10 = 10000000000
6+let assetIdKey = "assetId"
77
8-let SEP = "__"
8+let lpPoolAssetId = "lpPoolAssetId"
99
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-
10+let currentRewardAmountIdKey = "reward_amount_id"
5711
5812 @Callable(i)
59-func stakeLP () = if ((size(i.payments) != 1))
60- then throw("One Payment expected")
13+func constructor () = if (isDefined(getBoolean(isConstructedKey)))
14+ then throw("Constructor can be called one time")
6115 else {
62- let callerAddress = toBase58String(i.caller.bytes)
63- let payment = asPayment(i.payments[0])
64- if (if ((payment.assetId != poolLPTokenAddress))
65- then true
66- else (0 >= payment.amount))
67- then throw("Wrong asset id or negative amount")
68- else if (isUserHaveUnclaimedRewards(callerAddress))
69- then throw("You have unclaimed rewards on contract, claim them first")
70- else {
71- let currentTotalPoolClaimId = valueOrElse(getInteger(poolCurrentClaimIdKey), 0)
72- let currentTotalPoolLPStaked = valueOrElse(getInteger(totalPoolLPStakedKey), 0)
73- let currentTotalPoolEarned = valueOrElse(getInteger(totalPoolEarnedKey), 0)
74- let result = invoke(Address(stakeboosterRootAddress), "stakePoolLps", [poolId], [payment])
75- if ((result == result))
76- then {
77- let userDataOpt = getString(callerAddress)
78- let userData = if (isDefined(userDataOpt))
79- then {
80- let userData = split(asString(userDataOpt), SEP)
81- let userTotalStakedAmount = asInt(parseInt(userData[0]))
82- let newUserData = [toString((userTotalStakedAmount + payment.amount)), removeByIndex(userData, 0)]
83- makeString(newUserData, SEP)
84- }
85- else makeString([toString(payment.amount), "0", toString(currentTotalPoolClaimId), toString(currentTotalPoolEarned)], SEP)
86-[StringEntry(callerAddress, userData), IntegerEntry(poolCurrentClaimIdKey, currentTotalPoolClaimId), IntegerEntry(totalPoolEarnedKey, currentTotalPoolEarned), IntegerEntry(totalPoolLPStakedKey, (currentTotalPoolLPStaked + payment.amount))]
87- }
88- else throw("Strict value is not equal to itself.")
89- }
16+ let asset = Issue("WXTest", "", 1000000000000000, 8, false, unit, 0)
17+ let assetId = calculateAssetId(asset)
18+[asset, StringEntry(assetIdKey, toBase58String(assetId)), BooleanEntry(isConstructedKey, true), IntegerEntry(currentRewardAmountIdKey, 0)]
9019 }
9120
9221
9322
9423 @Callable(i)
95-func withdrawLP () = {
96- let callerAddress = toBase58String(i.caller.bytes)
97- if (isUserHaveUnclaimedRewards(callerAddress))
98- then throw("You have unclaimed rewards on contract, claim them first")
99- else nil
24+func issueLPAsset (recipient) = {
25+ let asset = Issue("LPPool", "", 1000000000000000, 8, false, unit, 0)
26+ let assetId = calculateAssetId(asset)
27+[asset, StringEntry(lpPoolAssetId, toBase58String(assetId)), ScriptTransfer(Address(fromBase58String(recipient)), 1000000000000, assetId)]
10028 }
10129
10230
10331
10432 @Callable(i)
105-func claimRewards () = {
106- let callerAddress = toBase58String(i.caller.bytes)
107- if (!(isUserHaveUnclaimedRewards(callerAddress)))
108- then throw("Nothing to claim, wait for a while, pool will collect the rewards from WX soon")
109- else {
110- let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey)
111- let totalPoolEarned = getIntegerValue(totalPoolEarnedKey)
112- let userData = split(getStringValue(callerAddress), SEP)
113- let userTotalLPStaked = asInt(parseInt(userData[0]))
114- let userTotalRewardsClaimed = asInt(parseInt(userData[1]))
115- let userLastClaimPoolClaimId = asInt(parseInt(userData[2]))
116- let poolEarnedRewardsWithoutUser = asInt(parseInt(userData[3]))
117- let totalPoolEarningsWithUser = (totalPoolEarned - poolEarnedRewardsWithoutUser)
118- let unclaimedRewards = (totalPoolEarningsWithUser - (userTotalRewardsClaimed * MULT10))
119- let userCurrentClaim = fraction(unclaimedRewards, userTotalLPStaked, MULT10)
120- let newUserData = makeString([userData[0], toString((userTotalRewardsClaimed + userCurrentClaim)), toString(poolCurrentClaimId), userData[3]], SEP)
121-[StringEntry(callerAddress, newUserData), ScriptTransfer(i.caller, userCurrentClaim, wxAssetId)]
122- }
123- }
33+func stakePoolLps (poolId) = [IntegerEntry("stakePoolLpsFuncCalled", height)]
12434
12535
12636
12737 @Callable(i)
128-func claimPoolRewards () = if ((i.caller.bytes != adminAddress))
129- then throw("Admin only")
130- else {
131- let totalPoolLPStaked = getIntegerValue(totalPoolLPStakedKey)
132- let totalPoolEarned = getIntegerValue(totalPoolEarnedKey)
133- let poolCurrentClaimId = getIntegerValue(poolCurrentClaimIdKey)
134- let currentWxOnContract = assetBalance(this, wxAssetId)
135- if ((currentWxOnContract == currentWxOnContract))
136- then {
137- let result = invoke(Address(stakeboosterRootAddress), "claimPoolRewards", [poolId], nil)
138- if ((result == result))
139- then {
140- let newWxOnContract = assetBalance(this, wxAssetId)
141- let claimedWxAmount = (newWxOnContract - currentWxOnContract)
142- let currentClaimIdEarnings = fraction(claimedWxAmount, MULT10, totalPoolLPStaked)
143-[IntegerEntry("CURRENT_WX_ON_CONTRACT", currentWxOnContract), IntegerEntry("NEW_WX_ON_CONTRACT", newWxOnContract), IntegerEntry(poolCurrentClaimIdKey, (poolCurrentClaimId + 1)), IntegerEntry(totalPoolEarnedKey, (totalPoolEarned + currentClaimIdEarnings))]
144- }
145- else throw("Strict value is not equal to itself.")
146- }
147- else throw("Strict value is not equal to itself.")
148- }
38+func withdrawPoolLps (poolId) = [IntegerEntry("withdrawPoolLpsFuncCalled", height)]
39+
40+
41+
42+@Callable(i)
43+func claimPoolRewards (poolId) = {
44+ let currentRewardAmountId = getIntegerValue(currentRewardAmountIdKey)
45+ let assetId = getStringValue(assetIdKey)
46+ let amount = if ((currentRewardAmountId == 0))
47+ then 10000000000
48+ else if ((currentRewardAmountId == 1))
49+ then 20000000000
50+ else if ((currentRewardAmountId == 2))
51+ then 5000000000
52+ else if ((currentRewardAmountId == 3))
53+ then 35000000000
54+ else 22000000000
55+ let newCurrentRewardAmountId = if ((currentRewardAmountId == 4))
56+ then 0
57+ else (currentRewardAmountId + 1)
58+[IntegerEntry(currentRewardAmountIdKey, newCurrentRewardAmountId), ScriptTransfer(i.caller, amount, fromBase58String(assetId))]
59+ }
14960
15061
15162 @Verifier(tx)
15263 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
15364

github/deemru/w8io/026f985 
28.49 ms