tx · EsKWbvZopS9vYW7hTSmuSK5Dm2YD4LEYD7qnrSLWTXW1 3N4kXZHGke6yRq3Z57q7BTgCrT2SCvQCYER: -0.01400000 Waves 2022.11.23 17:52 [2329891] smart account 3N4kXZHGke6yRq3Z57q7BTgCrT2SCvQCYER > SELF 0.00000000 Waves
{ "type": 13, "id": "EsKWbvZopS9vYW7hTSmuSK5Dm2YD4LEYD7qnrSLWTXW1", "fee": 1400000, "feeAssetId": null, "timestamp": 1669215130843, "version": 2, "chainId": 84, "sender": "3N4kXZHGke6yRq3Z57q7BTgCrT2SCvQCYER", "senderPublicKey": "6sxdMr2xYPPACEJccwmgS7nWC2ez1c38Y1kDX49ne42b", "proofs": [ "4J3sAuqZkZqm4bgYe6VSohYkt9onPdGwFnjfbp7qZCuavmuM1DsJUMFSnfAmaaXrx5GdXWeqksfA5kcoF2qJxNPm" ], "script": "base64:BgIdCAISBgoECAgICBIAEgASABIECgIBARIAEgMKAQggAAlTRVBBUkFUT1ICAl9fAAVXQVZFUwIFV0FWRVMADEtFWV9NVUxUSVNJRwIITVVMVElTSUcACktFWV9TVEFUVVMCBlNUQVRVUwAOS0VZX0JBU0VfQVNTRVQCCkJBU0VfQVNTRVQACUtFWV9BU1NFVAIFQVNTRVQAE0tFWV9TVEFLSU5HX0FEQVBURVICD1NUQUtJTkdfQURBUFRFUgASS0VZX1NUQUtJTkdfQU1PVU5UAg5TVEFLSU5HX0FNT1VOVAANS0VZX0xBU1RfUkFURQIJTEFTVF9SQVRFABBLRVlfQ1VSUkVOVF9SQVRFAgxDVVJSRU5UX1JBVEUAD0tFWV9MQVNUX0hFSUdIVAILTEFTVF9IRUlHSFQAEUtFWV9UQVJHRVRfSEVJR0hUAg1UQVJHRVRfSEVJR0hUAApGVU5DX1NUQUtFAgVzdGFrZQAMRlVOQ19VTlNUQUtFAgd1bnN0YWtlABFGVU5DX0NMQUlNX1JFV0FSRAILY2xhaW1SZXdhcmQADlBFUkNFTlRfRkFDVE9SCQC2AgEAg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AAgECHnNldE11bHRpc2lnOiBwZXJtaXNzaW9uIGRlbmllZAMJAQEhAQkBEF92YWxpZGF0ZUFkZHJlc3MBBQltdWx0aXNpZ18JAAIBAiVzZXRNdWx0aXNpZzogaW52YWxpZCBtdWx0aXNpZyBhZGRyZXNzBQR1bml0AwkAAAIFA2VycgUDZXJyCQCUCgIJAMwIAgkBC1N0cmluZ0VudHJ5AgUMS0VZX01VTFRJU0lHBQltdWx0aXNpZ18FA25pbAUEdW5pdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAEByRtYXRjaDAJAKIIAQUMS0VZX01VTFRJU0lHAwkAAQIFByRtYXRjaDACBlN0cmluZwQIbXVsdGlzaWcFByRtYXRjaDAJAQt2YWx1ZU9yRWxzZQIJAJsIAgkBEUBleHRyTmF0aXZlKDEwNjIpAQUIbXVsdGlzaWcJALkJAgkAzAgCBQpLRVlfU1RBVFVTCQDMCAIJAKUIAQUEdGhpcwkAzAgCCQDYBAEIBQJ0eAJpZAUDbmlsBQlTRVBBUkFUT1IHCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V53t0L+A==", "height": 2329891, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HfJMuDyMmbbKywPzobke9UokeR2m9pcRkACZa1FowZfE Next: DRBLYCxLW4PHy7YBZhkUcrfmMcjeiCKHwNDpLzKY8fUw Diff:
Old | New | Differences | |
---|---|---|---|
36 | 36 | let ZERO_BIGINT = toBigInt(0) | |
37 | 37 | ||
38 | 38 | let ONE_BIGINT = toBigInt(1) | |
39 | + | ||
40 | + | let ONE_WAVES = 100000000 | |
39 | 41 | ||
40 | 42 | func _validateAddress (address_) = match addressFromString(address_) { | |
41 | 43 | case a: Address => | |
187 | 189 | then throw("init: invalid base asset") | |
188 | 190 | else if (!(_validateAddress(stakingAdapter_))) | |
189 | 191 | then throw("init: invalid staking adapter") | |
190 | - | else if ((0 >= wavesBalance(this).regular)) | |
191 | - | then throw("init: no waves at this contract") | |
192 | - | else unit | |
192 | + | else unit | |
193 | 193 | if ((err == err)) | |
194 | 194 | then { | |
195 | 195 | let tokenDecimals = _getAssetDecimals(baseAsset) | |
196 | - | let issue = Issue(tokenName_, tokenDescr_, | |
196 | + | let issue = Issue(tokenName_, tokenDescr_, ONE_WAVES, tokenDecimals, true) | |
197 | 197 | let assetId = calculateAssetId(issue) | |
198 | - | let stakeActions = _updateStaking(baseAsset, | |
198 | + | let stakeActions = _updateStaking(baseAsset, ONE_WAVES, addressFromStringValue(stakingAdapter_)) | |
199 | 199 | $Tuple2(([StringEntry(KEY_BASE_ASSET, baseAsset_), StringEntry(KEY_STAKING_ADAPTER, stakingAdapter_), StringEntry(KEY_ASSET, toBase58String(assetId)), issue] ++ stakeActions), unit) | |
200 | 200 | } | |
201 | 201 | else throw("Strict value is not equal to itself.") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEPARATOR = "__" | |
5 | 5 | ||
6 | 6 | let WAVES = "WAVES" | |
7 | 7 | ||
8 | 8 | let KEY_MULTISIG = "MULTISIG" | |
9 | 9 | ||
10 | 10 | let KEY_STATUS = "STATUS" | |
11 | 11 | ||
12 | 12 | let KEY_BASE_ASSET = "BASE_ASSET" | |
13 | 13 | ||
14 | 14 | let KEY_ASSET = "ASSET" | |
15 | 15 | ||
16 | 16 | let KEY_STAKING_ADAPTER = "STAKING_ADAPTER" | |
17 | 17 | ||
18 | 18 | let KEY_STAKING_AMOUNT = "STAKING_AMOUNT" | |
19 | 19 | ||
20 | 20 | let KEY_LAST_RATE = "LAST_RATE" | |
21 | 21 | ||
22 | 22 | let KEY_CURRENT_RATE = "CURRENT_RATE" | |
23 | 23 | ||
24 | 24 | let KEY_LAST_HEIGHT = "LAST_HEIGHT" | |
25 | 25 | ||
26 | 26 | let KEY_TARGET_HEIGHT = "TARGET_HEIGHT" | |
27 | 27 | ||
28 | 28 | let FUNC_STAKE = "stake" | |
29 | 29 | ||
30 | 30 | let FUNC_UNSTAKE = "unstake" | |
31 | 31 | ||
32 | 32 | let FUNC_CLAIM_REWARD = "claimReward" | |
33 | 33 | ||
34 | 34 | let PERCENT_FACTOR = toBigInt(1000000000000) | |
35 | 35 | ||
36 | 36 | let ZERO_BIGINT = toBigInt(0) | |
37 | 37 | ||
38 | 38 | let ONE_BIGINT = toBigInt(1) | |
39 | + | ||
40 | + | let ONE_WAVES = 100000000 | |
39 | 41 | ||
40 | 42 | func _validateAddress (address_) = match addressFromString(address_) { | |
41 | 43 | case a: Address => | |
42 | 44 | true | |
43 | 45 | case _ => | |
44 | 46 | false | |
45 | 47 | } | |
46 | 48 | ||
47 | 49 | ||
48 | 50 | func _validateAsset (asset_) = if ((asset_ == WAVES)) | |
49 | 51 | then true | |
50 | 52 | else match assetInfo(fromBase58String(asset_)) { | |
51 | 53 | case a: Asset => | |
52 | 54 | true | |
53 | 55 | case _ => | |
54 | 56 | false | |
55 | 57 | } | |
56 | 58 | ||
57 | 59 | ||
58 | 60 | func _toAssetVector (asset_) = if ((asset_ == WAVES)) | |
59 | 61 | then unit | |
60 | 62 | else fromBase58String(asset_) | |
61 | 63 | ||
62 | 64 | ||
63 | 65 | func _getAssetDecimals (asset_) = match asset_ { | |
64 | 66 | case a: ByteVector => | |
65 | 67 | match assetInfo(a) { | |
66 | 68 | case asset: Asset => | |
67 | 69 | asset.decimals | |
68 | 70 | case _ => | |
69 | 71 | throw("_getAssetDecimals: no such asset") | |
70 | 72 | } | |
71 | 73 | case _ => | |
72 | 74 | 8 | |
73 | 75 | } | |
74 | 76 | ||
75 | 77 | ||
76 | 78 | func _getAssetQuantity (asset_) = match assetInfo(asset_) { | |
77 | 79 | case a: Asset => | |
78 | 80 | a.quantity | |
79 | 81 | case _ => | |
80 | 82 | throw("_getAssetQuantity: no such asset") | |
81 | 83 | } | |
82 | 84 | ||
83 | 85 | ||
84 | 86 | func _getAssetBalance (asset_,address) = match asset_ { | |
85 | 87 | case a: ByteVector => | |
86 | 88 | assetBalance(address, a) | |
87 | 89 | case _ => | |
88 | 90 | wavesBalance(address).regular | |
89 | 91 | } | |
90 | 92 | ||
91 | 93 | ||
92 | 94 | func _loadBaseAsset () = match getString(KEY_BASE_ASSET) { | |
93 | 95 | case a: String => | |
94 | 96 | if ((a == WAVES)) | |
95 | 97 | then unit | |
96 | 98 | else fromBase58String(a) | |
97 | 99 | case _ => | |
98 | 100 | throw("_loadBaseAsset: no base asset") | |
99 | 101 | } | |
100 | 102 | ||
101 | 103 | ||
102 | 104 | func _loadStakingAdapter () = match getString(KEY_STAKING_ADAPTER) { | |
103 | 105 | case a: String => | |
104 | 106 | addressFromStringValue(a) | |
105 | 107 | case _ => | |
106 | 108 | throw("_loadStakingAdapter: no staking adapter") | |
107 | 109 | } | |
108 | 110 | ||
109 | 111 | ||
110 | 112 | func _loadInt (key_,default_) = match getInteger(key_) { | |
111 | 113 | case a: Int => | |
112 | 114 | a | |
113 | 115 | case _ => | |
114 | 116 | default_ | |
115 | 117 | } | |
116 | 118 | ||
117 | 119 | ||
118 | 120 | func _loadBigInt (key_,default_) = match getBinary(key_) { | |
119 | 121 | case a: ByteVector => | |
120 | 122 | toBigInt(a) | |
121 | 123 | case _ => | |
122 | 124 | default_ | |
123 | 125 | } | |
124 | 126 | ||
125 | 127 | ||
126 | 128 | func _loadAsset () = match getString(KEY_ASSET) { | |
127 | 129 | case a: String => | |
128 | 130 | fromBase58String(a) | |
129 | 131 | case _ => | |
130 | 132 | base58'' | |
131 | 133 | } | |
132 | 134 | ||
133 | 135 | ||
134 | 136 | func _updateStaking (asset_,amount_,adapter_) = { | |
135 | 137 | let stakingAmount = _loadInt(KEY_STAKING_AMOUNT, 0) | |
136 | 138 | let newStakingAmount = (stakingAmount + amount_) | |
137 | 139 | let invocation = if ((amount_ > 0)) | |
138 | 140 | then invoke(adapter_, FUNC_STAKE, nil, [AttachedPayment(asset_, amount_)]) | |
139 | 141 | else invoke(adapter_, FUNC_UNSTAKE, [(-1 * amount_)], nil) | |
140 | 142 | if ((invocation == invocation)) | |
141 | 143 | then [IntegerEntry(KEY_STAKING_AMOUNT, newStakingAmount)] | |
142 | 144 | else throw("Strict value is not equal to itself.") | |
143 | 145 | } | |
144 | 146 | ||
145 | 147 | ||
146 | 148 | func _checkpoint (compensation) = { | |
147 | 149 | let invocation = invoke(_loadStakingAdapter(), FUNC_CLAIM_REWARD, nil, nil) | |
148 | 150 | if ((invocation == invocation)) | |
149 | 151 | then match invocation { | |
150 | 152 | case reward: (Int, Int, Int) => | |
151 | 153 | if (compensation) | |
152 | 154 | then { | |
153 | 155 | let stake = invoke(this, FUNC_STAKE, [reward._1, reward._3], nil) | |
154 | 156 | if ((stake == stake)) | |
155 | 157 | then $Tuple2(true, reward._2) | |
156 | 158 | else throw("Strict value is not equal to itself.") | |
157 | 159 | } | |
158 | 160 | else { | |
159 | 161 | let stake = invoke(this, FUNC_STAKE, [(reward._1 + reward._2), reward._3], nil) | |
160 | 162 | if ((stake == stake)) | |
161 | 163 | then $Tuple2(true, 0) | |
162 | 164 | else throw("Strict value is not equal to itself.") | |
163 | 165 | } | |
164 | 166 | case _ => | |
165 | 167 | $Tuple2(false, 0) | |
166 | 168 | } | |
167 | 169 | else throw("Strict value is not equal to itself.") | |
168 | 170 | } | |
169 | 171 | ||
170 | 172 | ||
171 | 173 | @Callable(i) | |
172 | 174 | func init (tokenName_,tokenDescr_,baseAsset_,stakingAdapter_) = { | |
173 | 175 | let multisig = valueOrErrorMessage(getString(KEY_MULTISIG), "init: no multisig set") | |
174 | 176 | let asset = _loadAsset() | |
175 | 177 | let baseAsset = _toAssetVector(baseAsset_) | |
176 | 178 | let err = if ((i.caller != this)) | |
177 | 179 | then throw("init: permission denied") | |
178 | 180 | else if ((asset != base58'')) | |
179 | 181 | then throw("init: already initialized") | |
180 | 182 | else if (if ((4 > size(tokenName_))) | |
181 | 183 | then true | |
182 | 184 | else (size(tokenName_) > 16)) | |
183 | 185 | then throw("init: invalid token name") | |
184 | 186 | else if ((size(tokenDescr_) > 1000)) | |
185 | 187 | then throw("init: invalid token description") | |
186 | 188 | else if (!(_validateAsset(baseAsset_))) | |
187 | 189 | then throw("init: invalid base asset") | |
188 | 190 | else if (!(_validateAddress(stakingAdapter_))) | |
189 | 191 | then throw("init: invalid staking adapter") | |
190 | - | else if ((0 >= wavesBalance(this).regular)) | |
191 | - | then throw("init: no waves at this contract") | |
192 | - | else unit | |
192 | + | else unit | |
193 | 193 | if ((err == err)) | |
194 | 194 | then { | |
195 | 195 | let tokenDecimals = _getAssetDecimals(baseAsset) | |
196 | - | let issue = Issue(tokenName_, tokenDescr_, | |
196 | + | let issue = Issue(tokenName_, tokenDescr_, ONE_WAVES, tokenDecimals, true) | |
197 | 197 | let assetId = calculateAssetId(issue) | |
198 | - | let stakeActions = _updateStaking(baseAsset, | |
198 | + | let stakeActions = _updateStaking(baseAsset, ONE_WAVES, addressFromStringValue(stakingAdapter_)) | |
199 | 199 | $Tuple2(([StringEntry(KEY_BASE_ASSET, baseAsset_), StringEntry(KEY_STAKING_ADAPTER, stakingAdapter_), StringEntry(KEY_ASSET, toBase58String(assetId)), issue] ++ stakeActions), unit) | |
200 | 200 | } | |
201 | 201 | else throw("Strict value is not equal to itself.") | |
202 | 202 | } | |
203 | 203 | ||
204 | 204 | ||
205 | 205 | ||
206 | 206 | @Callable(i) | |
207 | 207 | func getRate () = { | |
208 | 208 | let lastRate = _loadBigInt(KEY_LAST_RATE, PERCENT_FACTOR) | |
209 | 209 | let currentRate = _loadBigInt(KEY_CURRENT_RATE, ZERO_BIGINT) | |
210 | 210 | let lastHeight = _loadInt(KEY_LAST_HEIGHT, 0) | |
211 | 211 | let targetHeight = min([_loadInt(KEY_TARGET_HEIGHT, 0), height]) | |
212 | 212 | let rate = (lastRate + (currentRate * toBigInt((targetHeight - lastHeight)))) | |
213 | 213 | $Tuple2(nil, toString(rate)) | |
214 | 214 | } | |
215 | 215 | ||
216 | 216 | ||
217 | 217 | ||
218 | 218 | @Callable(i) | |
219 | 219 | func checkpoint () = { | |
220 | 220 | let checkpoint = _checkpoint(true) | |
221 | 221 | if ((checkpoint == checkpoint)) | |
222 | 222 | then if (!(checkpoint._1)) | |
223 | 223 | then throw("checkpoint: no reward") | |
224 | 224 | else if ((checkpoint._2 > 0)) | |
225 | 225 | then $Tuple2([ScriptTransfer(i.originCaller, checkpoint._2, _loadBaseAsset())], unit) | |
226 | 226 | else $Tuple2(nil, unit) | |
227 | 227 | else throw("Strict value is not equal to itself.") | |
228 | 228 | } | |
229 | 229 | ||
230 | 230 | ||
231 | 231 | ||
232 | 232 | @Callable(i) | |
233 | 233 | func deposit () = { | |
234 | 234 | let caller = toString(i.caller) | |
235 | 235 | let baseAsset = _loadBaseAsset() | |
236 | 236 | let asset = _loadAsset() | |
237 | 237 | let assetQuantity = toBigInt(_getAssetQuantity(asset)) | |
238 | 238 | let err = if ((size(i.payments) != 1)) | |
239 | 239 | then throw("deposit: no payments") | |
240 | 240 | else if ((i.payments[0].assetId != baseAsset)) | |
241 | 241 | then throw("deposit: payment is not in base asset") | |
242 | 242 | else if ((0 >= i.payments[0].amount)) | |
243 | 243 | then throw("deposit: invalid payment amount") | |
244 | 244 | else unit | |
245 | 245 | if ((err == err)) | |
246 | 246 | then { | |
247 | 247 | let checkpoint = _checkpoint(false) | |
248 | 248 | if ((checkpoint == checkpoint)) | |
249 | 249 | then { | |
250 | 250 | let lastRate = _loadBigInt(KEY_LAST_RATE, PERCENT_FACTOR) | |
251 | 251 | let currentRate = _loadBigInt(KEY_CURRENT_RATE, ZERO_BIGINT) | |
252 | 252 | let lastHeight = _loadInt(KEY_LAST_HEIGHT, 0) | |
253 | 253 | let targetHeight = min([_loadInt(KEY_TARGET_HEIGHT, 0), height]) | |
254 | 254 | let lastRateUpdated = (lastRate + (currentRate * toBigInt((targetHeight - lastHeight)))) | |
255 | 255 | let issueAmount = toInt(fraction(toBigInt(i.payments[0].amount), PERCENT_FACTOR, lastRateUpdated, FLOOR)) | |
256 | 256 | let currentRateUpdated = fraction(currentRate, assetQuantity, (assetQuantity + toBigInt(issueAmount)), FLOOR) | |
257 | 257 | let lastHeightUpdated = targetHeight | |
258 | 258 | let stakeActions = _updateStaking(baseAsset, i.payments[0].amount, _loadStakingAdapter()) | |
259 | 259 | $Tuple2(([Reissue(asset, issueAmount, true), ScriptTransfer(i.caller, issueAmount, asset), BinaryEntry(KEY_LAST_RATE, toBytes(lastRateUpdated)), BinaryEntry(KEY_CURRENT_RATE, toBytes(currentRateUpdated)), IntegerEntry(KEY_LAST_HEIGHT, lastHeightUpdated)] ++ stakeActions), unit) | |
260 | 260 | } | |
261 | 261 | else throw("Strict value is not equal to itself.") | |
262 | 262 | } | |
263 | 263 | else throw("Strict value is not equal to itself.") | |
264 | 264 | } | |
265 | 265 | ||
266 | 266 | ||
267 | 267 | ||
268 | 268 | @Callable(i) | |
269 | 269 | func stake (amount_,spreadBlocks_) = { | |
270 | 270 | let caller = toString(i.caller) | |
271 | 271 | let baseAsset = _loadBaseAsset() | |
272 | 272 | let asset = _loadAsset() | |
273 | 273 | let assetQuantity = toBigInt(_getAssetQuantity(asset)) | |
274 | 274 | let err = if ((i.caller != this)) | |
275 | 275 | then throw("stake: only this contract") | |
276 | 276 | else if ((0 >= amount_)) | |
277 | 277 | then throw("stake: invalid stake amount") | |
278 | 278 | else if ((amount_ > _getAssetBalance(baseAsset, this))) | |
279 | 279 | then throw("stake: insufficient stake amount") | |
280 | 280 | else if ((assetQuantity == ZERO_BIGINT)) | |
281 | 281 | then throw("stake: no deposits to stake for") | |
282 | 282 | else unit | |
283 | 283 | if ((err == err)) | |
284 | 284 | then { | |
285 | 285 | let lastRate = _loadBigInt(KEY_LAST_RATE, PERCENT_FACTOR) | |
286 | 286 | let currentRate = _loadBigInt(KEY_CURRENT_RATE, ZERO_BIGINT) | |
287 | 287 | let lastHeight = _loadInt(KEY_LAST_HEIGHT, 0) | |
288 | 288 | let targetHeight = _loadInt(KEY_TARGET_HEIGHT, 0) | |
289 | 289 | let minTargetHeight = min([targetHeight, height]) | |
290 | 290 | let actions = if ((minTargetHeight == height)) | |
291 | 291 | then { | |
292 | 292 | let lastRateUpdated = (lastRate + (toBigInt((minTargetHeight - lastHeight)) * currentRate)) | |
293 | 293 | let remainingReward = (currentRate * toBigInt((targetHeight - minTargetHeight))) | |
294 | 294 | let currentRateUpdated = fraction(((toBigInt(amount_) * PERCENT_FACTOR) + remainingReward), ONE_BIGINT, (assetQuantity * toBigInt(spreadBlocks_))) | |
295 | 295 | let lastHeightUpdated = height | |
296 | 296 | let targetHeightUpdated = (lastHeightUpdated + spreadBlocks_) | |
297 | 297 | [BinaryEntry(KEY_LAST_RATE, toBytes(lastRateUpdated)), BinaryEntry(KEY_CURRENT_RATE, toBytes(currentRateUpdated)), IntegerEntry(KEY_LAST_HEIGHT, lastHeightUpdated), IntegerEntry(KEY_TARGET_HEIGHT, targetHeightUpdated)] | |
298 | 298 | } | |
299 | 299 | else if ((targetHeight > lastHeight)) | |
300 | 300 | then { | |
301 | 301 | let lastRateUpdated = (lastRate + (toBigInt((targetHeight - lastHeight)) * currentRate)) | |
302 | 302 | let currentRateUpdated = fraction(toBigInt(amount_), PERCENT_FACTOR, (assetQuantity * toBigInt(spreadBlocks_))) | |
303 | 303 | let lastHeightUpdated = height | |
304 | 304 | let targetHeightUpdated = (lastHeightUpdated + spreadBlocks_) | |
305 | 305 | [BinaryEntry(KEY_LAST_RATE, toBytes(lastRateUpdated)), BinaryEntry(KEY_CURRENT_RATE, toBytes(currentRateUpdated)), IntegerEntry(KEY_LAST_HEIGHT, lastHeightUpdated), IntegerEntry(KEY_TARGET_HEIGHT, targetHeightUpdated)] | |
306 | 306 | } | |
307 | 307 | else { | |
308 | 308 | let currentRateUpdated = fraction(toBigInt(amount_), PERCENT_FACTOR, (assetQuantity * toBigInt(spreadBlocks_))) | |
309 | 309 | let lastHeightUpdated = height | |
310 | 310 | let targetHeightUpdated = (lastHeightUpdated + spreadBlocks_) | |
311 | 311 | [BinaryEntry(KEY_CURRENT_RATE, toBytes(currentRateUpdated)), IntegerEntry(KEY_LAST_HEIGHT, lastHeightUpdated), IntegerEntry(KEY_TARGET_HEIGHT, targetHeightUpdated)] | |
312 | 312 | } | |
313 | 313 | let stakeActions = _updateStaking(baseAsset, amount_, _loadStakingAdapter()) | |
314 | 314 | $Tuple2((actions ++ stakeActions), unit) | |
315 | 315 | } | |
316 | 316 | else throw("Strict value is not equal to itself.") | |
317 | 317 | } | |
318 | 318 | ||
319 | 319 | ||
320 | 320 | ||
321 | 321 | @Callable(i) | |
322 | 322 | func withdraw () = { | |
323 | 323 | let caller = toString(i.caller) | |
324 | 324 | let baseAsset = _loadBaseAsset() | |
325 | 325 | let asset = _loadAsset() | |
326 | 326 | let assetQuantity = toBigInt(_getAssetQuantity(asset)) | |
327 | 327 | let err = if ((1 > size(i.payments))) | |
328 | 328 | then throw("withdraw: no payments") | |
329 | 329 | else if ((i.payments[0].assetId != asset)) | |
330 | 330 | then throw("withdraw: payment is not in correct asset") | |
331 | 331 | else if ((0 >= i.payments[0].amount)) | |
332 | 332 | then throw("withdraw: invalid payment amount") | |
333 | 333 | else unit | |
334 | 334 | if ((err == err)) | |
335 | 335 | then { | |
336 | 336 | let checkpoint = _checkpoint(false) | |
337 | 337 | if ((checkpoint == checkpoint)) | |
338 | 338 | then { | |
339 | 339 | let lastRate = _loadBigInt(KEY_LAST_RATE, PERCENT_FACTOR) | |
340 | 340 | let currentRate = _loadBigInt(KEY_CURRENT_RATE, ZERO_BIGINT) | |
341 | 341 | let lastHeight = _loadInt(KEY_LAST_HEIGHT, 0) | |
342 | 342 | let targetHeight = min([_loadInt(KEY_TARGET_HEIGHT, 0), height]) | |
343 | 343 | let lastRateUpdated = (lastRate + (currentRate * toBigInt((targetHeight - lastHeight)))) | |
344 | 344 | let baseAmount = toInt(fraction(toBigInt(i.payments[0].amount), lastRateUpdated, PERCENT_FACTOR, FLOOR)) | |
345 | 345 | let currentRateUpdated = fraction(currentRate, assetQuantity, (assetQuantity - toBigInt(i.payments[0].amount)), FLOOR) | |
346 | 346 | let lastHeightUpdated = targetHeight | |
347 | 347 | let stakeActions = _updateStaking(baseAsset, (-1 * baseAmount), _loadStakingAdapter()) | |
348 | 348 | $Tuple2((stakeActions ++ [Burn(asset, i.payments[0].amount), ScriptTransfer(i.caller, baseAmount, unit), BinaryEntry(KEY_LAST_RATE, toBytes(lastRateUpdated)), BinaryEntry(KEY_CURRENT_RATE, toBytes(currentRateUpdated)), IntegerEntry(KEY_LAST_HEIGHT, lastHeightUpdated)]), unit) | |
349 | 349 | } | |
350 | 350 | else throw("Strict value is not equal to itself.") | |
351 | 351 | } | |
352 | 352 | else throw("Strict value is not equal to itself.") | |
353 | 353 | } | |
354 | 354 | ||
355 | 355 | ||
356 | 356 | ||
357 | 357 | @Callable(i) | |
358 | 358 | func setMultisig (multisig_) = { | |
359 | 359 | let err = if ((i.caller != this)) | |
360 | 360 | then throw("setMultisig: permission denied") | |
361 | 361 | else if (!(_validateAddress(multisig_))) | |
362 | 362 | then throw("setMultisig: invalid multisig address") | |
363 | 363 | else unit | |
364 | 364 | if ((err == err)) | |
365 | 365 | then $Tuple2([StringEntry(KEY_MULTISIG, multisig_)], unit) | |
366 | 366 | else throw("Strict value is not equal to itself.") | |
367 | 367 | } | |
368 | 368 | ||
369 | 369 | ||
370 | 370 | @Verifier(tx) | |
371 | 371 | func verify () = match getString(KEY_MULTISIG) { | |
372 | 372 | case multisig: String => | |
373 | 373 | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
374 | 374 | case _ => | |
375 | 375 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
376 | 376 | } | |
377 | 377 |
github/deemru/w8io/169f3d6 81.68 ms ◑