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