tx · 2Nf3iCgG9ABAJCYB6DfZVcUTgkXfHGfM3BuT8GonDx8a 3N3kKNoJohjVQYNLTrYTGTesr3nq3PZNh37: -0.02400000 Waves 2024.06.03 16:58 [3134594] smart account 3N3kKNoJohjVQYNLTrYTGTesr3nq3PZNh37 > SELF 0.00000000 Waves
{ "type": 13, "id": "2Nf3iCgG9ABAJCYB6DfZVcUTgkXfHGfM3BuT8GonDx8a", "fee": 2400000, "feeAssetId": null, "timestamp": 1717423201584, "version": 2, "chainId": 84, "sender": "3N3kKNoJohjVQYNLTrYTGTesr3nq3PZNh37", "senderPublicKey": "vmMXxwQAMUAoisvL193ptPiTtaWQqL5YNu2zs1ouTbY", "proofs": [ "2UGrAnm2Z9U5yaam2KPVJVJqRscvjCoSFCBhCDz9kW3BseMT6r7BWMKB4h7PEtdKKueY8KBAep5hAanDvjreXif4" ], "script": "base64:BwI9CAISAwoBCBIECgICGBIECgICGBIECgICGBIECgICGBIECgICGBIECgICGBIECgICGBIECgICGBIECgICGFgACXNlcGFyYXRvcgICX18AB2NoYWluSWQJAMkBAgkAygECCAUEdGhpcwVieXRlcwABAAEACGNoYWluSWRXAQFXABBjb250cmFjdEZpbGVuYW1lAhdmdXR1cmVzX2NhbGN1bGF0b3IucmlkZQAFbXVsdDgAgMLXLwAMbXVsdDE4QmlnSW50CQC2AgEAgICQu7rWrfANAA13YXZlc0RlY2ltYWxzAAgADHVzZHREZWNpbWFscwAGAAt3YXZlc1N0cmluZwIFV0FWRVMADXF1ZXVlSXRlbVNpemUAIAAEYmlnMAkAtgIBAAAACWtNdWx0aXNpZwIMJXNfX211bHRpc2lnAQdrU3RhdHVzAgRkYXBwBHR4SWQJALkJAgkAzAgCAgolc19fc3RhdHVzCQDMCAIFBGRhcHAJAMwIAgUEdHhJZAUDbmlsBQlzZXBhcmF0b3IACWtTaHV0ZG93bgIMJXNfX3NodXRkb3duAAtrUHVibGljS2V5cwIOJXNfX3B1YmxpY0tleXMAEWtNYXRjaGVyUHVibGlj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cFBnN0YXR1cwcJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXk2zLnq", "height": 3134594, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3gheT5Mo9ByFriByEeXCzrD3Z8nQsPWFkoMM6fbbbydC Next: FSXVFXuy72n2upcR5xhsLwmz2rWuNHZwNqY83WBRsLLa Diff:
Old | New | Differences | |
---|---|---|---|
165 | 165 | func kLeverage (accountAddress) = makeString(["%s%s", "leverage", toString(accountAddress)], separator) | |
166 | 166 | ||
167 | 167 | ||
168 | + | func kRequestLeverage (requestId) = makeString(["%s%s", "requestLeverage", toBase58String(requestId)], separator) | |
169 | + | ||
170 | + | ||
168 | 171 | func kSyntheticAssetId (baseAssetId) = makeString(["%s%s", "syntheticAssetId", assetIdToString(baseAssetId)], separator) | |
169 | 172 | ||
170 | 173 | ||
320 | 323 | then { | |
321 | 324 | let amountAssetIdStr = args[0] | |
322 | 325 | let priceAssetIdStr = args[1] | |
326 | + | let leverage = valueOrErrorMessage(parseInt(args[2]), wrapErr("invalid leverage")) | |
323 | 327 | let userAddress = addressFromPublicKey(callerPublicKey) | |
324 | 328 | let requestId = sha256(((userAddress.bytes + fromBase58String(amountAssetIdStr)) + fromBase58String(priceAssetIdStr))) | |
325 | 329 | let amountAssetId = parseAssetId(amountAssetIdStr) | |
340 | 344 | else throwErr(("accounts limit is " + toString(accountsLimit())))] | |
341 | 345 | if ((checks == checks)) | |
342 | 346 | then { | |
343 | - | let $ | |
344 | - | then $Tuple2([ScriptTransfer(factoryAddress, rewardAmount(), unit)], [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_EMPTY], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), (requestsQueue() + requestId)], nil)]) | |
347 | + | let $t01172813262 = if ((size(accountsQueue()) == 0)) | |
348 | + | then $Tuple2([ScriptTransfer(factoryAddress, rewardAmount(), unit)], [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_EMPTY], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), (requestsQueue() + requestId)], nil), invoke(factoryAddress, "integerEntry", [kRequestLeverage(requestId), leverage], nil)]) | |
345 | 349 | else { | |
346 | 350 | let accountPublicKey = take(accountsQueue(), queueItemSize) | |
347 | 351 | let accountAddress = addressFromPublicKey(accountPublicKey) | |
348 | 352 | let creatorAddress = addressFromPublicKey(valueOrErrorMessage(getBinary(factoryAddress, kAccountCreatorPublicKey(accountAddress)), wrapErr("invalid creator public key"))) | |
349 | - | $Tuple2([ScriptTransfer(creatorAddress, rewardAmount(), unit)], [invoke(factoryAddress, "binaryEntry", [kAccountsQueue(), drop(accountsQueue(), queueItemSize)], nil), invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil)]) | |
353 | + | $Tuple2([ScriptTransfer(creatorAddress, rewardAmount(), unit)], [invoke(factoryAddress, "binaryEntry", [kAccountsQueue(), drop(accountsQueue(), queueItemSize)], nil), invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil), invoke(factoryAddress, "integerEntry", [kLeverage(accountAddress), leverage], nil)]) | |
350 | 354 | } | |
351 | - | let actions = $ | |
352 | - | let factoryActions = $ | |
355 | + | let actions = $t01172813262._1 | |
356 | + | let factoryActions = $t01172813262._2 | |
353 | 357 | $Tuple2(actions, (factoryActions ++ [invoke(factoryAddress, "binaryEntry", [kRequestOwnerPublicKey(requestId), callerPublicKey], nil), invoke(factoryAddress, "binaryEntry", [kRequestsByOwner(userAddress), (requestsByOwner(userAddress) + requestId)], nil), invoke(factoryAddress, "stringEntry", [kRequestAmountAssetId(requestId), amountAssetIdStr], nil), invoke(factoryAddress, "stringEntry", [kRequestPriceAssetId(requestId), priceAssetIdStr], nil)])) | |
354 | 358 | } | |
355 | 359 | else throw("Strict value is not equal to itself.") | |
382 | 386 | else throwErr("invalid script")] | |
383 | 387 | if ((checks == checks)) | |
384 | 388 | then { | |
385 | - | let $ | |
389 | + | let $t01451715759 = if ((size(requestsQueue()) == 0)) | |
386 | 390 | then $Tuple2(nil, [invoke(factoryAddress, "binaryEntry", [kAccountsQueue(), (accountsQueue() + accountPublicKey)], nil)]) | |
387 | 391 | else { | |
388 | 392 | let requestId = take(requestsQueue(), queueItemSize) | |
389 | - | $Tuple2(nil, [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), drop(requestsQueue(), queueItemSize)], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil), invoke(factoryAddress, "transferWaves", [creatorAddress.bytes, rewardAmount()], nil)]) | |
393 | + | let leverage = valueOrErrorMessage(getInteger(factoryAddress, kRequestLeverage(requestId)), wrapErr("request's leverage is undefined")) | |
394 | + | $Tuple2(nil, [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), drop(requestsQueue(), queueItemSize)], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil), invoke(factoryAddress, "transferWaves", [creatorAddress.bytes, rewardAmount()], nil), invoke(factoryAddress, "integerEntry", [kLeverage(accountAddress), leverage], nil)]) | |
390 | 395 | } | |
391 | - | let actions = $ | |
392 | - | let factoryActions = $ | |
396 | + | let actions = $t01451715759._1 | |
397 | + | let factoryActions = $t01451715759._2 | |
393 | 398 | $Tuple2(actions, (factoryActions ++ [invoke(factoryAddress, "binaryEntry", [kAccountCreatorPublicKey(accountAddress), creatorPublicKey], nil)])) | |
394 | 399 | } | |
395 | 400 | else throw("Strict value is not equal to itself.") | |
462 | 467 | let creditA = toX18(valueOrElse(getInteger(factoryAddress, kCredit(accountAddress, amountAssetId)), 0), pow10Decimals(amountAssetId)) | |
463 | 468 | let creditB = toX18(valueOrElse(getInteger(factoryAddress, kCredit(accountAddress, usdtAssetId)), 0), pow10Decimals(usdtAssetId)) | |
464 | 469 | let totalCredit = calcTotalCredit(creditA, creditB, currentPrice) | |
465 | - | let leverageDefault = 3 | |
466 | - | let leverage = toX18(valueOrElse(getInteger(factoryAddress, kLeverage(accountAddress)), leverageDefault), 1) | |
470 | + | let leverage = toX18(valueOrErrorMessage(getInteger(factoryAddress, kLeverage(accountAddress)), wrapErr("leverage should be defined")), 1) | |
467 | 471 | let creditAvailableUsdt = calcCreditAvailable(deposited, leverage, totalCredit) | |
468 | 472 | let creditAvailable = if ((assetIdRequested == amountAssetId)) | |
469 | 473 | then fromX18(fraction(creditAvailableUsdt, mult18BigInt, currentPrice), pow10Decimals(amountAssetId)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 7 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | 5 | ||
6 | 6 | let chainId = take(drop(this.bytes, 1), 1) | |
7 | 7 | ||
8 | 8 | let chainIdW = base58'2W' | |
9 | 9 | ||
10 | 10 | let contractFilename = "futures_calculator.ride" | |
11 | 11 | ||
12 | 12 | let mult8 = 100000000 | |
13 | 13 | ||
14 | 14 | let mult18BigInt = toBigInt(1000000000000000000) | |
15 | 15 | ||
16 | 16 | let wavesDecimals = 8 | |
17 | 17 | ||
18 | 18 | let usdtDecimals = 6 | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let queueItemSize = 32 | |
23 | 23 | ||
24 | 24 | let big0 = toBigInt(0) | |
25 | 25 | ||
26 | 26 | let kMultisig = "%s__multisig" | |
27 | 27 | ||
28 | 28 | func kStatus (dapp,txId) = makeString(["%s__status", dapp, txId], separator) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | let kShutdown = "%s__shutdown" | |
32 | 32 | ||
33 | 33 | let kPublicKeys = "%s__publicKeys" | |
34 | 34 | ||
35 | 35 | let kMatcherPublicKey = "%s__matcherPublicKey" | |
36 | 36 | ||
37 | 37 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), mult18BigInt, toBigInt(origScaleMult)) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), mult18BigInt)) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func validateAddress (address) = isDefined(addressFromString(address)) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func wrapErr (s) = ((contractFilename + ": ") + s) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func throwErr (s) = throw(wrapErr(s)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func ensurePositive (v,s) = if ((v >= 0)) | |
53 | 53 | then v | |
54 | 54 | else throwErr((s + " value should be positive")) | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func parseAssetId (input) = if ((input == wavesString)) | |
58 | 58 | then unit | |
59 | 59 | else fromBase58String(input) | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func assetIdToString (input) = if ((input == unit)) | |
63 | 63 | then wavesString | |
64 | 64 | else toBase58String(value(input)) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func getAssetInfoOrFail (assetId) = valueOrErrorMessage(assetInfo(assetId), wrapErr("invalid asset info")) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func getAssetDecimalsOrFail (assetId) = match assetId { | |
71 | 71 | case _: Unit => | |
72 | 72 | wavesDecimals | |
73 | 73 | case assetId: ByteVector => | |
74 | 74 | getAssetInfoOrFail(assetId).decimals | |
75 | 75 | case _ => | |
76 | 76 | throw("Match error") | |
77 | 77 | } | |
78 | 78 | ||
79 | 79 | ||
80 | 80 | func pow10 (n) = pow(10, 0, n, 0, 0, DOWN) | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | func pow10Decimals (assetId) = pow10(getAssetDecimalsOrFail(assetId)) | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | let kFactoryAddress = "%s__factoryAddress" | |
87 | 87 | ||
88 | 88 | let factoryAddressOption = match getString(this, kFactoryAddress) { | |
89 | 89 | case s: String => | |
90 | 90 | addressFromString(s) | |
91 | 91 | case _: Unit => | |
92 | 92 | unit | |
93 | 93 | case _ => | |
94 | 94 | throw("Match error") | |
95 | 95 | } | |
96 | 96 | ||
97 | 97 | let factoryAddress = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) | |
98 | 98 | ||
99 | 99 | let kUsdtAssetId = "%s__usdtAssetId" | |
100 | 100 | ||
101 | 101 | let usdtAssetIdOption = match getString(factoryAddress, kUsdtAssetId) { | |
102 | 102 | case s: String => | |
103 | 103 | parseAssetId(s) | |
104 | 104 | case _: Unit => | |
105 | 105 | unit | |
106 | 106 | case _ => | |
107 | 107 | throw("Match error") | |
108 | 108 | } | |
109 | 109 | ||
110 | 110 | let usdtAssetId = valueOrErrorMessage(usdtAssetIdOption, wrapErr("invalid usdt asset id")) | |
111 | 111 | ||
112 | 112 | let kPricesAddress = "%s__calculatorAddress" | |
113 | 113 | ||
114 | 114 | let shutdown = valueOrElse(getBoolean(factoryAddress, kShutdown), false) | |
115 | 115 | ||
116 | 116 | func mustAddress (caller,address) = if ((caller == address)) | |
117 | 117 | then true | |
118 | 118 | else throwErr("permission denied") | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func mustThis (caller) = mustAddress(caller, this) | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | func mustFactory (caller) = mustAddress(caller, factoryAddress) | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func mustAdmin (callerPublicKey) = { | |
128 | 128 | let multisig = addressFromStringValue(getStringValue(factoryAddress, kMultisig)) | |
129 | 129 | let publicKeysList = split(getStringValue(multisig, kPublicKeys), separator) | |
130 | 130 | if (containsElement(publicKeysList, toBase58String(callerPublicKey))) | |
131 | 131 | then true | |
132 | 132 | else throwErr("not allowed") | |
133 | 133 | } | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | let kAccountScript = "%s__accountScript" | |
137 | 137 | ||
138 | 138 | func accountScript () = valueOrErrorMessage(getBinary(factoryAddress, kAccountScript), wrapErr("account script is not set")) | |
139 | 139 | ||
140 | 140 | ||
141 | 141 | let kRewardAmount = "%s__rewardAmount" | |
142 | 142 | ||
143 | 143 | func rewardAmount () = valueOrErrorMessage(getInteger(factoryAddress, kRewardAmount), wrapErr("reward amount is not set")) | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | let kAccountsLimit = "%s__accountsLimit" | |
147 | 147 | ||
148 | 148 | let accountsLimitDefault = 20 | |
149 | 149 | ||
150 | 150 | func accountsLimit () = valueOrElse(getInteger(factoryAddress, kAccountsLimit), accountsLimitDefault) | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | func kDeposited (accountAddress) = makeString(["%s%s", "deposited", toString(accountAddress)], separator) | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | func depositedOption (accountAddress) = getInteger(factoryAddress, kDeposited(accountAddress)) | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | func kCredit (accountAddress,assetId) = makeString(["%s%s%s", "credit", toString(accountAddress), assetIdToString(assetId)], separator) | |
160 | 160 | ||
161 | 161 | ||
162 | 162 | func creditOption (accountAddress,assetId) = getInteger(factoryAddress, kCredit(accountAddress, assetId)) | |
163 | 163 | ||
164 | 164 | ||
165 | 165 | func kLeverage (accountAddress) = makeString(["%s%s", "leverage", toString(accountAddress)], separator) | |
166 | 166 | ||
167 | 167 | ||
168 | + | func kRequestLeverage (requestId) = makeString(["%s%s", "requestLeverage", toBase58String(requestId)], separator) | |
169 | + | ||
170 | + | ||
168 | 171 | func kSyntheticAssetId (baseAssetId) = makeString(["%s%s", "syntheticAssetId", assetIdToString(baseAssetId)], separator) | |
169 | 172 | ||
170 | 173 | ||
171 | 174 | func kBaseAssetId (syntheticAssetId) = makeString(["%s%s", "baseAssetId", assetIdToString(syntheticAssetId)], separator) | |
172 | 175 | ||
173 | 176 | ||
174 | 177 | let REQUEST_STATUS_EMPTY = 0 | |
175 | 178 | ||
176 | 179 | let REQUEST_STATUS_READY = 1 | |
177 | 180 | ||
178 | 181 | func kRequestStatus (requestId) = makeString(["%s%s", toBase58String(requestId), "status"], separator) | |
179 | 182 | ||
180 | 183 | ||
181 | 184 | func kAccountCreatorPublicKey (accountAddress) = makeString(["%s%s", toString(accountAddress), "creatorPublicKey"], separator) | |
182 | 185 | ||
183 | 186 | ||
184 | 187 | func kRequestOwnerPublicKey (requestId) = makeString(["%s%s", toBase58String(requestId), "ownerPublicKey"], separator) | |
185 | 188 | ||
186 | 189 | ||
187 | 190 | func kRequestAmountAssetId (requestId) = makeString(["%s%s", toBase58String(requestId), "amountAssetId"], separator) | |
188 | 191 | ||
189 | 192 | ||
190 | 193 | func kRequestPriceAssetId (requestId) = makeString(["%s%s", toBase58String(requestId), "priceAssetId"], separator) | |
191 | 194 | ||
192 | 195 | ||
193 | 196 | func kRequestIdToAccountPublicKey (requestId) = makeString(["%s%s", toBase58String(requestId), "requestIdToAccountPublicKey"], separator) | |
194 | 197 | ||
195 | 198 | ||
196 | 199 | func kAccountAddressToRequestId (accountAddress) = makeString(["%s%s", toString(accountAddress), "accountAddressToRequestId"], separator) | |
197 | 200 | ||
198 | 201 | ||
199 | 202 | func kRequestsQueue () = makeString(["%s", "requestsQueue"], separator) | |
200 | 203 | ||
201 | 204 | ||
202 | 205 | func requestsQueue () = valueOrElse(getBinary(factoryAddress, kRequestsQueue()), base58'') | |
203 | 206 | ||
204 | 207 | ||
205 | 208 | func kAccountsQueue () = makeString(["%s", "accountsQueue"], separator) | |
206 | 209 | ||
207 | 210 | ||
208 | 211 | func accountsQueue () = valueOrElse(getBinary(factoryAddress, kAccountsQueue()), base58'') | |
209 | 212 | ||
210 | 213 | ||
211 | 214 | func kRequestsByOwner (ownerAddress) = makeString(["%s%s", "requests", toString(ownerAddress)], separator) | |
212 | 215 | ||
213 | 216 | ||
214 | 217 | func requestsByOwner (ownerAddress) = valueOrElse(getBinary(factoryAddress, kRequestsByOwner(ownerAddress)), base58'') | |
215 | 218 | ||
216 | 219 | ||
217 | 220 | func kPairAllowed (amountAssetId,priceAssetId) = makeString(["%s%s%s", assetIdToString(amountAssetId), assetIdToString(priceAssetId), "pairAllowed"], separator) | |
218 | 221 | ||
219 | 222 | ||
220 | 223 | func pairAllowed (amountAssetId,priceAssetId) = valueOrElse(getBoolean(factoryAddress, kPairAllowed(amountAssetId, priceAssetId)), false) | |
221 | 224 | ||
222 | 225 | ||
223 | 226 | func kPrice (assetId) = makeString(["%s", assetIdToString(assetId)], separator) | |
224 | 227 | ||
225 | 228 | ||
226 | 229 | func getCurrentPrice (assetId) = { | |
227 | 230 | let matcherPublicKey = fromBase58String(valueOrErrorMessage(getString(factoryAddress, kMatcherPublicKey), wrapErr("invalid matcher public key"))) | |
228 | 231 | let matcherAddress = addressFromPublicKey(matcherPublicKey) | |
229 | 232 | let price = valueOrErrorMessage(getInteger(matcherAddress, kPrice(assetId)), wrapErr(("invalid price, assetId = " + assetIdToString(assetId)))) | |
230 | 233 | price | |
231 | 234 | } | |
232 | 235 | ||
233 | 236 | ||
234 | 237 | func calcTotalCredit (creditA,creditB,currentPrice) = (fraction(creditA, currentPrice, mult18BigInt) + creditB) | |
235 | 238 | ||
236 | 239 | ||
237 | 240 | func calcTotalBalance (balanceA,balanceB,currentPrice) = (fraction(balanceA, currentPrice, mult18BigInt) + balanceB) | |
238 | 241 | ||
239 | 242 | ||
240 | 243 | func calcPnl (totalBalance,totalCredit) = (totalBalance - totalCredit) | |
241 | 244 | ||
242 | 245 | ||
243 | 246 | func calcCreditAvailable (deposit,leverage,totalCredit) = (fraction(deposit, leverage, mult18BigInt) - totalCredit) | |
244 | 247 | ||
245 | 248 | ||
246 | 249 | func calcRealInCredit (credit,balance) = if ((credit > big0)) | |
247 | 250 | then (credit - balance) | |
248 | 251 | else big0 | |
249 | 252 | ||
250 | 253 | ||
251 | 254 | func calcFree (credit,balance) = if ((credit > big0)) | |
252 | 255 | then (balance - credit) | |
253 | 256 | else big0 | |
254 | 257 | ||
255 | 258 | ||
256 | 259 | func calcShortPrice (free,realInCredit) = if ((realInCredit > big0)) | |
257 | 260 | then max([big0, fraction(free, mult18BigInt, realInCredit)]) | |
258 | 261 | else big0 | |
259 | 262 | ||
260 | 263 | ||
261 | 264 | func calcLongPrice (free,realInCredit) = if ((realInCredit > big0)) | |
262 | 265 | then max([big0, fraction(realInCredit, mult18BigInt, free)]) | |
263 | 266 | else big0 | |
264 | 267 | ||
265 | 268 | ||
266 | 269 | func calcStartMargin (realInCreditA,realInCreditB,currentPrice,settingsMargin) = fraction((fraction(realInCreditA, currentPrice, mult18BigInt) + realInCreditB), settingsMargin, mult18BigInt) | |
267 | 270 | ||
268 | 271 | ||
269 | 272 | func calcMarginSupply (settingsMarginSupply,settingsMargin,startMargin) = fraction(settingsMarginSupply, startMargin, settingsMargin) | |
270 | 273 | ||
271 | 274 | ||
272 | 275 | func calcLiquidationPrice (deposit,marginSupply,realInCreditA,realInCreditB,shortPrice,longPrice) = { | |
273 | 276 | let liquidationPriceA = if ((realInCreditA > big0)) | |
274 | 277 | then (((deposit - marginSupply) / realInCreditA) + shortPrice) | |
275 | 278 | else big0 | |
276 | 279 | let liquidationPriceB = if ((realInCreditB > big0)) | |
277 | 280 | then (longPrice - ((deposit - marginSupply) / (realInCreditA / longPrice))) | |
278 | 281 | else big0 | |
279 | 282 | (liquidationPriceA + liquidationPriceB) | |
280 | 283 | } | |
281 | 284 | ||
282 | 285 | ||
283 | 286 | func getRequestId (accountAddress) = { | |
284 | 287 | let requestId = fromBase58String(valueOrErrorMessage(getString(factoryAddress, kAccountAddressToRequestId(accountAddress)), wrapErr("invalid account address: request id is undefined"))) | |
285 | 288 | requestId | |
286 | 289 | } | |
287 | 290 | ||
288 | 291 | ||
289 | 292 | func getAccountAssets (accountAddress) = { | |
290 | 293 | let requestId = getRequestId(accountAddress) | |
291 | 294 | let amountAssetId = parseAssetId(valueOrErrorMessage(getString(factoryAddress, kRequestAmountAssetId(requestId)), wrapErr("invalid amount asset id"))) | |
292 | 295 | let priceAssetId = parseAssetId(valueOrErrorMessage(getString(factoryAddress, kRequestPriceAssetId(requestId)), wrapErr("invalid amount price id"))) | |
293 | 296 | $Tuple2(amountAssetId, priceAssetId) | |
294 | 297 | } | |
295 | 298 | ||
296 | 299 | ||
297 | 300 | func getAccountOwnerPublicKey (accountAddress) = { | |
298 | 301 | let requestId = getRequestId(accountAddress) | |
299 | 302 | let requestOwnerPublicKey = valueOrErrorMessage(getBinary(factoryAddress, kRequestOwnerPublicKey(requestId)), wrapErr("invalid amount asset id")) | |
300 | 303 | requestOwnerPublicKey | |
301 | 304 | } | |
302 | 305 | ||
303 | 306 | ||
304 | 307 | @Callable(i) | |
305 | 308 | func init (factoryAddressStr) = { | |
306 | 309 | let checkCaller = mustThis(i.caller) | |
307 | 310 | if ((checkCaller == checkCaller)) | |
308 | 311 | then $Tuple2([StringEntry(kFactoryAddress, factoryAddressStr)], unit) | |
309 | 312 | else throw("Strict value is not equal to itself.") | |
310 | 313 | } | |
311 | 314 | ||
312 | 315 | ||
313 | 316 | ||
314 | 317 | @Callable(i) | |
315 | 318 | func requestAccount (callerPublicKey,args) = { | |
316 | 319 | let ckecks = [if (!(shutdown)) | |
317 | 320 | then true | |
318 | 321 | else throwErr("not allowed"), mustFactory(i.caller)] | |
319 | 322 | if ((ckecks == ckecks)) | |
320 | 323 | then { | |
321 | 324 | let amountAssetIdStr = args[0] | |
322 | 325 | let priceAssetIdStr = args[1] | |
326 | + | let leverage = valueOrErrorMessage(parseInt(args[2]), wrapErr("invalid leverage")) | |
323 | 327 | let userAddress = addressFromPublicKey(callerPublicKey) | |
324 | 328 | let requestId = sha256(((userAddress.bytes + fromBase58String(amountAssetIdStr)) + fromBase58String(priceAssetIdStr))) | |
325 | 329 | let amountAssetId = parseAssetId(amountAssetIdStr) | |
326 | 330 | let priceAssetId = parseAssetId(priceAssetIdStr) | |
327 | 331 | let userRequestsNumber = (size(kRequestsByOwner(userAddress)) / queueItemSize) | |
328 | 332 | let checks = [if ((size(i.payments) == 1)) | |
329 | 333 | then true | |
330 | 334 | else throwErr("1 payment is required"), if ((i.payments[0].assetId == unit)) | |
331 | 335 | then true | |
332 | 336 | else throwErr("invalid asset"), if ((i.payments[0].amount == rewardAmount())) | |
333 | 337 | then true | |
334 | 338 | else throwErr("invalid amount"), if (pairAllowed(amountAssetId, priceAssetId)) | |
335 | 339 | then true | |
336 | 340 | else throwErr("pair is not allowed"), if ((getInteger(factoryAddress, kRequestStatus(requestId)) == unit)) | |
337 | 341 | then true | |
338 | 342 | else throwErr("account is already exists"), if ((accountsLimit() > userRequestsNumber)) | |
339 | 343 | then true | |
340 | 344 | else throwErr(("accounts limit is " + toString(accountsLimit())))] | |
341 | 345 | if ((checks == checks)) | |
342 | 346 | then { | |
343 | - | let $ | |
344 | - | then $Tuple2([ScriptTransfer(factoryAddress, rewardAmount(), unit)], [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_EMPTY], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), (requestsQueue() + requestId)], nil)]) | |
347 | + | let $t01172813262 = if ((size(accountsQueue()) == 0)) | |
348 | + | then $Tuple2([ScriptTransfer(factoryAddress, rewardAmount(), unit)], [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_EMPTY], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), (requestsQueue() + requestId)], nil), invoke(factoryAddress, "integerEntry", [kRequestLeverage(requestId), leverage], nil)]) | |
345 | 349 | else { | |
346 | 350 | let accountPublicKey = take(accountsQueue(), queueItemSize) | |
347 | 351 | let accountAddress = addressFromPublicKey(accountPublicKey) | |
348 | 352 | let creatorAddress = addressFromPublicKey(valueOrErrorMessage(getBinary(factoryAddress, kAccountCreatorPublicKey(accountAddress)), wrapErr("invalid creator public key"))) | |
349 | - | $Tuple2([ScriptTransfer(creatorAddress, rewardAmount(), unit)], [invoke(factoryAddress, "binaryEntry", [kAccountsQueue(), drop(accountsQueue(), queueItemSize)], nil), invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil)]) | |
353 | + | $Tuple2([ScriptTransfer(creatorAddress, rewardAmount(), unit)], [invoke(factoryAddress, "binaryEntry", [kAccountsQueue(), drop(accountsQueue(), queueItemSize)], nil), invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil), invoke(factoryAddress, "integerEntry", [kLeverage(accountAddress), leverage], nil)]) | |
350 | 354 | } | |
351 | - | let actions = $ | |
352 | - | let factoryActions = $ | |
355 | + | let actions = $t01172813262._1 | |
356 | + | let factoryActions = $t01172813262._2 | |
353 | 357 | $Tuple2(actions, (factoryActions ++ [invoke(factoryAddress, "binaryEntry", [kRequestOwnerPublicKey(requestId), callerPublicKey], nil), invoke(factoryAddress, "binaryEntry", [kRequestsByOwner(userAddress), (requestsByOwner(userAddress) + requestId)], nil), invoke(factoryAddress, "stringEntry", [kRequestAmountAssetId(requestId), amountAssetIdStr], nil), invoke(factoryAddress, "stringEntry", [kRequestPriceAssetId(requestId), priceAssetIdStr], nil)])) | |
354 | 358 | } | |
355 | 359 | else throw("Strict value is not equal to itself.") | |
356 | 360 | } | |
357 | 361 | else throw("Strict value is not equal to itself.") | |
358 | 362 | } | |
359 | 363 | ||
360 | 364 | ||
361 | 365 | ||
362 | 366 | @Callable(i) | |
363 | 367 | func addAccount (callerPublicKey,args) = { | |
364 | 368 | let ckecks = [if (!(shutdown)) | |
365 | 369 | then true | |
366 | 370 | else throwErr("not allowed"), mustFactory(i.caller)] | |
367 | 371 | if ((ckecks == ckecks)) | |
368 | 372 | then { | |
369 | 373 | let creatorPublicKey = fromBase58String(args[0]) | |
370 | 374 | let accountPublicKey = callerPublicKey | |
371 | 375 | let accountAddress = addressFromPublicKey(callerPublicKey) | |
372 | 376 | let creatorAddress = addressFromPublicKey(creatorPublicKey) | |
373 | 377 | let checks = [if ((getBinary(factoryAddress, kAccountCreatorPublicKey(accountAddress)) == unit)) | |
374 | 378 | then true | |
375 | 379 | else throwErr("account is already exists"), if ( match scriptHash(accountAddress) { | |
376 | 380 | case b: ByteVector => | |
377 | 381 | (b == blake2b256_32Kb(accountScript())) | |
378 | 382 | case _ => | |
379 | 383 | false | |
380 | 384 | }) | |
381 | 385 | then true | |
382 | 386 | else throwErr("invalid script")] | |
383 | 387 | if ((checks == checks)) | |
384 | 388 | then { | |
385 | - | let $ | |
389 | + | let $t01451715759 = if ((size(requestsQueue()) == 0)) | |
386 | 390 | then $Tuple2(nil, [invoke(factoryAddress, "binaryEntry", [kAccountsQueue(), (accountsQueue() + accountPublicKey)], nil)]) | |
387 | 391 | else { | |
388 | 392 | let requestId = take(requestsQueue(), queueItemSize) | |
389 | - | $Tuple2(nil, [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), drop(requestsQueue(), queueItemSize)], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil), invoke(factoryAddress, "transferWaves", [creatorAddress.bytes, rewardAmount()], nil)]) | |
393 | + | let leverage = valueOrErrorMessage(getInteger(factoryAddress, kRequestLeverage(requestId)), wrapErr("request's leverage is undefined")) | |
394 | + | $Tuple2(nil, [invoke(factoryAddress, "integerEntry", [kRequestStatus(requestId), REQUEST_STATUS_READY], nil), invoke(factoryAddress, "binaryEntry", [kRequestIdToAccountPublicKey(requestId), accountPublicKey], nil), invoke(factoryAddress, "binaryEntry", [kRequestsQueue(), drop(requestsQueue(), queueItemSize)], nil), invoke(factoryAddress, "stringEntry", [kAccountAddressToRequestId(accountAddress), toBase58String(requestId)], nil), invoke(factoryAddress, "transferWaves", [creatorAddress.bytes, rewardAmount()], nil), invoke(factoryAddress, "integerEntry", [kLeverage(accountAddress), leverage], nil)]) | |
390 | 395 | } | |
391 | - | let actions = $ | |
392 | - | let factoryActions = $ | |
396 | + | let actions = $t01451715759._1 | |
397 | + | let factoryActions = $t01451715759._2 | |
393 | 398 | $Tuple2(actions, (factoryActions ++ [invoke(factoryAddress, "binaryEntry", [kAccountCreatorPublicKey(accountAddress), creatorPublicKey], nil)])) | |
394 | 399 | } | |
395 | 400 | else throw("Strict value is not equal to itself.") | |
396 | 401 | } | |
397 | 402 | else throw("Strict value is not equal to itself.") | |
398 | 403 | } | |
399 | 404 | ||
400 | 405 | ||
401 | 406 | ||
402 | 407 | @Callable(i) | |
403 | 408 | func deposit (callerPublicKey,args) = { | |
404 | 409 | let payment = i.payments[0] | |
405 | 410 | let accountAddress = valueOrErrorMessage(addressFromString(args[0]), wrapErr("invalid account address")) | |
406 | 411 | let ckecks = [if (!(shutdown)) | |
407 | 412 | then true | |
408 | 413 | else throwErr("not allowed"), mustFactory(i.caller), if ((size(i.payments) == 1)) | |
409 | 414 | then true | |
410 | 415 | else throwErr("1 payment is required"), if ((payment.assetId == usdtAssetId)) | |
411 | 416 | then true | |
412 | 417 | else throwErr("invalid asset"), if ((getInteger(factoryAddress, kRequestStatus(getRequestId(accountAddress))) == REQUEST_STATUS_READY)) | |
413 | 418 | then true | |
414 | 419 | else throwErr("account is not ready")] | |
415 | 420 | if ((ckecks == ckecks)) | |
416 | 421 | then { | |
417 | 422 | let actions = [ScriptTransfer(accountAddress, payment.amount, payment.assetId)] | |
418 | 423 | let factoryActions = [invoke(factoryAddress, "integerEntry", [kDeposited(accountAddress), (valueOrElse(depositedOption(accountAddress), 0) + payment.amount)], nil)] | |
419 | 424 | $Tuple2(actions, factoryActions) | |
420 | 425 | } | |
421 | 426 | else throw("Strict value is not equal to itself.") | |
422 | 427 | } | |
423 | 428 | ||
424 | 429 | ||
425 | 430 | ||
426 | 431 | @Callable(i) | |
427 | 432 | func withdraw (callerPublicKey,args) = { | |
428 | 433 | let ckecks = [if (!(shutdown)) | |
429 | 434 | then true | |
430 | 435 | else throwErr("not allowed"), mustFactory(i.caller)] | |
431 | 436 | if ((ckecks == ckecks)) | |
432 | 437 | then { | |
433 | 438 | let userAddress = addressFromPublicKey(callerPublicKey) | |
434 | 439 | let accountAddress = valueOrErrorMessage(addressFromString(args[0]), wrapErr("invalid account address")) | |
435 | 440 | let amount = valueOrErrorMessage(parseInt(args[1]), wrapErr("invalid amount")) | |
436 | 441 | let assetId = parseAssetId(args[2]) | |
437 | 442 | let invocations = [invoke(accountAddress, "transferAsset", [userAddress.bytes, amount, assetId], nil)] | |
438 | 443 | $Tuple2(nil, invocations) | |
439 | 444 | } | |
440 | 445 | else throw("Strict value is not equal to itself.") | |
441 | 446 | } | |
442 | 447 | ||
443 | 448 | ||
444 | 449 | ||
445 | 450 | @Callable(i) | |
446 | 451 | func borrow (callerPublicKey,args) = { | |
447 | 452 | let accountAddress = valueOrErrorMessage(addressFromString(args[0]), wrapErr("invalid account address")) | |
448 | 453 | let assetIdRequested = parseAssetId(args[1]) | |
449 | 454 | let amountRequested = ensurePositive(valueOrErrorMessage(parseInt(args[2]), wrapErr("invalid requested amount")), "requested amount") | |
450 | 455 | let accountOwnerPublicKey = getAccountOwnerPublicKey(accountAddress) | |
451 | 456 | let userAddress = addressFromPublicKey(callerPublicKey) | |
452 | 457 | let ckecks = [if (!(shutdown)) | |
453 | 458 | then true | |
454 | 459 | else throwErr("not allowed"), mustFactory(i.caller), if ((callerPublicKey == accountOwnerPublicKey)) | |
455 | 460 | then true | |
456 | 461 | else throwErr("can be called by account owner only")] | |
457 | 462 | if ((ckecks == ckecks)) | |
458 | 463 | then { | |
459 | 464 | let amountAssetId = getAccountAssets(accountAddress)._1 | |
460 | 465 | let deposited = toX18(valueOrElse(depositedOption(accountAddress), 0), pow10Decimals(usdtAssetId)) | |
461 | 466 | let currentPrice = toX18(getCurrentPrice(amountAssetId), pow10Decimals(usdtAssetId)) | |
462 | 467 | let creditA = toX18(valueOrElse(getInteger(factoryAddress, kCredit(accountAddress, amountAssetId)), 0), pow10Decimals(amountAssetId)) | |
463 | 468 | let creditB = toX18(valueOrElse(getInteger(factoryAddress, kCredit(accountAddress, usdtAssetId)), 0), pow10Decimals(usdtAssetId)) | |
464 | 469 | let totalCredit = calcTotalCredit(creditA, creditB, currentPrice) | |
465 | - | let leverageDefault = 3 | |
466 | - | let leverage = toX18(valueOrElse(getInteger(factoryAddress, kLeverage(accountAddress)), leverageDefault), 1) | |
470 | + | let leverage = toX18(valueOrErrorMessage(getInteger(factoryAddress, kLeverage(accountAddress)), wrapErr("leverage should be defined")), 1) | |
467 | 471 | let creditAvailableUsdt = calcCreditAvailable(deposited, leverage, totalCredit) | |
468 | 472 | let creditAvailable = if ((assetIdRequested == amountAssetId)) | |
469 | 473 | then fromX18(fraction(creditAvailableUsdt, mult18BigInt, currentPrice), pow10Decimals(amountAssetId)) | |
470 | 474 | else if ((assetIdRequested == usdtAssetId)) | |
471 | 475 | then fromX18(creditAvailableUsdt, pow10Decimals(usdtAssetId)) | |
472 | 476 | else throwErr("invalid requested asset id") | |
473 | 477 | let syntheticAssetId = parseAssetId(valueOrErrorMessage(getString(factoryAddress, kSyntheticAssetId(assetIdRequested)), wrapErr("synthetic asset for requested asset is undefined"))) | |
474 | 478 | let amountToSend = if ((creditAvailable >= amountRequested)) | |
475 | 479 | then amountRequested | |
476 | 480 | else throwErr(("credit available = " + toString(creditAvailable))) | |
477 | 481 | let factoryActions = [invoke(factoryAddress, "integerEntry", [kCredit(accountAddress, assetIdRequested), (valueOrElse(creditOption(accountAddress, assetIdRequested), 0) + amountToSend)], nil), invoke(factoryAddress, "transferAsset", [userAddress.bytes, amountToSend, syntheticAssetId], nil)] | |
478 | 482 | $Tuple2(nil, [factoryActions, creditAvailable]) | |
479 | 483 | } | |
480 | 484 | else throw("Strict value is not equal to itself.") | |
481 | 485 | } | |
482 | 486 | ||
483 | 487 | ||
484 | 488 | ||
485 | 489 | @Callable(i) | |
486 | 490 | func repay (callerPublicKey,args) = { | |
487 | 491 | let ckecks = [if (!(shutdown)) | |
488 | 492 | then true | |
489 | 493 | else throwErr("not allowed"), mustFactory(i.caller)] | |
490 | 494 | if ((ckecks == ckecks)) | |
491 | 495 | then $Tuple2(nil, unit) | |
492 | 496 | else throw("Strict value is not equal to itself.") | |
493 | 497 | } | |
494 | 498 | ||
495 | 499 | ||
496 | 500 | ||
497 | 501 | @Callable(i) | |
498 | 502 | func setPairAllowance (callerPublicKey,args) = { | |
499 | 503 | let ckecks = [if (!(shutdown)) | |
500 | 504 | then true | |
501 | 505 | else throwErr("not allowed"), mustFactory(i.caller), mustAdmin(callerPublicKey)] | |
502 | 506 | if ((ckecks == ckecks)) | |
503 | 507 | then { | |
504 | 508 | let amountAssetIdStr = args[0] | |
505 | 509 | let priceAssetIdStr = args[1] | |
506 | 510 | let allowStr = args[2] | |
507 | 511 | let amountAssetId = parseAssetId(amountAssetIdStr) | |
508 | 512 | let priceAssetId = parseAssetId(priceAssetIdStr) | |
509 | 513 | let allow = (allowStr == "true") | |
510 | 514 | let invocations = [invoke(factoryAddress, "booleanEntry", [kPairAllowed(amountAssetId, priceAssetId), allow], nil)] | |
511 | 515 | $Tuple2(nil, invocations) | |
512 | 516 | } | |
513 | 517 | else throw("Strict value is not equal to itself.") | |
514 | 518 | } | |
515 | 519 | ||
516 | 520 | ||
517 | 521 | ||
518 | 522 | @Callable(i) | |
519 | 523 | func addSyntheticAsset (callerPublicKey,args) = { | |
520 | 524 | let baseAssetId = parseAssetId(args[0]) | |
521 | 525 | let syntheticAssetId = parseAssetId(args[1]) | |
522 | 526 | let ckecks = [if (!(shutdown)) | |
523 | 527 | then true | |
524 | 528 | else throwErr("not allowed"), mustFactory(i.caller), mustAdmin(callerPublicKey), if ((getString(factoryAddress, kSyntheticAssetId(baseAssetId)) == unit)) | |
525 | 529 | then true | |
526 | 530 | else throwErr("invalid base asset"), if ((getString(factoryAddress, kBaseAssetId(syntheticAssetId)) == unit)) | |
527 | 531 | then true | |
528 | 532 | else throwErr("invalid synthetic asset")] | |
529 | 533 | if ((ckecks == ckecks)) | |
530 | 534 | then { | |
531 | 535 | let invocations = [invoke(factoryAddress, "stringEntry", [kSyntheticAssetId(baseAssetId), assetIdToString(syntheticAssetId)], nil), invoke(factoryAddress, "stringEntry", [kBaseAssetId(syntheticAssetId), assetIdToString(baseAssetId)], nil)] | |
532 | 536 | $Tuple2(nil, invocations) | |
533 | 537 | } | |
534 | 538 | else throw("Strict value is not equal to itself.") | |
535 | 539 | } | |
536 | 540 | ||
537 | 541 | ||
538 | 542 | ||
539 | 543 | @Callable(i) | |
540 | 544 | func doShutdown (callerPublicKey,args) = { | |
541 | 545 | let checks = [mustFactory(i.caller), mustAdmin(callerPublicKey)] | |
542 | 546 | if ((checks == checks)) | |
543 | 547 | then { | |
544 | 548 | let invocations = [invoke(factoryAddress, "booleanEntry", [kShutdown, true], nil)] | |
545 | 549 | $Tuple2(nil, invocations) | |
546 | 550 | } | |
547 | 551 | else throw("Strict value is not equal to itself.") | |
548 | 552 | } | |
549 | 553 | ||
550 | 554 | ||
551 | 555 | @Verifier(tx) | |
552 | 556 | func verify () = if (if (isDefined(factoryAddressOption)) | |
553 | 557 | then isDefined(getString(factoryAddress, kMultisig)) | |
554 | 558 | else false) | |
555 | 559 | then match getString(factoryAddress, kMultisig) { | |
556 | 560 | case multisig: String => | |
557 | 561 | let statusKey = kStatus(toString(this), toBase58String(tx.id)) | |
558 | 562 | let status = valueOrElse(getBoolean(addressFromStringValue(multisig), statusKey), false) | |
559 | 563 | status | |
560 | 564 | case _ => | |
561 | 565 | false | |
562 | 566 | } | |
563 | 567 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
564 | 568 |
github/deemru/w8io/169f3d6 70.66 ms ◑