tx · CzgxYBgjefUSwLsmm2cG9YWyPSTehU8qLiN2rf7yb55R 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq: -0.01000000 Waves 2023.07.19 09:30 [2672394] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves
{ "type": 13, "id": "CzgxYBgjefUSwLsmm2cG9YWyPSTehU8qLiN2rf7yb55R", "fee": 1000000, "feeAssetId": null, "timestamp": 1689748276309, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "5hXPek2gorkVC1KUf3temwstsqkhGaupeu3rwTdq9eE2RFfp5zWdi2yt85FenCPVSYFaiWz5FrZQpY6LA2Me48A1" ], "script": "base64:BgIVCAISAwoBARIAEgMKAQESAwoBCBIAFAAMY29udHJhY3RGaWxlAhBtcnRfc3Rha2luZy5yaWRlAANTRVACAl9fAAZzY2FsZTgAgMLXLwEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAATa2V5RW1pc3Npb25QZXJCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICEGVtaXNzaW9uUGVyQmxvY2sFA25pbAUDU0VQAA1rZXlTdGFydEJsb2NrCQC5CQIJAMwIAgICJXMJAMwIAgIKc3RhcnRCbG9jawUDbmlsBQNTRVAAEGtleVRvdGFsTHBBbW91bnQJALkJAgkAzAgCAgIlcwkAzAgCAg10b3RhbExwQW1vdW50BQNuaWwFA1NFUAATa2V5VG90YWxBc3NldEFtb3VudAkAuQkCCQDMCAICAiVzCQDMCAICEHRvdGFsQXNzZXRBbW91bnQFA25pbAUDU0VQAQ9rZXlVc2VyTHBBbW91bnQBC3VzZXJBZGRyZXN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3CQBrAwUMdXNlckxwQW1vdW50CQEPZ2V0Q3VycmVudFByaWNlAAUGc2NhbGU4CQCUCgIFA25pbAkAlAoCBQx1c2VyTHBBbW91bnQFHHVzZXJBdmFpbGFibGVBc3NldFRvV2l0aGRyYXcBaQEWZ2V0VG90YWxBc3NldHNSRUFET05MWQAJAJQKAgUDbmlsCQCUCgIFDXRvdGFsTHBBbW91bnQJAStnZXRUb3RhbEFzc2V0QW1vdW50V2l0aFByb2ZpdE9yTWF4QXZhaWxhYmxlAADoPcAs", "height": 2672394, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8GEqyqv1MR2KCmXDZWivdm8NRPUBjmZiXaL8vXZTC2Kp Next: 56YPgkHkrDFwYbZYLCo6dYiYsmCynTsqidA9SWEWk8vT Diff:
Old | New | Differences | |
---|---|---|---|
54 | 54 | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
55 | 55 | match assetIdBytes { | |
56 | 56 | case u: Unit => | |
57 | - | min([totalAssetAmountWithProfit, wavesBalance(this). | |
57 | + | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
58 | 58 | case b: ByteVector => | |
59 | 59 | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
60 | 60 | case _ => |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "mrt_staking.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | 9 | ||
10 | 10 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
14 | 14 | ||
15 | 15 | let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP) | |
16 | 16 | ||
17 | 17 | let keyStartBlock = makeString(["%s", "startBlock"], SEP) | |
18 | 18 | ||
19 | 19 | let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP) | |
20 | 20 | ||
21 | 21 | let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP) | |
22 | 22 | ||
23 | 23 | func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0) | |
33 | 33 | ||
34 | 34 | let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0) | |
35 | 35 | ||
36 | 36 | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
37 | 37 | ||
38 | 38 | let assetIdBytes = if ((assetIdString == "WAVES")) | |
39 | 39 | then unit | |
40 | 40 | else fromBase58String(assetIdString) | |
41 | 41 | ||
42 | 42 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func calcTotalProfit () = { | |
46 | 46 | let emissionPerBlock = valueOrElse(getInteger(this, keyEmissionPerBlock), 0) | |
47 | 47 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
48 | 48 | let elapsedBlocks = (height - startBlock) | |
49 | 49 | max([0, (emissionPerBlock * elapsedBlocks)]) | |
50 | 50 | } | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
54 | 54 | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
55 | 55 | match assetIdBytes { | |
56 | 56 | case u: Unit => | |
57 | - | min([totalAssetAmountWithProfit, wavesBalance(this). | |
57 | + | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
58 | 58 | case b: ByteVector => | |
59 | 59 | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
60 | 60 | case _ => | |
61 | 61 | throw("Match error") | |
62 | 62 | } | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func getCurrentPrice () = { | |
67 | 67 | let currentPrice = if ((totalLpAmount != 0)) | |
68 | 68 | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount) | |
69 | 69 | else (1 * scale8) | |
70 | 70 | currentPrice | |
71 | 71 | } | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | @Callable(i) | |
75 | 75 | func setEmissionPerBlock (emissionPerBlock) = [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | ||
79 | 79 | @Callable(i) | |
80 | 80 | func stake () = { | |
81 | 81 | let checks = [if ((size(i.payments) == 1)) | |
82 | 82 | then true | |
83 | 83 | else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
84 | 84 | then true | |
85 | 85 | else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0)) | |
86 | 86 | then true | |
87 | 87 | else "payment amount should be greater than 0"] | |
88 | 88 | if ((checks == checks)) | |
89 | 89 | then { | |
90 | 90 | let paymentAmount = i.payments[0].amount | |
91 | 91 | let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice()) | |
92 | 92 | let userAddress = toString(i.caller) | |
93 | 93 | let userLpAmount = getUserLpAmount(userAddress) | |
94 | 94 | let userTotalInvestedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
95 | 95 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
96 | 96 | let newTotalAssetAmount = (totalAssetAmount + paymentAmount) | |
97 | 97 | let newUserLpAmount = (userLpAmount + paymentLpAmount) | |
98 | 98 | let newUserTotalInvestedAmount = (userTotalInvestedAmount + paymentAmount) | |
99 | 99 | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalInvestedAmount)] | |
100 | 100 | } | |
101 | 101 | else throw("Strict value is not equal to itself.") | |
102 | 102 | } | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | ||
106 | 106 | @Callable(i) | |
107 | 107 | func withdraw (lpAssetWithdrawAmount) = { | |
108 | 108 | let userAddress = toString(i.caller) | |
109 | 109 | let userLpAmount = getUserLpAmount(userAddress) | |
110 | 110 | let check = [if ((userLpAmount >= lpAssetWithdrawAmount)) | |
111 | 111 | then true | |
112 | 112 | else throwErr((("cannot withdraw more than available (" + toString(userLpAmount)) + ")"))] | |
113 | 113 | if ((check == check)) | |
114 | 114 | then { | |
115 | 115 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
116 | 116 | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8) | |
117 | 117 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
118 | 118 | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8) | |
119 | 119 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
120 | 120 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
121 | 121 | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
122 | 122 | } | |
123 | 123 | else throw("Strict value is not equal to itself.") | |
124 | 124 | } | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | 128 | @Callable(i) | |
129 | 129 | func getAvailableToWithdrawREADONLY (userAddress) = { | |
130 | 130 | let userLpAmount = getUserLpAmount(userAddress) | |
131 | 131 | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8) | |
132 | 132 | $Tuple2(nil, $Tuple2(userLpAmount, userAvailableAssetToWithdraw)) | |
133 | 133 | } | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | ||
137 | 137 | @Callable(i) | |
138 | 138 | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple2(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable())) | |
139 | 139 | ||
140 | 140 |
github/deemru/w8io/026f985 43.49 ms ◑