tx · CDugFANo6VEY7Cqy1SYdJDjABWzaMkQFNmMs68R1Dw7E 3MudiTkeXkCmSPyxKpTUKekkixFAtE34VS4: -0.18900000 Waves 2020.10.20 17:27 [1229002] smart account 3MudiTkeXkCmSPyxKpTUKekkixFAtE34VS4 > SELF 0.00000000 Waves
{ "type": 13, "id": "CDugFANo6VEY7Cqy1SYdJDjABWzaMkQFNmMs68R1Dw7E", "fee": 18900000, "feeAssetId": null, "timestamp": 1603204048865, "version": 2, "chainId": 84, "sender": "3MudiTkeXkCmSPyxKpTUKekkixFAtE34VS4", "senderPublicKey": "FUtTeqR8bGLSzbtwYwyqKTZQm3qNBgha29jtvAcH5ZwL", "proofs": [ "3PTKLmE6rZKWM9FVViX9z8NkBtS8N5Q1LrsY9P1Kqyh6UcofXyAWQtWDrQ8xvP7x3HodXYc32f3Zv1niDvqTEAXN" ], "script": "base64:AAIDAAAAAAAAAA8IARIAEgASABIDCgEBEgAAAAAAAAAABQAAAAFpAQAAAAhwYXlZaWVsZAAAAAAEAAAAC0dvdmVyblRva2VuAQAAACC8BnLNTH75zY/85pKTg3cOi9DRRgrZqRPS5vvLPGg8zQQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAMJAABmAAAAAgUAAAANY3VycmVudEFtb3VudAAAAAAAAAAAAAQAAAARR292ZXJuVG9rZW5BbW91bnQJAAPrAAAAAgUAAAAEdGhpcwUAAAALR292ZXJuVG9rZW4DCQAAZgAAAAIAAAAAAAAAAAEFAAAAEUdvdmVyblRva2VuQW1vdW50CQAAAgAAAAECAAAAIU5vIGVub3VnaCBHb3Zlcm5Ub2tlbiBJbiBDb250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uQW1vdW50CQAAAgAAAAEJAAEsAAAAAgIAAABSWW91IGhhdmUgdG8gU3Rha2UgU3Rha2VkVG9rZW4gdG8gY2xhaW0gcmV3YXJkIAogWW91ciBCYWxhbmNlIG9mIFN0YWtlZCBUb2tlbnMgaXM6IAkAAaQAAAABBQAAABVVc2VyU3Rha2VkVG9rZW5BbW91bnQDCQAAZgAAAAIFAAAAFVVzZXJHb3Zlcm5Ub2tlbkFtb3VudAAAAAAAAAAAZAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAC3dpbm5lclByaXplBQAAAAtQcml6ZUFtb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAASRnVuZEJveFN0YWtlZFRva2VuAAAAAAAAAAAACQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAABJVc2VyR292ZXJuVG9rZW5LZXkAAAAAAAAAAGQFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAp3aW5BZGRyZXNzBQAAAAtQcml6ZUFtb3VudAUAAAALU3Rha2VkVG9rZW4JAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyAAAAAAAAAABkBQAAAAtHb3Zlcm5Ub2tlbgUAAAADbmlsCQAAAgAAAAEJAAEsAAAAAgIAAABHWW91IGhhdmUgdG8gZGVwb3NpdCAxMDAgR292ZXJuVG9rZW4gdG8gY2xhaW0gUmV3YXJkIAogWW91ciBCYWxhbmNlIGlzOiAJAAGkAAAAAQUAAAAVVXNlckdvdmVyblRva2VuQW1vdW50AAAAAHv4UQ0=", "height": 1229002, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 813EVjznDFstqmQkL9DDQQkxA9VKaZNRkimXxCaCUPov Next: 7VMnpbHgt83GgSzb2vujHRM6bBd57xcXoUcEztYkxNBZ Diff:
Old | New | Differences | |
---|---|---|---|
47 | 47 | then throw("No enough GovernToken In Contract") | |
48 | 48 | else ScriptResult(WriteSet([DataEntry(currentKey, 10), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 10, GovernToken)])) | |
49 | 49 | } | |
50 | - | else throw("Can deposit only | |
50 | + | else throw("Can deposit only StakeToken") | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Callable(i) | |
56 | - | func | |
56 | + | func DepositGovernToken () = { | |
57 | 57 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
58 | 58 | let GovernTokenMaxDeposit = toBase58String(GovernToken) | |
59 | 59 | let pmt = extract(i.payment) | |
61 | 61 | then (extract(pmt.assetId) == GovernToken) | |
62 | 62 | else false) | |
63 | 63 | then { | |
64 | - | let currentKey = | |
64 | + | let currentKey = toBase58String(i.caller.bytes) | |
65 | 65 | let currentAmount = match getInteger(this, currentKey) { | |
66 | 66 | case a: Int => | |
67 | 67 | a | |
69 | 69 | 0 | |
70 | 70 | } | |
71 | 71 | let CurrrentGovernTokenDeposit = (currentAmount + pmt.amount) | |
72 | - | let | |
73 | - | let | |
72 | + | let GovernTokeKey = "GovernTokenMaxDeposit" | |
73 | + | let MaxGovernTokenDeposit = match getInteger(this, GovernTokeKey) { | |
74 | 74 | case a: Int => | |
75 | 75 | a | |
76 | 76 | case _ => | |
77 | 77 | 0 | |
78 | 78 | } | |
79 | - | if ((CurrrentGovernTokenDeposit > | |
80 | - | then WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit), DataEntry( | |
81 | - | else throw((((" | |
79 | + | if ((CurrrentGovernTokenDeposit > MaxGovernTokenDeposit)) | |
80 | + | then WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit), DataEntry(GovernTokeKey, MaxGovernTokenDeposit)]) | |
81 | + | else throw((((" Your Balance of GovernToken is " + toString(CurrrentGovernTokenDeposit)) + " But Max GovernToken is: ") + toString(MaxGovernTokenDeposit))) | |
82 | 82 | } | |
83 | 83 | else throw("Can deposit only Govern Token") | |
84 | 84 | } | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | @Callable(i) | |
89 | - | func | |
89 | + | func WithdrawStakedFunds (amount) = { | |
90 | 90 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
91 | 91 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
92 | 92 | let currentKey = toBase58String(i.caller.bytes) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func payYield () = { | |
8 | 8 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
9 | 9 | let currentKey = toBase58String(i.caller.bytes) | |
10 | 10 | let currentAmount = match getInteger(this, currentKey) { | |
11 | 11 | case a: Int => | |
12 | 12 | a | |
13 | 13 | case _ => | |
14 | 14 | 0 | |
15 | 15 | } | |
16 | 16 | if ((currentAmount > 0)) | |
17 | 17 | then { | |
18 | 18 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
19 | 19 | if ((1 > GovernTokenAmount)) | |
20 | 20 | then throw("No enough GovernToken In Contract") | |
21 | 21 | else ScriptResult(WriteSet([DataEntry(currentKey, 10)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken)])) | |
22 | 22 | } | |
23 | 23 | else throw("You need to deposit Collateral Token to receive Govern Token") | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | 28 | @Callable(i) | |
29 | 29 | func Stake () = { | |
30 | 30 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
31 | 31 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
32 | 32 | let pmt = extract(i.payment) | |
33 | 33 | if (if (isDefined(pmt.assetId)) | |
34 | 34 | then (extract(pmt.assetId) == CollateralToken) | |
35 | 35 | else false) | |
36 | 36 | then { | |
37 | 37 | let currentKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(CollateralToken)) | |
38 | 38 | let currentAmount = match getInteger(this, currentKey) { | |
39 | 39 | case a: Int => | |
40 | 40 | a | |
41 | 41 | case _ => | |
42 | 42 | 0 | |
43 | 43 | } | |
44 | 44 | let newAmount = (currentAmount + pmt.amount) | |
45 | 45 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
46 | 46 | if ((1 > GovernTokenAmount)) | |
47 | 47 | then throw("No enough GovernToken In Contract") | |
48 | 48 | else ScriptResult(WriteSet([DataEntry(currentKey, 10), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 10, GovernToken)])) | |
49 | 49 | } | |
50 | - | else throw("Can deposit only | |
50 | + | else throw("Can deposit only StakeToken") | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Callable(i) | |
56 | - | func | |
56 | + | func DepositGovernToken () = { | |
57 | 57 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
58 | 58 | let GovernTokenMaxDeposit = toBase58String(GovernToken) | |
59 | 59 | let pmt = extract(i.payment) | |
60 | 60 | if (if (isDefined(pmt.assetId)) | |
61 | 61 | then (extract(pmt.assetId) == GovernToken) | |
62 | 62 | else false) | |
63 | 63 | then { | |
64 | - | let currentKey = | |
64 | + | let currentKey = toBase58String(i.caller.bytes) | |
65 | 65 | let currentAmount = match getInteger(this, currentKey) { | |
66 | 66 | case a: Int => | |
67 | 67 | a | |
68 | 68 | case _ => | |
69 | 69 | 0 | |
70 | 70 | } | |
71 | 71 | let CurrrentGovernTokenDeposit = (currentAmount + pmt.amount) | |
72 | - | let | |
73 | - | let | |
72 | + | let GovernTokeKey = "GovernTokenMaxDeposit" | |
73 | + | let MaxGovernTokenDeposit = match getInteger(this, GovernTokeKey) { | |
74 | 74 | case a: Int => | |
75 | 75 | a | |
76 | 76 | case _ => | |
77 | 77 | 0 | |
78 | 78 | } | |
79 | - | if ((CurrrentGovernTokenDeposit > | |
80 | - | then WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit), DataEntry( | |
81 | - | else throw((((" | |
79 | + | if ((CurrrentGovernTokenDeposit > MaxGovernTokenDeposit)) | |
80 | + | then WriteSet([DataEntry(currentKey, CurrrentGovernTokenDeposit), DataEntry(GovernTokeKey, MaxGovernTokenDeposit)]) | |
81 | + | else throw((((" Your Balance of GovernToken is " + toString(CurrrentGovernTokenDeposit)) + " But Max GovernToken is: ") + toString(MaxGovernTokenDeposit))) | |
82 | 82 | } | |
83 | 83 | else throw("Can deposit only Govern Token") | |
84 | 84 | } | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | ||
88 | 88 | @Callable(i) | |
89 | - | func | |
89 | + | func WithdrawStakedFunds (amount) = { | |
90 | 90 | let CollateralToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
91 | 91 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
92 | 92 | let currentKey = toBase58String(i.caller.bytes) | |
93 | 93 | let currentAmount = match getInteger(this, currentKey) { | |
94 | 94 | case a: Int => | |
95 | 95 | a | |
96 | 96 | case _ => | |
97 | 97 | 0 | |
98 | 98 | } | |
99 | 99 | let newAmount = (currentAmount - amount) | |
100 | 100 | if ((0 > amount)) | |
101 | 101 | then throw("Can't withdraw negative amount") | |
102 | 102 | else if ((0 > newAmount)) | |
103 | 103 | then throw("User cannot withdraw more than deposited funds") | |
104 | 104 | else { | |
105 | 105 | let GovernTokenAmount = assetBalance(this, GovernToken) | |
106 | 106 | if ((1 > GovernTokenAmount)) | |
107 | 107 | then throw("No enough GovernToken In Contract") | |
108 | 108 | else ScriptResult(WriteSet([DataEntry(currentKey, 1), DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, 1, GovernToken), ScriptTransfer(i.caller, amount, CollateralToken)])) | |
109 | 109 | } | |
110 | 110 | } | |
111 | 111 | ||
112 | 112 | ||
113 | 113 | ||
114 | 114 | @Callable(i) | |
115 | 115 | func ClaimPrize () = { | |
116 | 116 | let StakedToken = base58'5hHK64aujiyn7cNrTBwhe5yJQuxs119KTPbE9nFjLoUN' | |
117 | 117 | let GovernToken = base58'DeyMK8USWs9ijzAXNy2azA3soajfrXjUNiJBdSJJsvMJ' | |
118 | 118 | let FundBoxAddress58 = base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD' | |
119 | 119 | let winnerPrize = (("3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA" + "_") + toBase58String(StakedToken)) | |
120 | 120 | let winAddress = Address(base58'3N1QzUHdfyXmKVFAn9TPHG7iuW4uK53pfXA') | |
121 | 121 | let FundBoxAddress = Address(base58'3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD') | |
122 | 122 | let FundBox = "3NCMrhPAVqXgtLdpi2BhFWpJkMBUAFrozbD" | |
123 | 123 | let UserGovernTokenKey = ((toBase58String(i.caller.bytes) + "_") + toBase58String(GovernToken)) | |
124 | 124 | let UserStakedToken = ((toBase58String(i.caller.bytes) + "_") + toBase58String(StakedToken)) | |
125 | 125 | let FundBoxStakedToken = ((toBase58String(FundBoxAddress58) + "_") + toBase58String(StakedToken)) | |
126 | 126 | let UserGovernTokenAmount = match getInteger(this, UserGovernTokenKey) { | |
127 | 127 | case a: Int => | |
128 | 128 | a | |
129 | 129 | case _ => | |
130 | 130 | 0 | |
131 | 131 | } | |
132 | 132 | let UserStakedTokenAmount = match getInteger(this, UserStakedToken) { | |
133 | 133 | case a: Int => | |
134 | 134 | a | |
135 | 135 | case _ => | |
136 | 136 | 0 | |
137 | 137 | } | |
138 | 138 | let PrizeAmount = match getInteger(this, FundBoxStakedToken) { | |
139 | 139 | case a: Int => | |
140 | 140 | a | |
141 | 141 | case _ => | |
142 | 142 | 0 | |
143 | 143 | } | |
144 | 144 | if ((PrizeAmount == 0)) | |
145 | 145 | then throw("No prize to Claim") | |
146 | 146 | else if ((UserStakedToken != winnerPrize)) | |
147 | 147 | then throw("You are not the winner hence cannot claim the reward ") | |
148 | 148 | else if ((1 > UserStakedTokenAmount)) | |
149 | 149 | then throw(("You have to Stake StakedToken to claim reward | |
150 | 150 | Your Balance of Staked Tokens is: " + toString(UserStakedTokenAmount))) | |
151 | 151 | else if ((UserGovernTokenAmount > 100)) | |
152 | 152 | then ScriptResult(WriteSet([DataEntry(winnerPrize, PrizeAmount), DataEntry(FundBoxStakedToken, 0), DataEntry(UserGovernTokenKey, 100)]), TransferSet([ScriptTransfer(winAddress, PrizeAmount, StakedToken), ScriptTransfer(i.caller, 100, GovernToken)])) | |
153 | 153 | else throw(("You have to deposit 100 GovernToken to claim Reward | |
154 | 154 | Your Balance is: " + toString(UserGovernTokenAmount))) | |
155 | 155 | } | |
156 | 156 | ||
157 | 157 |
github/deemru/w8io/169f3d6 55.75 ms ◑