tx · 69ysPdCVGZFawLKhuouPBETMhPfG8Xgwzbbq3o9Z5Ri1 3N95taAsiWcVMmXdVShZ2ann6MAboXrFT1b: -0.01400000 Waves 2021.07.20 16:53 [1622025] smart account 3N95taAsiWcVMmXdVShZ2ann6MAboXrFT1b > SELF 0.00000000 Waves
{ "type": 13, "id": "69ysPdCVGZFawLKhuouPBETMhPfG8Xgwzbbq3o9Z5Ri1", "fee": 1400000, "feeAssetId": null, "timestamp": 1626789276271, "version": 2, "chainId": 84, "sender": "3N95taAsiWcVMmXdVShZ2ann6MAboXrFT1b", "senderPublicKey": "EDQ1awBPdPh8m86bDaSLf5pynLiRVX4kcPLMxYLRScq5", "proofs": [ "5kKXNhKHtB6kLUDCifY4RPfZ7H4EzqNz6CEhGSTpg3zpJUf9uuHrQgjq7TdtPVeXqHxjv7jFtKkfa4MLZBWinCu3", "5yqCSm5AukbrBktVAZCNL9sjyfsBT9pFbH2afbjbBVUpSQF9b4KTUZ7pCLHtu9kMnrkWsXBPnTbDoPhSBhdCnbaC" ], "script": "base64:AAIEAAAAAAAAABkIAhIAEgMKAQESABIDCgEBEgASABIDCgEBAAAAOwAAAAAHdmVyc2lvbgIAAAAFMS4wLjAAAAAACmtleVZlcnNpb24CAAAAB3ZlcnNpb24AAAAACWtleUFjdGl2ZQIAAAAGYWN0aXZlAAAAAAtrZXlBc3NldElkQQIAAAAKQV9hc3NldF9pZAAAAAALa2V5QXNzZXRJZEICAAAACkJfYXNzZXRfaWQAAAAAC2tleUJhbGFuY2VBAgAAAA9BX2Fzc2V0X2JhbGFuY2UAAAAAC2tleUJhbGFuY2VCAgAAAA9CX2Fzc2V0X2JhbGFuY2UAAAAAD2tleVNoYXJlQXNzZXRJZAIAAAAOc2hhcmVfYXNzZXRfaWQAAAAAE2tleVNoYXJlQXNzZXRTdXBwbHkCAAAAEnNoYXJlX2Fzc2V0X3N1cHBseQAAAAANa2V5Q29tbWlzc2lvbgIAAAAKY29tbWlzc2lvbgAAAAAba2V5Q29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AwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAACBQAAAAxhZG1pblB1YktleTMAAAAAAAAAAAEAAAAAAAAAAAAJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAEmFkbWluUHViS2V5MVNpZ25lZAUAAAASYWRtaW5QdWJLZXkyU2lnbmVkBQAAABJhZG1pblB1YktleTNTaWduZWQAAAAAAAAAAALnQbb7", "height": 1622025, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Gp1B9iArShJ62KJUTrSrA5H9GNXnr9qeVMJ8fTLxe7in Next: none Diff:
Old | New | Differences | |
---|---|---|---|
15 | 15 | ||
16 | 16 | let keyBalanceB = "B_asset_balance" | |
17 | 17 | ||
18 | - | let keyBalanceInitA = "A_asset_init" | |
19 | - | ||
20 | - | let keyBalanceInitB = "B_asset_init" | |
21 | - | ||
22 | 18 | let keyShareAssetId = "share_asset_id" | |
23 | 19 | ||
24 | 20 | let keyShareAssetSupply = "share_asset_supply" | |
28 | 24 | let keyCommissionScaleDelimiter = "commission_scale_delimiter" | |
29 | 25 | ||
30 | 26 | let keyCause = "shutdown_cause" | |
31 | - | ||
32 | - | let keyFirstHarvest = "first_harvest" | |
33 | - | ||
34 | - | let keyFirstHarvestHeight = "first_harvest_height" | |
35 | - | ||
36 | - | let kShareLimit = "share_limit_on_first_harvest" | |
37 | - | ||
38 | - | let kBasePeriod = "base_period" | |
39 | - | ||
40 | - | let kPeriodLength = "period_length" | |
41 | - | ||
42 | - | let kStartHeight = "start_height" | |
43 | - | ||
44 | - | let kFirstHarvestHeight = "first_harvest_height" | |
45 | 27 | ||
46 | 28 | let adminPubKey1 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
47 | 29 | ||
53 | 35 | ||
54 | 36 | let adminPubKeyStaking = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
55 | 37 | ||
56 | - | let | |
38 | + | let governanceAddress = Address(base58'3NAGTtZz6WpupSN89NZD5rMZwwziZEg4Kx4') | |
57 | 39 | ||
58 | - | let walletAddress = Address(base58'3NAGTtZz6WpupSN89NZD5rMZwwziZEg4Kx4') | |
59 | - | ||
60 | - | let votingAddress = Address(base58'3MrJgdL1GniipErHy44YF9idzLaUL2iX5DQ') | |
61 | - | ||
62 | - | let stakingAddress = Address(base58'3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg') | |
63 | - | ||
64 | - | let USDNToWavesExchanger = Address(base58'3N3g1MVp6DXyfqhq8sMPA6CRRkTTPtBsZeh') | |
65 | - | ||
66 | - | let basePeriod = valueOrErrorMessage(getInteger(votingAddress, kBasePeriod), "Empty kBasePeriod") | |
67 | - | ||
68 | - | let startHeight = valueOrErrorMessage(getInteger(votingAddress, kStartHeight), "Empty kStartHeight") | |
69 | - | ||
70 | - | let periodLength = valueOrErrorMessage(getInteger(votingAddress, kPeriodLength), "Empty kPeriodLength") | |
71 | - | ||
72 | - | let firstHarvestEndPeriod = ((basePeriod + ((height - startHeight) / periodLength)) + 3) | |
40 | + | let stakingAddressUSDN = Address(base58'3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg') | |
73 | 41 | ||
74 | 42 | let USDN = base58'8UrfDVd5GreeUwm7uPk7eYz1eMv376kzR52C6sANPkwS' | |
43 | + | ||
44 | + | let NSBT = base58'36mg8NZTaFRDygiVwb8uBnLR51hetJruUCZcxhaVcHj9' | |
45 | + | ||
46 | + | let SWOP = base58'2HAJrwa8q4SxBx9cHYaBTQdBjdk5wwqdof7ccpAx2uhZ' | |
47 | + | ||
48 | + | let swopUSDNtoWAVES = Address(base58'3N3g1MVp6DXyfqhq8sMPA6CRRkTTPtBsZeh') | |
49 | + | ||
50 | + | let swopUSDNtoNSBT = Address(base58'3N95taAsiWcVMmXdVShZ2ann6MAboXrFT1b') | |
75 | 51 | ||
76 | 52 | let stakingFeeInUSDN = 270000 | |
77 | 53 | ||
139 | 115 | } | |
140 | 116 | ||
141 | 117 | ||
142 | - | let stakedAmountUSDN = match getInteger(stakingAddress, ((("rpd_balance_" + toBase58String(USDN)) + "_") + toString(this))) { | |
143 | - | case staked: Int => | |
144 | - | staked | |
145 | - | case nothing: Unit => | |
146 | - | 0 | |
147 | - | case _ => | |
148 | - | throw("Match error") | |
149 | - | } | |
118 | + | func stakedAmount (stakingAddress,asset) = { | |
119 | + | let stakedAmountCalculated = match getInteger(stakingAddress, ((("rpd_balance_" + asset) + "_") + toString(this))) { | |
120 | + | case staked: Int => | |
121 | + | staked | |
122 | + | case nothing: Unit => | |
123 | + | 0 | |
124 | + | case _ => | |
125 | + | throw("Match error") | |
126 | + | } | |
127 | + | stakedAmountCalculated | |
128 | + | } | |
150 | 129 | ||
151 | - | let assetInitA = getIntegerValue(this, keyBalanceInitA) | |
152 | 130 | ||
153 | - | let | |
131 | + | let stakedAmountA = stakedAmount(stakingAddressUSDN, strAssetIdA) | |
154 | 132 | ||
155 | - | let availableBalanceA = (balanceA - (if ((assetIdA == USDN)) | |
156 | - | then stakedAmountUSDN | |
157 | - | else 0)) | |
133 | + | let stakedAmountB = stakedAmount(stakingAddressUSDN, strAssetIdB) | |
158 | 134 | ||
159 | - | let availableBalanceB = (balanceB - (if ((assetIdB == USDN)) | |
160 | - | then stakedAmountUSDN | |
161 | - | else 0)) | |
135 | + | let availableBalanceA = (balanceA - stakedAmountA) | |
162 | 136 | ||
163 | - | let accountBalanceWithStakedA = (accountBalance(assetIdA) + (if ((assetIdA == USDN)) | |
164 | - | then stakedAmountUSDN | |
165 | - | else 0)) | |
137 | + | let availableBalanceB = (balanceB - stakedAmountB) | |
166 | 138 | ||
167 | - | let | |
168 | - | ||
169 | - | ||
139 | + | let accountBalanceWithStakedA = (accountBalance(assetIdA) + stakedAmountA) | |
140 | + | ||
141 | + | let accountBalanceWithStakedB = (accountBalance(assetIdB) + stakedAmountB) | |
170 | 142 | ||
171 | 143 | let hasEnoughBalance = if ((accountBalanceWithStakedA >= balanceA)) | |
172 | 144 | then (accountBalanceWithStakedB >= balanceB) | |
184 | 156 | } | |
185 | 157 | ||
186 | 158 | ||
187 | - | func getAssetInfoFromString (assetStr) = if ((assetStr == "WAVES")) | |
188 | - | then $Tuple3("WAVES", "WAVES", 8) | |
189 | - | else { | |
190 | - | let stringId = assetStr | |
191 | - | let id = fromBase58String(assetStr) | |
192 | - | let info = valueOrErrorMessage(assetInfo(id), (("Asset " + stringId) + " doesn't exist")) | |
193 | - | $Tuple3(stringId, info.name, info.decimals) | |
194 | - | } | |
159 | + | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
195 | 160 | ||
196 | 161 | ||
197 | - | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
162 | + | func stakedTokenCount () = { | |
163 | + | let isStakedA = if ((stakedAmountA > 0)) | |
164 | + | then 1 | |
165 | + | else 0 | |
166 | + | let isStakedB = if ((stakedAmountB > 0)) | |
167 | + | then 1 | |
168 | + | else 0 | |
169 | + | (isStakedA + isStakedB) | |
170 | + | } | |
198 | 171 | ||
199 | 172 | ||
200 | 173 | func deductStakingFee (amount,assetId) = if ((assetId == USDN)) | |
201 | 174 | then { | |
202 | - | let result = (amount - stakingFeeInUSDN) | |
175 | + | let result = (amount - (stakedTokenCount() * stakingFeeInUSDN)) | |
203 | 176 | if ((0 >= result)) | |
204 | 177 | then throw((((("Insufficient amount " + toString(amount)) + " to deduct staking fee ") + toString(stakingFeeInUSDN)) + " USD-N")) | |
205 | 178 | else result | |
217 | 190 | ||
218 | 191 | ||
219 | 192 | @Callable(i) | |
220 | - | func init (firstHarvest) = { | |
221 | - | let $t064796556 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
222 | - | let pmtAmountA = $t064796556._1 | |
223 | - | let pmtAssetIdA = $t064796556._2 | |
224 | - | let $t065616638 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
225 | - | let pmtAmountB = $t065616638._1 | |
226 | - | let pmtAssetIdB = $t065616638._2 | |
227 | - | let $t066436720 = getAssetInfo(pmtAssetIdA) | |
228 | - | let pmtStrAssetIdA = $t066436720._1 | |
229 | - | let pmtAssetNameA = $t066436720._2 | |
230 | - | let pmtDecimalsA = $t066436720._3 | |
231 | - | let $t067256802 = getAssetInfo(pmtAssetIdB) | |
232 | - | let pmtStrAssetIdB = $t067256802._1 | |
233 | - | let pmtAssetNameB = $t067256802._2 | |
234 | - | let pmtDecimalsB = $t067256802._3 | |
235 | - | if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStaking], i.callerPublicKey))) | |
236 | - | then throw("Only admin can call this function") | |
237 | - | else if (isDefined(getBoolean(this, keyActive))) | |
238 | - | then throw("DApp is already active") | |
239 | - | else if ((pmtAssetIdA == pmtAssetIdB)) | |
240 | - | then throw("Assets must be different") | |
241 | - | else { | |
242 | - | let shareName = ((("s" + take(pmtAssetNameA, 7)) + "_") + take(pmtAssetNameB, 7)) | |
243 | - | let shareDescription = ((((("ShareToken of SwopFi protocol for " + pmtAssetNameA) + " and ") + pmtAssetNameB) + " at address ") + toString(this)) | |
244 | - | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
245 | - | let shareInitialSupply = fraction(pow(pmtAmountA, pmtDecimalsA, 5, 1, pmtDecimalsA, HALFDOWN), pow(pmtAmountB, pmtDecimalsB, 5, 1, pmtDecimalsB, HALFDOWN), pow(10, 0, shareDecimals, 0, 0, HALFDOWN)) | |
246 | - | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
247 | - | let shareIssueId = calculateAssetId(shareIssue) | |
248 | - | let baseEntry = [StringEntry(keyVersion, version), BooleanEntry(keyActive, true), StringEntry(keyAssetIdA, pmtStrAssetIdA), StringEntry(keyAssetIdB, pmtStrAssetIdB), IntegerEntry(keyBalanceA, pmtAmountA), IntegerEntry(keyBalanceB, pmtAmountB), IntegerEntry(keyCommission, commission), IntegerEntry(keyCommissionScaleDelimiter, commissionScaleDelimiter), shareIssue, StringEntry(keyShareAssetId, toBase58String(shareIssueId)), IntegerEntry(keyShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareIssueId)] | |
249 | - | if (firstHarvest) | |
250 | - | then (baseEntry ++ [BooleanEntry(keyFirstHarvest, firstHarvest), IntegerEntry(keyFirstHarvestHeight, (startHeight + (firstHarvestEndPeriod * periodLength)))]) | |
251 | - | else baseEntry | |
252 | - | } | |
193 | + | func init () = { | |
194 | + | let $t056135690 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
195 | + | let pmtAmountA = $t056135690._1 | |
196 | + | let pmtAssetIdA = $t056135690._2 | |
197 | + | let $t056955772 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
198 | + | let pmtAmountB = $t056955772._1 | |
199 | + | let pmtAssetIdB = $t056955772._2 | |
200 | + | let $t057775854 = getAssetInfo(pmtAssetIdA) | |
201 | + | let pmtStrAssetIdA = $t057775854._1 | |
202 | + | let pmtAssetNameA = $t057775854._2 | |
203 | + | let pmtDecimalsA = $t057775854._3 | |
204 | + | let $t058595936 = getAssetInfo(pmtAssetIdB) | |
205 | + | let pmtStrAssetIdB = $t058595936._1 | |
206 | + | let pmtAssetNameB = $t058595936._2 | |
207 | + | let pmtDecimalsB = $t058595936._3 | |
208 | + | if (isDefined(getBoolean(this, keyActive))) | |
209 | + | then throw("DApp is already active") | |
210 | + | else if ((pmtAssetIdA == pmtAssetIdB)) | |
211 | + | then throw("Assets must be different") | |
212 | + | else { | |
213 | + | let shareName = ((("s" + take(pmtAssetNameA, 7)) + "_") + take(pmtAssetNameB, 7)) | |
214 | + | let shareDescription = ((((("ShareToken of SwopFi protocol for " + pmtAssetNameA) + " and ") + pmtAssetNameB) + " at address ") + toString(this)) | |
215 | + | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
216 | + | let shareInitialSupply = fraction(pow(pmtAmountA, pmtDecimalsA, 5, 1, pmtDecimalsA, HALFDOWN), pow(pmtAmountB, pmtDecimalsB, 5, 1, pmtDecimalsB, HALFDOWN), pow(10, 0, shareDecimals, 0, 0, HALFDOWN)) | |
217 | + | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
218 | + | let shareIssueId = calculateAssetId(shareIssue) | |
219 | + | [StringEntry(keyVersion, version), BooleanEntry(keyActive, true), StringEntry(keyAssetIdA, pmtStrAssetIdA), StringEntry(keyAssetIdB, pmtStrAssetIdB), IntegerEntry(keyBalanceA, pmtAmountA), IntegerEntry(keyBalanceB, pmtAmountB), IntegerEntry(keyCommission, commission), IntegerEntry(keyCommissionScaleDelimiter, commissionScaleDelimiter), shareIssue, StringEntry(keyShareAssetId, toBase58String(shareIssueId)), IntegerEntry(keyShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareIssueId)] | |
220 | + | } | |
253 | 221 | } | |
254 | - | ||
255 | - | ||
256 | - | ||
257 | - | @Callable(i) | |
258 | - | func initWithInitRatio (amtAssetA,amtAssetB,strAssetIdA,strAssetIdB,firstHarvest) = { | |
259 | - | let $t090109097 = getAssetInfoFromString(strAssetIdA) | |
260 | - | let pmtStrAssetIdA = $t090109097._1 | |
261 | - | let pmtAssetNameA = $t090109097._2 | |
262 | - | let pmtDecimalsA = $t090109097._3 | |
263 | - | let $t091029189 = getAssetInfoFromString(strAssetIdB) | |
264 | - | let pmtStrAssetIdB = $t091029189._1 | |
265 | - | let pmtAssetNameB = $t091029189._2 | |
266 | - | let pmtDecimalsB = $t091029189._3 | |
267 | - | if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStaking], i.callerPublicKey))) | |
268 | - | then throw("Only admin can call this function") | |
269 | - | else if (isDefined(getBoolean(this, keyActive))) | |
270 | - | then throw("DApp is already active") | |
271 | - | else if ((strAssetIdA == strAssetIdB)) | |
272 | - | then throw("Assets must be different") | |
273 | - | else { | |
274 | - | let shareName = ((("s" + take(pmtAssetNameA, 7)) + "_") + take(pmtAssetNameB, 7)) | |
275 | - | let shareDescription = ((((("ShareToken of SwopFi protocol for " + pmtAssetNameA) + " and ") + pmtAssetNameB) + " at address ") + toString(this)) | |
276 | - | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
277 | - | let shareInitialSupply = 0 | |
278 | - | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
279 | - | let shareIssueId = calculateAssetId(shareIssue) | |
280 | - | let baseEntry = [StringEntry(keyVersion, version), BooleanEntry(keyActive, true), StringEntry(keyAssetIdA, pmtStrAssetIdA), StringEntry(keyAssetIdB, pmtStrAssetIdB), IntegerEntry(keyBalanceInitA, amtAssetA), IntegerEntry(keyBalanceInitB, amtAssetB), IntegerEntry(keyBalanceA, 0), IntegerEntry(keyBalanceB, 0), IntegerEntry(keyCommission, commission), IntegerEntry(keyCommissionScaleDelimiter, commissionScaleDelimiter), shareIssue, StringEntry(keyShareAssetId, toBase58String(shareIssueId)), IntegerEntry(keyShareAssetSupply, shareInitialSupply)] | |
281 | - | if (firstHarvest) | |
282 | - | then (baseEntry ++ [BooleanEntry(keyFirstHarvest, firstHarvest), IntegerEntry(keyFirstHarvestHeight, (startHeight + (firstHarvestEndPeriod * periodLength)))]) | |
283 | - | else baseEntry | |
284 | - | } | |
285 | - | } | |
286 | - | ||
287 | - | ||
288 | - | ||
289 | - | @Callable(i) | |
290 | - | func keepLimitForFirstHarvest (shareLimit) = if (!(isActive)) | |
291 | - | then throw("DApp is inactive at this moment") | |
292 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStaking], i.callerPublicKey))) | |
293 | - | then throw("Only admin can call this function") | |
294 | - | else [IntegerEntry(kShareLimit, shareLimit)] | |
295 | 222 | ||
296 | 223 | ||
297 | 224 | ||
301 | 228 | let pmtAssetIdB = i.payments[1].assetId | |
302 | 229 | let pmtAmountA = deductStakingFee(i.payments[0].amount, pmtAssetIdA) | |
303 | 230 | let pmtAmountB = deductStakingFee(i.payments[1].amount, pmtAssetIdB) | |
304 | - | if (if ((balanceA == 0)) | |
305 | - | then (balanceB == 0) | |
306 | - | else false) | |
307 | - | then { | |
308 | - | let $t01187411951 = getAssetInfo(pmtAssetIdA) | |
309 | - | let pmtStrAssetIdA = $t01187411951._1 | |
310 | - | let pmtAssetNameA = $t01187411951._2 | |
311 | - | let pmtDecimalsA = $t01187411951._3 | |
312 | - | let $t01196012037 = getAssetInfo(pmtAssetIdB) | |
313 | - | let pmtStrAssetIdB = $t01196012037._1 | |
314 | - | let pmtAssetNameB = $t01196012037._2 | |
315 | - | let pmtDecimalsB = $t01196012037._3 | |
316 | - | let tokenRatio = fraction(fraction(assetInitA, scaleValue8, pmtAmountA), scaleValue3, fraction(assetInitB, scaleValue8, pmtAmountB)) | |
317 | - | if ((pmtAssetIdA == pmtAssetIdB)) | |
318 | - | then throw("Assets must be different") | |
319 | - | else { | |
320 | - | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
321 | - | let shareInitialSupply = fraction(pow(pmtAmountA, pmtDecimalsA, 5, 1, pmtDecimalsA, HALFDOWN), pow(pmtAmountB, pmtDecimalsB, 5, 1, pmtDecimalsB, HALFDOWN), pow(10, 0, shareDecimals, 0, 0, HALFDOWN)) | |
322 | - | if (!(isActive)) | |
323 | - | then throw("DApp is inactive at this moment") | |
324 | - | else if (if ((0 > slippageTolerance)) | |
325 | - | then true | |
326 | - | else (slippageTolerance > slippageToleranceDelimiter)) | |
327 | - | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
328 | - | else if ((size(i.payments) != 2)) | |
329 | - | then throw("Two attached assets expected") | |
330 | - | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
331 | - | then true | |
332 | - | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
333 | - | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
334 | - | else if (if ((pmtAssetIdA != assetIdA)) | |
335 | - | then true | |
336 | - | else (pmtAssetIdB != assetIdB)) | |
337 | - | then throw(((("Incorrect assets attached. Expected: " + strAssetIdA) + " and ") + strAssetIdB)) | |
338 | - | else if ((shareInitialSupply == 0)) | |
339 | - | then throw("Too small amount to replenish") | |
340 | - | else if (!(hasEnoughBalance)) | |
341 | - | then ([ScriptTransfer(i.caller, pmtAmountA, pmtAssetIdA), ScriptTransfer(i.caller, pmtAmountB, pmtAssetIdB)] ++ suspendSuspicious()) | |
342 | - | else [Reissue(shareAssetId, shareInitialSupply, true), IntegerEntry(keyBalanceA, pmtAmountA), IntegerEntry(keyBalanceB, pmtAmountB), IntegerEntry(keyShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareAssetId)] | |
343 | - | } | |
344 | - | } | |
345 | - | else { | |
346 | - | let tokenRatio = fraction(fraction(balanceA, scaleValue8, pmtAmountA), scaleValue3, fraction(balanceB, scaleValue8, pmtAmountB)) | |
347 | - | let ratioShareTokensInA = fraction(pmtAmountA, scaleValue8, balanceA) | |
348 | - | let ratioShareTokensInB = fraction(pmtAmountB, scaleValue8, balanceB) | |
349 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
350 | - | if (!(isActive)) | |
351 | - | then throw("DApp is inactive at this moment") | |
352 | - | else if (if ((0 > slippageTolerance)) | |
231 | + | let tokenRatio = fraction(fraction(balanceA, scaleValue8, pmtAmountA), scaleValue3, fraction(balanceB, scaleValue8, pmtAmountB)) | |
232 | + | let ratioShareTokensInA = fraction(pmtAmountA, scaleValue8, balanceA) | |
233 | + | let ratioShareTokensInB = fraction(pmtAmountB, scaleValue8, balanceB) | |
234 | + | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
235 | + | if (!(isActive)) | |
236 | + | then throw("DApp is inactive at this moment") | |
237 | + | else if (if ((0 > slippageTolerance)) | |
238 | + | then true | |
239 | + | else (slippageTolerance > slippageToleranceDelimiter)) | |
240 | + | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
241 | + | else if ((size(i.payments) != 2)) | |
242 | + | then throw("Two attached assets expected") | |
243 | + | else if (if ((pmtAssetIdA != assetIdA)) | |
353 | 244 | then true | |
354 | - | else (slippageTolerance > slippageToleranceDelimiter)) | |
355 | - | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
356 | - | else if ((size(i.payments) != 2)) | |
357 | - | then throw("Two attached assets expected") | |
358 | - | else if (if ((pmtAssetIdA != assetIdA)) | |
359 | - | then true | |
360 | - | else (pmtAssetIdB != assetIdB)) | |
361 | - | then throw(((("Incorrect assets attached. Expected: " + strAssetIdA) + " and ") + strAssetIdB)) | |
362 | - | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
363 | - | then true | |
364 | - | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
365 | - | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
366 | - | else if ((shareTokenToPayAmount == 0)) | |
367 | - | then throw("Too small amount to replenish") | |
368 | - | else if (!(hasEnoughBalance)) | |
369 | - | then ([ScriptTransfer(i.caller, pmtAmountA, pmtAssetIdA), ScriptTransfer(i.caller, pmtAmountB, pmtAssetIdB)] ++ suspendSuspicious()) | |
370 | - | else [IntegerEntry(keyBalanceA, (balanceA + pmtAmountA)), IntegerEntry(keyBalanceB, (balanceB + pmtAmountB)), IntegerEntry(keyShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
371 | - | } | |
245 | + | else (pmtAssetIdB != assetIdB)) | |
246 | + | then throw(((("Incorrect assets attached. Expected: " + strAssetIdA) + " and ") + strAssetIdB)) | |
247 | + | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
248 | + | then true | |
249 | + | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
250 | + | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
251 | + | else if ((shareTokenToPayAmount == 0)) | |
252 | + | then throw("Too small amount to replenish") | |
253 | + | else if (!(hasEnoughBalance)) | |
254 | + | then ([ScriptTransfer(i.caller, pmtAmountA, pmtAssetIdA), ScriptTransfer(i.caller, pmtAmountB, pmtAssetIdB)] ++ suspendSuspicious()) | |
255 | + | else [IntegerEntry(keyBalanceA, (balanceA + pmtAmountA)), IntegerEntry(keyBalanceB, (balanceB + pmtAmountB)), IntegerEntry(keyShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
372 | 256 | } | |
373 | 257 | ||
374 | 258 | ||
375 | 259 | ||
376 | 260 | @Callable(i) | |
377 | 261 | func withdraw () = { | |
378 | - | let $ | |
379 | - | let pmtAmount = $ | |
380 | - | let pmtAssetId = $ | |
262 | + | let $t01000910159 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
263 | + | let pmtAmount = $t01000910159._1 | |
264 | + | let pmtAssetId = $t01000910159._2 | |
381 | 265 | let amountToPayA = deductStakingFee(fraction(pmtAmount, balanceA, shareAssetSupply), assetIdA) | |
382 | 266 | let amountToPayB = deductStakingFee(fraction(pmtAmount, balanceB, shareAssetSupply), assetIdB) | |
383 | 267 | if (!(isActive)) | |
399 | 283 | ||
400 | 284 | @Callable(i) | |
401 | 285 | func exchange (minAmountToReceive) = { | |
402 | - | let $ | |
403 | - | let pmtAmount = $ | |
404 | - | let pmtAssetId = $ | |
286 | + | let $t01136511440 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
287 | + | let pmtAmount = $t01136511440._1 | |
288 | + | let pmtAssetId = $t01136511440._2 | |
405 | 289 | func calculateFees (tokenFrom,tokenTo) = { | |
406 | 290 | let amountWithoutFee = fraction(tokenTo, pmtAmount, (pmtAmount + tokenFrom)) | |
407 | 291 | let amountWithFee = fraction(amountWithoutFee, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
413 | 297 | ||
414 | 298 | if (!(isActive)) | |
415 | 299 | then throw("DApp is inactive at this moment") | |
416 | - | else if (if ((balanceA == 0)) | |
417 | - | then true | |
418 | - | else (balanceB == 0)) | |
419 | - | then throw("Can't exchange with zero balance") | |
420 | - | else if ((0 >= minAmountToReceive)) | |
421 | - | then throw(("Minimal amount to receive must be positive. Actual: " + toString(minAmountToReceive))) | |
422 | - | else if ((size(i.payments) != 1)) | |
423 | - | then throw("One attached payment expected") | |
424 | - | else if (!(hasEnoughBalance)) | |
425 | - | then ([ScriptTransfer(i.caller, pmtAmount, pmtAssetId)] ++ suspendSuspicious()) | |
426 | - | else if ((pmtAssetId == assetIdA)) | |
300 | + | else if ((0 >= minAmountToReceive)) | |
301 | + | then throw(("Minimal amount to receive must be positive. Actual: " + toString(minAmountToReceive))) | |
302 | + | else if ((size(i.payments) != 1)) | |
303 | + | then throw("One attached payment expected") | |
304 | + | else if (!(hasEnoughBalance)) | |
305 | + | then ([ScriptTransfer(i.caller, pmtAmount, pmtAssetId)] ++ suspendSuspicious()) | |
306 | + | else if ((pmtAssetId == assetIdA)) | |
307 | + | then { | |
308 | + | let assetIdSend = assetIdB | |
309 | + | let $t01261512706 = calculateFees(balanceA, balanceB) | |
310 | + | let amountWithoutFee = $t01261512706._1 | |
311 | + | let amountWithFee = $t01261512706._2 | |
312 | + | let governanceReward = $t01261512706._3 | |
313 | + | let newBalanceA = (balanceA + pmtAmount) | |
314 | + | let newBalanceB = ((balanceB - amountWithFee) - governanceReward) | |
315 | + | if (if ((stakedAmountA >= newBalanceA)) | |
316 | + | then true | |
317 | + | else (stakedAmountB >= newBalanceB)) | |
318 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
319 | + | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(governanceAddress, governanceReward, assetIdSend)] | |
320 | + | } | |
321 | + | else if ((pmtAssetId == assetIdB)) | |
427 | 322 | then { | |
428 | - | let assetIdSend = assetIdB | |
429 | - | let $t01915419245 = calculateFees(balanceA, balanceB) | |
430 | - | let amountWithoutFee = $t01915419245._1 | |
431 | - | let amountWithFee = $t01915419245._2 | |
432 | - | let governanceReward = $t01915419245._3 | |
433 | - | let newBalanceA = (balanceA + pmtAmount) | |
434 | - | let newBalanceB = ((balanceB - amountWithFee) - governanceReward) | |
435 | - | if (if (if ((assetIdA == USDN)) | |
436 | - | then (stakedAmountUSDN >= newBalanceA) | |
437 | - | else false) | |
323 | + | let assetIdSend = assetIdA | |
324 | + | let $t01352913620 = calculateFees(balanceB, balanceA) | |
325 | + | let amountWithoutFee = $t01352913620._1 | |
326 | + | let amountWithFee = $t01352913620._2 | |
327 | + | let governanceReward = $t01352913620._3 | |
328 | + | let newBalanceA = ((balanceA - amountWithFee) - governanceReward) | |
329 | + | let newBalanceB = (balanceB + pmtAmount) | |
330 | + | if (if ((stakedAmountA >= newBalanceA)) | |
438 | 331 | then true | |
439 | - | else if ((assetIdB == USDN)) | |
440 | - | then (stakedAmountUSDN >= newBalanceB) | |
441 | - | else false) | |
442 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
443 | - | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(walletAddress, governanceReward, assetIdSend)] | |
332 | + | else (stakedAmountB >= newBalanceB)) | |
333 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
334 | + | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(governanceAddress, governanceReward, assetIdSend)] | |
444 | 335 | } | |
445 | - | else if ((pmtAssetId == assetIdB)) | |
446 | - | then { | |
447 | - | let assetIdSend = assetIdA | |
448 | - | let $t02011420205 = calculateFees(balanceB, balanceA) | |
449 | - | let amountWithoutFee = $t02011420205._1 | |
450 | - | let amountWithFee = $t02011420205._2 | |
451 | - | let governanceReward = $t02011420205._3 | |
452 | - | let newBalanceA = ((balanceA - amountWithFee) - governanceReward) | |
453 | - | let newBalanceB = (balanceB + pmtAmount) | |
454 | - | if (if (if ((assetIdA == USDN)) | |
455 | - | then (stakedAmountUSDN >= newBalanceA) | |
456 | - | else false) | |
457 | - | then true | |
458 | - | else if ((assetIdB == USDN)) | |
459 | - | then (stakedAmountUSDN >= newBalanceB) | |
460 | - | else false) | |
461 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
462 | - | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(walletAddress, governanceReward, assetIdSend)] | |
463 | - | } | |
464 | - | else throw(((("Incorrect asset attached. Expected: " + strAssetIdA) + " or ") + strAssetIdB)) | |
336 | + | else throw(((("Incorrect asset attached. Expected: " + strAssetIdA) + " or ") + strAssetIdB)) | |
465 | 337 | } | |
466 | 338 | ||
467 | 339 | ||
515 | 387 | @Verifier(tx) | |
516 | 388 | func verify () = match tx { | |
517 | 389 | case invoke: InvokeScriptTransaction => | |
518 | - | let callTakeIntoAccount = if ((invoke.dApp == this)) | |
519 | - | then (invoke.function == "takeIntoAccountExtraFunds") | |
520 | - | else false | |
521 | - | let callStaking = if ((invoke.dApp == stakingAddress)) | |
522 | - | then if (if (if ((invoke.function == "lockNeutrino")) | |
523 | - | then (size(invoke.payments) == 1) | |
524 | - | else false) | |
525 | - | then (invoke.payments[0].assetId == USDN) | |
526 | - | else false) | |
527 | - | then true | |
528 | - | else if ((invoke.function == "unlockNeutrino")) | |
529 | - | then (size(invoke.payments) == 0) | |
530 | - | else false | |
531 | - | else false | |
532 | - | let exchangeToWaves = if (if (if ((invoke.dApp == USDNToWavesExchanger)) | |
533 | - | then (invoke.function == "exchange") | |
534 | - | else false) | |
535 | - | then (assetIdA == USDN) | |
390 | + | if (if (if (sigVerify(invoke.bodyBytes, invoke.proofs[0], adminPubKeyStaking)) | |
391 | + | then (invoke.dApp == stakingAddressUSDN) | |
536 | 392 | else false) | |
537 | 393 | then true | |
538 | - | else if ((assetIdB == USDN)) | |
539 | - | then (invoke.payments[0].assetId == USDN) | |
394 | + | else if (if (sigVerify(invoke.bodyBytes, invoke.proofs[0], adminPubKeyStaking)) | |
395 | + | then (invoke.function == "exchange") | |
396 | + | else false) | |
397 | + | then if (if (if (if ((assetIdA == NSBT)) | |
398 | + | then (assetIdB == USDN) | |
399 | + | else false) | |
400 | + | then (invoke.dApp == swopUSDNtoWAVES) | |
401 | + | else false) | |
402 | + | then if ((invoke.payments[0].assetId == unit)) | |
403 | + | then true | |
404 | + | else (invoke.payments[0].assetId == USDN) | |
405 | + | else false) | |
406 | + | then true | |
407 | + | else if (if ((assetIdA == NSBT)) | |
408 | + | then (assetIdB == SWOP) | |
409 | + | else false) | |
410 | + | then if (if ((invoke.dApp == swopUSDNtoNSBT)) | |
411 | + | then (invoke.payments[0].assetId == USDN) | |
412 | + | else false) | |
413 | + | then true | |
414 | + | else if ((invoke.dApp == swopUSDNtoWAVES)) | |
415 | + | then if ((invoke.payments[0].assetId == unit)) | |
416 | + | then true | |
417 | + | else (invoke.payments[0].assetId == USDN) | |
418 | + | else false | |
419 | + | else false | |
420 | + | else false) | |
421 | + | then true | |
422 | + | else if (if (sigVerify(invoke.bodyBytes, invoke.proofs[0], adminPubKeyStaking)) | |
423 | + | then (invoke.dApp == this) | |
424 | + | else false) | |
425 | + | then (invoke.function == "takeIntoAccountExtraFunds") | |
540 | 426 | else false | |
541 | - | let signedByAdmin = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
542 | - | then true | |
543 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey2)) | |
544 | - | then true | |
545 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey3)) | |
546 | - | then true | |
547 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKeyStaking) | |
548 | - | if (if (if (callTakeIntoAccount) | |
549 | - | then true | |
550 | - | else callStaking) | |
551 | - | then true | |
552 | - | else exchangeToWaves) | |
553 | - | then signedByAdmin | |
554 | - | else false | |
555 | 427 | case _ => | |
556 | 428 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
557 | 429 | then 1 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let version = "1.0.0" | |
5 | 5 | ||
6 | 6 | let keyVersion = "version" | |
7 | 7 | ||
8 | 8 | let keyActive = "active" | |
9 | 9 | ||
10 | 10 | let keyAssetIdA = "A_asset_id" | |
11 | 11 | ||
12 | 12 | let keyAssetIdB = "B_asset_id" | |
13 | 13 | ||
14 | 14 | let keyBalanceA = "A_asset_balance" | |
15 | 15 | ||
16 | 16 | let keyBalanceB = "B_asset_balance" | |
17 | 17 | ||
18 | - | let keyBalanceInitA = "A_asset_init" | |
19 | - | ||
20 | - | let keyBalanceInitB = "B_asset_init" | |
21 | - | ||
22 | 18 | let keyShareAssetId = "share_asset_id" | |
23 | 19 | ||
24 | 20 | let keyShareAssetSupply = "share_asset_supply" | |
25 | 21 | ||
26 | 22 | let keyCommission = "commission" | |
27 | 23 | ||
28 | 24 | let keyCommissionScaleDelimiter = "commission_scale_delimiter" | |
29 | 25 | ||
30 | 26 | let keyCause = "shutdown_cause" | |
31 | - | ||
32 | - | let keyFirstHarvest = "first_harvest" | |
33 | - | ||
34 | - | let keyFirstHarvestHeight = "first_harvest_height" | |
35 | - | ||
36 | - | let kShareLimit = "share_limit_on_first_harvest" | |
37 | - | ||
38 | - | let kBasePeriod = "base_period" | |
39 | - | ||
40 | - | let kPeriodLength = "period_length" | |
41 | - | ||
42 | - | let kStartHeight = "start_height" | |
43 | - | ||
44 | - | let kFirstHarvestHeight = "first_harvest_height" | |
45 | 27 | ||
46 | 28 | let adminPubKey1 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
47 | 29 | ||
48 | 30 | let adminPubKey2 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
49 | 31 | ||
50 | 32 | let adminPubKey3 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
51 | 33 | ||
52 | 34 | let adminPubKeyStartStop = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
53 | 35 | ||
54 | 36 | let adminPubKeyStaking = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
55 | 37 | ||
56 | - | let | |
38 | + | let governanceAddress = Address(base58'3NAGTtZz6WpupSN89NZD5rMZwwziZEg4Kx4') | |
57 | 39 | ||
58 | - | let walletAddress = Address(base58'3NAGTtZz6WpupSN89NZD5rMZwwziZEg4Kx4') | |
59 | - | ||
60 | - | let votingAddress = Address(base58'3MrJgdL1GniipErHy44YF9idzLaUL2iX5DQ') | |
61 | - | ||
62 | - | let stakingAddress = Address(base58'3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg') | |
63 | - | ||
64 | - | let USDNToWavesExchanger = Address(base58'3N3g1MVp6DXyfqhq8sMPA6CRRkTTPtBsZeh') | |
65 | - | ||
66 | - | let basePeriod = valueOrErrorMessage(getInteger(votingAddress, kBasePeriod), "Empty kBasePeriod") | |
67 | - | ||
68 | - | let startHeight = valueOrErrorMessage(getInteger(votingAddress, kStartHeight), "Empty kStartHeight") | |
69 | - | ||
70 | - | let periodLength = valueOrErrorMessage(getInteger(votingAddress, kPeriodLength), "Empty kPeriodLength") | |
71 | - | ||
72 | - | let firstHarvestEndPeriod = ((basePeriod + ((height - startHeight) / periodLength)) + 3) | |
40 | + | let stakingAddressUSDN = Address(base58'3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg') | |
73 | 41 | ||
74 | 42 | let USDN = base58'8UrfDVd5GreeUwm7uPk7eYz1eMv376kzR52C6sANPkwS' | |
43 | + | ||
44 | + | let NSBT = base58'36mg8NZTaFRDygiVwb8uBnLR51hetJruUCZcxhaVcHj9' | |
45 | + | ||
46 | + | let SWOP = base58'2HAJrwa8q4SxBx9cHYaBTQdBjdk5wwqdof7ccpAx2uhZ' | |
47 | + | ||
48 | + | let swopUSDNtoWAVES = Address(base58'3N3g1MVp6DXyfqhq8sMPA6CRRkTTPtBsZeh') | |
49 | + | ||
50 | + | let swopUSDNtoNSBT = Address(base58'3N95taAsiWcVMmXdVShZ2ann6MAboXrFT1b') | |
75 | 51 | ||
76 | 52 | let stakingFeeInUSDN = 270000 | |
77 | 53 | ||
78 | 54 | let isActive = getBooleanValue(this, keyActive) | |
79 | 55 | ||
80 | 56 | let strAssetIdA = getStringValue(this, keyAssetIdA) | |
81 | 57 | ||
82 | 58 | let strAssetIdB = getStringValue(this, keyAssetIdB) | |
83 | 59 | ||
84 | 60 | let assetIdA = if ((strAssetIdA == "WAVES")) | |
85 | 61 | then unit | |
86 | 62 | else fromBase58String(strAssetIdA) | |
87 | 63 | ||
88 | 64 | let assetIdB = if ((strAssetIdB == "WAVES")) | |
89 | 65 | then unit | |
90 | 66 | else fromBase58String(strAssetIdB) | |
91 | 67 | ||
92 | 68 | let assetNameA = match assetIdA { | |
93 | 69 | case id: ByteVector => | |
94 | 70 | value(assetInfo(id)).name | |
95 | 71 | case waves: Unit => | |
96 | 72 | "WAVES" | |
97 | 73 | case _ => | |
98 | 74 | throw("Match error") | |
99 | 75 | } | |
100 | 76 | ||
101 | 77 | let assetNameB = match assetIdB { | |
102 | 78 | case id: ByteVector => | |
103 | 79 | value(assetInfo(id)).name | |
104 | 80 | case waves: Unit => | |
105 | 81 | "WAVES" | |
106 | 82 | case _ => | |
107 | 83 | throw("Match error") | |
108 | 84 | } | |
109 | 85 | ||
110 | 86 | let balanceA = getIntegerValue(this, keyBalanceA) | |
111 | 87 | ||
112 | 88 | let balanceB = getIntegerValue(this, keyBalanceB) | |
113 | 89 | ||
114 | 90 | let shareAssetId = fromBase58String(getStringValue(this, keyShareAssetId)) | |
115 | 91 | ||
116 | 92 | let shareAssetSupply = getIntegerValue(this, keyShareAssetSupply) | |
117 | 93 | ||
118 | 94 | let commission = 3000 | |
119 | 95 | ||
120 | 96 | let commissionGovernance = 1200 | |
121 | 97 | ||
122 | 98 | let commissionScaleDelimiter = 1000000 | |
123 | 99 | ||
124 | 100 | let scaleValue3 = 1000 | |
125 | 101 | ||
126 | 102 | let scaleValue8 = 100000000 | |
127 | 103 | ||
128 | 104 | let slippageToleranceDelimiter = 1000 | |
129 | 105 | ||
130 | 106 | let scaleValue8Digits = 8 | |
131 | 107 | ||
132 | 108 | func accountBalance (assetId) = match assetId { | |
133 | 109 | case id: ByteVector => | |
134 | 110 | assetBalance(this, id) | |
135 | 111 | case waves: Unit => | |
136 | 112 | wavesBalance(this).available | |
137 | 113 | case _ => | |
138 | 114 | throw("Match error") | |
139 | 115 | } | |
140 | 116 | ||
141 | 117 | ||
142 | - | let stakedAmountUSDN = match getInteger(stakingAddress, ((("rpd_balance_" + toBase58String(USDN)) + "_") + toString(this))) { | |
143 | - | case staked: Int => | |
144 | - | staked | |
145 | - | case nothing: Unit => | |
146 | - | 0 | |
147 | - | case _ => | |
148 | - | throw("Match error") | |
149 | - | } | |
118 | + | func stakedAmount (stakingAddress,asset) = { | |
119 | + | let stakedAmountCalculated = match getInteger(stakingAddress, ((("rpd_balance_" + asset) + "_") + toString(this))) { | |
120 | + | case staked: Int => | |
121 | + | staked | |
122 | + | case nothing: Unit => | |
123 | + | 0 | |
124 | + | case _ => | |
125 | + | throw("Match error") | |
126 | + | } | |
127 | + | stakedAmountCalculated | |
128 | + | } | |
150 | 129 | ||
151 | - | let assetInitA = getIntegerValue(this, keyBalanceInitA) | |
152 | 130 | ||
153 | - | let | |
131 | + | let stakedAmountA = stakedAmount(stakingAddressUSDN, strAssetIdA) | |
154 | 132 | ||
155 | - | let availableBalanceA = (balanceA - (if ((assetIdA == USDN)) | |
156 | - | then stakedAmountUSDN | |
157 | - | else 0)) | |
133 | + | let stakedAmountB = stakedAmount(stakingAddressUSDN, strAssetIdB) | |
158 | 134 | ||
159 | - | let availableBalanceB = (balanceB - (if ((assetIdB == USDN)) | |
160 | - | then stakedAmountUSDN | |
161 | - | else 0)) | |
135 | + | let availableBalanceA = (balanceA - stakedAmountA) | |
162 | 136 | ||
163 | - | let accountBalanceWithStakedA = (accountBalance(assetIdA) + (if ((assetIdA == USDN)) | |
164 | - | then stakedAmountUSDN | |
165 | - | else 0)) | |
137 | + | let availableBalanceB = (balanceB - stakedAmountB) | |
166 | 138 | ||
167 | - | let | |
168 | - | ||
169 | - | ||
139 | + | let accountBalanceWithStakedA = (accountBalance(assetIdA) + stakedAmountA) | |
140 | + | ||
141 | + | let accountBalanceWithStakedB = (accountBalance(assetIdB) + stakedAmountB) | |
170 | 142 | ||
171 | 143 | let hasEnoughBalance = if ((accountBalanceWithStakedA >= balanceA)) | |
172 | 144 | then (accountBalanceWithStakedB >= balanceB) | |
173 | 145 | else false | |
174 | 146 | ||
175 | 147 | func getAssetInfo (assetId) = match assetId { | |
176 | 148 | case id: ByteVector => | |
177 | 149 | let stringId = toBase58String(id) | |
178 | 150 | let info = valueOrErrorMessage(assetInfo(id), (("Asset " + stringId) + " doesn't exist")) | |
179 | 151 | $Tuple3(stringId, info.name, info.decimals) | |
180 | 152 | case waves: Unit => | |
181 | 153 | $Tuple3("WAVES", "WAVES", 8) | |
182 | 154 | case _ => | |
183 | 155 | throw("Match error") | |
184 | 156 | } | |
185 | 157 | ||
186 | 158 | ||
187 | - | func getAssetInfoFromString (assetStr) = if ((assetStr == "WAVES")) | |
188 | - | then $Tuple3("WAVES", "WAVES", 8) | |
189 | - | else { | |
190 | - | let stringId = assetStr | |
191 | - | let id = fromBase58String(assetStr) | |
192 | - | let info = valueOrErrorMessage(assetInfo(id), (("Asset " + stringId) + " doesn't exist")) | |
193 | - | $Tuple3(stringId, info.name, info.decimals) | |
194 | - | } | |
159 | + | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
195 | 160 | ||
196 | 161 | ||
197 | - | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
162 | + | func stakedTokenCount () = { | |
163 | + | let isStakedA = if ((stakedAmountA > 0)) | |
164 | + | then 1 | |
165 | + | else 0 | |
166 | + | let isStakedB = if ((stakedAmountB > 0)) | |
167 | + | then 1 | |
168 | + | else 0 | |
169 | + | (isStakedA + isStakedB) | |
170 | + | } | |
198 | 171 | ||
199 | 172 | ||
200 | 173 | func deductStakingFee (amount,assetId) = if ((assetId == USDN)) | |
201 | 174 | then { | |
202 | - | let result = (amount - stakingFeeInUSDN) | |
175 | + | let result = (amount - (stakedTokenCount() * stakingFeeInUSDN)) | |
203 | 176 | if ((0 >= result)) | |
204 | 177 | then throw((((("Insufficient amount " + toString(amount)) + " to deduct staking fee ") + toString(stakingFeeInUSDN)) + " USD-N")) | |
205 | 178 | else result | |
206 | 179 | } | |
207 | 180 | else amount | |
208 | 181 | ||
209 | 182 | ||
210 | 183 | func throwInsufficientAvailableBalance (amount,available,assetName) = throw((((((((("Insufficient DApp balance to pay " + toString(amount)) + " ") + assetName) + " due to staking. Available: ") + toString(available)) + " ") + assetName) + ". Please contact support in Telegram: https://t.me/swopfisupport")) | |
211 | 184 | ||
212 | 185 | ||
213 | 186 | func throwInsufficientAvailableBalances (amountA,amountB) = throw((((((((((((((((("Insufficient DApp balance to pay " + toString(amountA)) + " ") + assetNameA) + " and ") + toString(amountB)) + " ") + assetNameB) + " due to staking. Available: ") + toString(availableBalanceA)) + " ") + assetNameA) + " and ") + toString(availableBalanceB)) + " ") + assetNameB) + ". Please contact support in Telegram: https://t.me/swopfisupport")) | |
214 | 187 | ||
215 | 188 | ||
216 | 189 | func suspendSuspicious () = suspend(((((((((((((((("Suspicious state. Actual balances: " + toString(accountBalanceWithStakedA)) + " ") + assetNameA) + ", ") + toString(accountBalanceWithStakedB)) + " ") + assetNameB) + ". State: ") + toString(balanceA)) + " ") + assetNameA) + ", ") + toString(balanceB)) + " ") + assetNameB)) | |
217 | 190 | ||
218 | 191 | ||
219 | 192 | @Callable(i) | |
220 | - | func init (firstHarvest) = { | |
221 | - | let $t064796556 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
222 | - | let pmtAmountA = $t064796556._1 | |
223 | - | let pmtAssetIdA = $t064796556._2 | |
224 | - | let $t065616638 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
225 | - | let pmtAmountB = $t065616638._1 | |
226 | - | let pmtAssetIdB = $t065616638._2 | |
227 | - | let $t066436720 = getAssetInfo(pmtAssetIdA) | |
228 | - | let pmtStrAssetIdA = $t066436720._1 | |
229 | - | let pmtAssetNameA = $t066436720._2 | |
230 | - | let pmtDecimalsA = $t066436720._3 | |
231 | - | let $t067256802 = getAssetInfo(pmtAssetIdB) | |
232 | - | let pmtStrAssetIdB = $t067256802._1 | |
233 | - | let pmtAssetNameB = $t067256802._2 | |
234 | - | let pmtDecimalsB = $t067256802._3 | |
235 | - | if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStaking], i.callerPublicKey))) | |
236 | - | then throw("Only admin can call this function") | |
237 | - | else if (isDefined(getBoolean(this, keyActive))) | |
238 | - | then throw("DApp is already active") | |
239 | - | else if ((pmtAssetIdA == pmtAssetIdB)) | |
240 | - | then throw("Assets must be different") | |
241 | - | else { | |
242 | - | let shareName = ((("s" + take(pmtAssetNameA, 7)) + "_") + take(pmtAssetNameB, 7)) | |
243 | - | let shareDescription = ((((("ShareToken of SwopFi protocol for " + pmtAssetNameA) + " and ") + pmtAssetNameB) + " at address ") + toString(this)) | |
244 | - | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
245 | - | let shareInitialSupply = fraction(pow(pmtAmountA, pmtDecimalsA, 5, 1, pmtDecimalsA, HALFDOWN), pow(pmtAmountB, pmtDecimalsB, 5, 1, pmtDecimalsB, HALFDOWN), pow(10, 0, shareDecimals, 0, 0, HALFDOWN)) | |
246 | - | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
247 | - | let shareIssueId = calculateAssetId(shareIssue) | |
248 | - | let baseEntry = [StringEntry(keyVersion, version), BooleanEntry(keyActive, true), StringEntry(keyAssetIdA, pmtStrAssetIdA), StringEntry(keyAssetIdB, pmtStrAssetIdB), IntegerEntry(keyBalanceA, pmtAmountA), IntegerEntry(keyBalanceB, pmtAmountB), IntegerEntry(keyCommission, commission), IntegerEntry(keyCommissionScaleDelimiter, commissionScaleDelimiter), shareIssue, StringEntry(keyShareAssetId, toBase58String(shareIssueId)), IntegerEntry(keyShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareIssueId)] | |
249 | - | if (firstHarvest) | |
250 | - | then (baseEntry ++ [BooleanEntry(keyFirstHarvest, firstHarvest), IntegerEntry(keyFirstHarvestHeight, (startHeight + (firstHarvestEndPeriod * periodLength)))]) | |
251 | - | else baseEntry | |
252 | - | } | |
193 | + | func init () = { | |
194 | + | let $t056135690 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
195 | + | let pmtAmountA = $t056135690._1 | |
196 | + | let pmtAssetIdA = $t056135690._2 | |
197 | + | let $t056955772 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
198 | + | let pmtAmountB = $t056955772._1 | |
199 | + | let pmtAssetIdB = $t056955772._2 | |
200 | + | let $t057775854 = getAssetInfo(pmtAssetIdA) | |
201 | + | let pmtStrAssetIdA = $t057775854._1 | |
202 | + | let pmtAssetNameA = $t057775854._2 | |
203 | + | let pmtDecimalsA = $t057775854._3 | |
204 | + | let $t058595936 = getAssetInfo(pmtAssetIdB) | |
205 | + | let pmtStrAssetIdB = $t058595936._1 | |
206 | + | let pmtAssetNameB = $t058595936._2 | |
207 | + | let pmtDecimalsB = $t058595936._3 | |
208 | + | if (isDefined(getBoolean(this, keyActive))) | |
209 | + | then throw("DApp is already active") | |
210 | + | else if ((pmtAssetIdA == pmtAssetIdB)) | |
211 | + | then throw("Assets must be different") | |
212 | + | else { | |
213 | + | let shareName = ((("s" + take(pmtAssetNameA, 7)) + "_") + take(pmtAssetNameB, 7)) | |
214 | + | let shareDescription = ((((("ShareToken of SwopFi protocol for " + pmtAssetNameA) + " and ") + pmtAssetNameB) + " at address ") + toString(this)) | |
215 | + | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
216 | + | let shareInitialSupply = fraction(pow(pmtAmountA, pmtDecimalsA, 5, 1, pmtDecimalsA, HALFDOWN), pow(pmtAmountB, pmtDecimalsB, 5, 1, pmtDecimalsB, HALFDOWN), pow(10, 0, shareDecimals, 0, 0, HALFDOWN)) | |
217 | + | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
218 | + | let shareIssueId = calculateAssetId(shareIssue) | |
219 | + | [StringEntry(keyVersion, version), BooleanEntry(keyActive, true), StringEntry(keyAssetIdA, pmtStrAssetIdA), StringEntry(keyAssetIdB, pmtStrAssetIdB), IntegerEntry(keyBalanceA, pmtAmountA), IntegerEntry(keyBalanceB, pmtAmountB), IntegerEntry(keyCommission, commission), IntegerEntry(keyCommissionScaleDelimiter, commissionScaleDelimiter), shareIssue, StringEntry(keyShareAssetId, toBase58String(shareIssueId)), IntegerEntry(keyShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareIssueId)] | |
220 | + | } | |
253 | 221 | } | |
254 | - | ||
255 | - | ||
256 | - | ||
257 | - | @Callable(i) | |
258 | - | func initWithInitRatio (amtAssetA,amtAssetB,strAssetIdA,strAssetIdB,firstHarvest) = { | |
259 | - | let $t090109097 = getAssetInfoFromString(strAssetIdA) | |
260 | - | let pmtStrAssetIdA = $t090109097._1 | |
261 | - | let pmtAssetNameA = $t090109097._2 | |
262 | - | let pmtDecimalsA = $t090109097._3 | |
263 | - | let $t091029189 = getAssetInfoFromString(strAssetIdB) | |
264 | - | let pmtStrAssetIdB = $t091029189._1 | |
265 | - | let pmtAssetNameB = $t091029189._2 | |
266 | - | let pmtDecimalsB = $t091029189._3 | |
267 | - | if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStaking], i.callerPublicKey))) | |
268 | - | then throw("Only admin can call this function") | |
269 | - | else if (isDefined(getBoolean(this, keyActive))) | |
270 | - | then throw("DApp is already active") | |
271 | - | else if ((strAssetIdA == strAssetIdB)) | |
272 | - | then throw("Assets must be different") | |
273 | - | else { | |
274 | - | let shareName = ((("s" + take(pmtAssetNameA, 7)) + "_") + take(pmtAssetNameB, 7)) | |
275 | - | let shareDescription = ((((("ShareToken of SwopFi protocol for " + pmtAssetNameA) + " and ") + pmtAssetNameB) + " at address ") + toString(this)) | |
276 | - | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
277 | - | let shareInitialSupply = 0 | |
278 | - | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
279 | - | let shareIssueId = calculateAssetId(shareIssue) | |
280 | - | let baseEntry = [StringEntry(keyVersion, version), BooleanEntry(keyActive, true), StringEntry(keyAssetIdA, pmtStrAssetIdA), StringEntry(keyAssetIdB, pmtStrAssetIdB), IntegerEntry(keyBalanceInitA, amtAssetA), IntegerEntry(keyBalanceInitB, amtAssetB), IntegerEntry(keyBalanceA, 0), IntegerEntry(keyBalanceB, 0), IntegerEntry(keyCommission, commission), IntegerEntry(keyCommissionScaleDelimiter, commissionScaleDelimiter), shareIssue, StringEntry(keyShareAssetId, toBase58String(shareIssueId)), IntegerEntry(keyShareAssetSupply, shareInitialSupply)] | |
281 | - | if (firstHarvest) | |
282 | - | then (baseEntry ++ [BooleanEntry(keyFirstHarvest, firstHarvest), IntegerEntry(keyFirstHarvestHeight, (startHeight + (firstHarvestEndPeriod * periodLength)))]) | |
283 | - | else baseEntry | |
284 | - | } | |
285 | - | } | |
286 | - | ||
287 | - | ||
288 | - | ||
289 | - | @Callable(i) | |
290 | - | func keepLimitForFirstHarvest (shareLimit) = if (!(isActive)) | |
291 | - | then throw("DApp is inactive at this moment") | |
292 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStaking], i.callerPublicKey))) | |
293 | - | then throw("Only admin can call this function") | |
294 | - | else [IntegerEntry(kShareLimit, shareLimit)] | |
295 | 222 | ||
296 | 223 | ||
297 | 224 | ||
298 | 225 | @Callable(i) | |
299 | 226 | func replenishWithTwoTokens (slippageTolerance) = { | |
300 | 227 | let pmtAssetIdA = i.payments[0].assetId | |
301 | 228 | let pmtAssetIdB = i.payments[1].assetId | |
302 | 229 | let pmtAmountA = deductStakingFee(i.payments[0].amount, pmtAssetIdA) | |
303 | 230 | let pmtAmountB = deductStakingFee(i.payments[1].amount, pmtAssetIdB) | |
304 | - | if (if ((balanceA == 0)) | |
305 | - | then (balanceB == 0) | |
306 | - | else false) | |
307 | - | then { | |
308 | - | let $t01187411951 = getAssetInfo(pmtAssetIdA) | |
309 | - | let pmtStrAssetIdA = $t01187411951._1 | |
310 | - | let pmtAssetNameA = $t01187411951._2 | |
311 | - | let pmtDecimalsA = $t01187411951._3 | |
312 | - | let $t01196012037 = getAssetInfo(pmtAssetIdB) | |
313 | - | let pmtStrAssetIdB = $t01196012037._1 | |
314 | - | let pmtAssetNameB = $t01196012037._2 | |
315 | - | let pmtDecimalsB = $t01196012037._3 | |
316 | - | let tokenRatio = fraction(fraction(assetInitA, scaleValue8, pmtAmountA), scaleValue3, fraction(assetInitB, scaleValue8, pmtAmountB)) | |
317 | - | if ((pmtAssetIdA == pmtAssetIdB)) | |
318 | - | then throw("Assets must be different") | |
319 | - | else { | |
320 | - | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
321 | - | let shareInitialSupply = fraction(pow(pmtAmountA, pmtDecimalsA, 5, 1, pmtDecimalsA, HALFDOWN), pow(pmtAmountB, pmtDecimalsB, 5, 1, pmtDecimalsB, HALFDOWN), pow(10, 0, shareDecimals, 0, 0, HALFDOWN)) | |
322 | - | if (!(isActive)) | |
323 | - | then throw("DApp is inactive at this moment") | |
324 | - | else if (if ((0 > slippageTolerance)) | |
325 | - | then true | |
326 | - | else (slippageTolerance > slippageToleranceDelimiter)) | |
327 | - | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
328 | - | else if ((size(i.payments) != 2)) | |
329 | - | then throw("Two attached assets expected") | |
330 | - | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
331 | - | then true | |
332 | - | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
333 | - | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
334 | - | else if (if ((pmtAssetIdA != assetIdA)) | |
335 | - | then true | |
336 | - | else (pmtAssetIdB != assetIdB)) | |
337 | - | then throw(((("Incorrect assets attached. Expected: " + strAssetIdA) + " and ") + strAssetIdB)) | |
338 | - | else if ((shareInitialSupply == 0)) | |
339 | - | then throw("Too small amount to replenish") | |
340 | - | else if (!(hasEnoughBalance)) | |
341 | - | then ([ScriptTransfer(i.caller, pmtAmountA, pmtAssetIdA), ScriptTransfer(i.caller, pmtAmountB, pmtAssetIdB)] ++ suspendSuspicious()) | |
342 | - | else [Reissue(shareAssetId, shareInitialSupply, true), IntegerEntry(keyBalanceA, pmtAmountA), IntegerEntry(keyBalanceB, pmtAmountB), IntegerEntry(keyShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareAssetId)] | |
343 | - | } | |
344 | - | } | |
345 | - | else { | |
346 | - | let tokenRatio = fraction(fraction(balanceA, scaleValue8, pmtAmountA), scaleValue3, fraction(balanceB, scaleValue8, pmtAmountB)) | |
347 | - | let ratioShareTokensInA = fraction(pmtAmountA, scaleValue8, balanceA) | |
348 | - | let ratioShareTokensInB = fraction(pmtAmountB, scaleValue8, balanceB) | |
349 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
350 | - | if (!(isActive)) | |
351 | - | then throw("DApp is inactive at this moment") | |
352 | - | else if (if ((0 > slippageTolerance)) | |
231 | + | let tokenRatio = fraction(fraction(balanceA, scaleValue8, pmtAmountA), scaleValue3, fraction(balanceB, scaleValue8, pmtAmountB)) | |
232 | + | let ratioShareTokensInA = fraction(pmtAmountA, scaleValue8, balanceA) | |
233 | + | let ratioShareTokensInB = fraction(pmtAmountB, scaleValue8, balanceB) | |
234 | + | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
235 | + | if (!(isActive)) | |
236 | + | then throw("DApp is inactive at this moment") | |
237 | + | else if (if ((0 > slippageTolerance)) | |
238 | + | then true | |
239 | + | else (slippageTolerance > slippageToleranceDelimiter)) | |
240 | + | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
241 | + | else if ((size(i.payments) != 2)) | |
242 | + | then throw("Two attached assets expected") | |
243 | + | else if (if ((pmtAssetIdA != assetIdA)) | |
353 | 244 | then true | |
354 | - | else (slippageTolerance > slippageToleranceDelimiter)) | |
355 | - | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
356 | - | else if ((size(i.payments) != 2)) | |
357 | - | then throw("Two attached assets expected") | |
358 | - | else if (if ((pmtAssetIdA != assetIdA)) | |
359 | - | then true | |
360 | - | else (pmtAssetIdB != assetIdB)) | |
361 | - | then throw(((("Incorrect assets attached. Expected: " + strAssetIdA) + " and ") + strAssetIdB)) | |
362 | - | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
363 | - | then true | |
364 | - | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
365 | - | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
366 | - | else if ((shareTokenToPayAmount == 0)) | |
367 | - | then throw("Too small amount to replenish") | |
368 | - | else if (!(hasEnoughBalance)) | |
369 | - | then ([ScriptTransfer(i.caller, pmtAmountA, pmtAssetIdA), ScriptTransfer(i.caller, pmtAmountB, pmtAssetIdB)] ++ suspendSuspicious()) | |
370 | - | else [IntegerEntry(keyBalanceA, (balanceA + pmtAmountA)), IntegerEntry(keyBalanceB, (balanceB + pmtAmountB)), IntegerEntry(keyShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
371 | - | } | |
245 | + | else (pmtAssetIdB != assetIdB)) | |
246 | + | then throw(((("Incorrect assets attached. Expected: " + strAssetIdA) + " and ") + strAssetIdB)) | |
247 | + | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
248 | + | then true | |
249 | + | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
250 | + | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
251 | + | else if ((shareTokenToPayAmount == 0)) | |
252 | + | then throw("Too small amount to replenish") | |
253 | + | else if (!(hasEnoughBalance)) | |
254 | + | then ([ScriptTransfer(i.caller, pmtAmountA, pmtAssetIdA), ScriptTransfer(i.caller, pmtAmountB, pmtAssetIdB)] ++ suspendSuspicious()) | |
255 | + | else [IntegerEntry(keyBalanceA, (balanceA + pmtAmountA)), IntegerEntry(keyBalanceB, (balanceB + pmtAmountB)), IntegerEntry(keyShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
372 | 256 | } | |
373 | 257 | ||
374 | 258 | ||
375 | 259 | ||
376 | 260 | @Callable(i) | |
377 | 261 | func withdraw () = { | |
378 | - | let $ | |
379 | - | let pmtAmount = $ | |
380 | - | let pmtAssetId = $ | |
262 | + | let $t01000910159 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
263 | + | let pmtAmount = $t01000910159._1 | |
264 | + | let pmtAssetId = $t01000910159._2 | |
381 | 265 | let amountToPayA = deductStakingFee(fraction(pmtAmount, balanceA, shareAssetSupply), assetIdA) | |
382 | 266 | let amountToPayB = deductStakingFee(fraction(pmtAmount, balanceB, shareAssetSupply), assetIdB) | |
383 | 267 | if (!(isActive)) | |
384 | 268 | then throw("DApp is inactive at this moment") | |
385 | 269 | else if ((size(i.payments) != 1)) | |
386 | 270 | then throw("One attached payment expected") | |
387 | 271 | else if ((pmtAssetId != shareAssetId)) | |
388 | 272 | then throw(("Incorrect asset attached. Expected: " + toBase58String(shareAssetId))) | |
389 | 273 | else if (!(hasEnoughBalance)) | |
390 | 274 | then ([ScriptTransfer(i.caller, pmtAmount, pmtAssetId)] ++ suspendSuspicious()) | |
391 | 275 | else if (if ((amountToPayA > availableBalanceA)) | |
392 | 276 | then true | |
393 | 277 | else (amountToPayB > availableBalanceB)) | |
394 | 278 | then throwInsufficientAvailableBalances(amountToPayA, amountToPayB) | |
395 | 279 | else [IntegerEntry(keyBalanceA, (balanceA - amountToPayA)), IntegerEntry(keyBalanceB, (balanceB - amountToPayB)), IntegerEntry(keyShareAssetSupply, (shareAssetSupply - pmtAmount)), Burn(shareAssetId, pmtAmount), ScriptTransfer(i.caller, amountToPayA, assetIdA), ScriptTransfer(i.caller, amountToPayB, assetIdB)] | |
396 | 280 | } | |
397 | 281 | ||
398 | 282 | ||
399 | 283 | ||
400 | 284 | @Callable(i) | |
401 | 285 | func exchange (minAmountToReceive) = { | |
402 | - | let $ | |
403 | - | let pmtAmount = $ | |
404 | - | let pmtAssetId = $ | |
286 | + | let $t01136511440 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
287 | + | let pmtAmount = $t01136511440._1 | |
288 | + | let pmtAssetId = $t01136511440._2 | |
405 | 289 | func calculateFees (tokenFrom,tokenTo) = { | |
406 | 290 | let amountWithoutFee = fraction(tokenTo, pmtAmount, (pmtAmount + tokenFrom)) | |
407 | 291 | let amountWithFee = fraction(amountWithoutFee, (commissionScaleDelimiter - commission), commissionScaleDelimiter) | |
408 | 292 | let governanceReward = fraction(amountWithoutFee, commissionGovernance, commissionScaleDelimiter) | |
409 | 293 | if ((minAmountToReceive > amountWithFee)) | |
410 | 294 | then throw(((("Calculated amount to receive " + toString(amountWithFee)) + " is less than specified minimum ") + toString(minAmountToReceive))) | |
411 | 295 | else $Tuple3(amountWithoutFee, amountWithFee, governanceReward) | |
412 | 296 | } | |
413 | 297 | ||
414 | 298 | if (!(isActive)) | |
415 | 299 | then throw("DApp is inactive at this moment") | |
416 | - | else if (if ((balanceA == 0)) | |
417 | - | then true | |
418 | - | else (balanceB == 0)) | |
419 | - | then throw("Can't exchange with zero balance") | |
420 | - | else if ((0 >= minAmountToReceive)) | |
421 | - | then throw(("Minimal amount to receive must be positive. Actual: " + toString(minAmountToReceive))) | |
422 | - | else if ((size(i.payments) != 1)) | |
423 | - | then throw("One attached payment expected") | |
424 | - | else if (!(hasEnoughBalance)) | |
425 | - | then ([ScriptTransfer(i.caller, pmtAmount, pmtAssetId)] ++ suspendSuspicious()) | |
426 | - | else if ((pmtAssetId == assetIdA)) | |
300 | + | else if ((0 >= minAmountToReceive)) | |
301 | + | then throw(("Minimal amount to receive must be positive. Actual: " + toString(minAmountToReceive))) | |
302 | + | else if ((size(i.payments) != 1)) | |
303 | + | then throw("One attached payment expected") | |
304 | + | else if (!(hasEnoughBalance)) | |
305 | + | then ([ScriptTransfer(i.caller, pmtAmount, pmtAssetId)] ++ suspendSuspicious()) | |
306 | + | else if ((pmtAssetId == assetIdA)) | |
307 | + | then { | |
308 | + | let assetIdSend = assetIdB | |
309 | + | let $t01261512706 = calculateFees(balanceA, balanceB) | |
310 | + | let amountWithoutFee = $t01261512706._1 | |
311 | + | let amountWithFee = $t01261512706._2 | |
312 | + | let governanceReward = $t01261512706._3 | |
313 | + | let newBalanceA = (balanceA + pmtAmount) | |
314 | + | let newBalanceB = ((balanceB - amountWithFee) - governanceReward) | |
315 | + | if (if ((stakedAmountA >= newBalanceA)) | |
316 | + | then true | |
317 | + | else (stakedAmountB >= newBalanceB)) | |
318 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
319 | + | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(governanceAddress, governanceReward, assetIdSend)] | |
320 | + | } | |
321 | + | else if ((pmtAssetId == assetIdB)) | |
427 | 322 | then { | |
428 | - | let assetIdSend = assetIdB | |
429 | - | let $t01915419245 = calculateFees(balanceA, balanceB) | |
430 | - | let amountWithoutFee = $t01915419245._1 | |
431 | - | let amountWithFee = $t01915419245._2 | |
432 | - | let governanceReward = $t01915419245._3 | |
433 | - | let newBalanceA = (balanceA + pmtAmount) | |
434 | - | let newBalanceB = ((balanceB - amountWithFee) - governanceReward) | |
435 | - | if (if (if ((assetIdA == USDN)) | |
436 | - | then (stakedAmountUSDN >= newBalanceA) | |
437 | - | else false) | |
323 | + | let assetIdSend = assetIdA | |
324 | + | let $t01352913620 = calculateFees(balanceB, balanceA) | |
325 | + | let amountWithoutFee = $t01352913620._1 | |
326 | + | let amountWithFee = $t01352913620._2 | |
327 | + | let governanceReward = $t01352913620._3 | |
328 | + | let newBalanceA = ((balanceA - amountWithFee) - governanceReward) | |
329 | + | let newBalanceB = (balanceB + pmtAmount) | |
330 | + | if (if ((stakedAmountA >= newBalanceA)) | |
438 | 331 | then true | |
439 | - | else if ((assetIdB == USDN)) | |
440 | - | then (stakedAmountUSDN >= newBalanceB) | |
441 | - | else false) | |
442 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
443 | - | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(walletAddress, governanceReward, assetIdSend)] | |
332 | + | else (stakedAmountB >= newBalanceB)) | |
333 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
334 | + | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(governanceAddress, governanceReward, assetIdSend)] | |
444 | 335 | } | |
445 | - | else if ((pmtAssetId == assetIdB)) | |
446 | - | then { | |
447 | - | let assetIdSend = assetIdA | |
448 | - | let $t02011420205 = calculateFees(balanceB, balanceA) | |
449 | - | let amountWithoutFee = $t02011420205._1 | |
450 | - | let amountWithFee = $t02011420205._2 | |
451 | - | let governanceReward = $t02011420205._3 | |
452 | - | let newBalanceA = ((balanceA - amountWithFee) - governanceReward) | |
453 | - | let newBalanceB = (balanceB + pmtAmount) | |
454 | - | if (if (if ((assetIdA == USDN)) | |
455 | - | then (stakedAmountUSDN >= newBalanceA) | |
456 | - | else false) | |
457 | - | then true | |
458 | - | else if ((assetIdB == USDN)) | |
459 | - | then (stakedAmountUSDN >= newBalanceB) | |
460 | - | else false) | |
461 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
462 | - | else [IntegerEntry(keyBalanceA, newBalanceA), IntegerEntry(keyBalanceB, newBalanceB), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(walletAddress, governanceReward, assetIdSend)] | |
463 | - | } | |
464 | - | else throw(((("Incorrect asset attached. Expected: " + strAssetIdA) + " or ") + strAssetIdB)) | |
336 | + | else throw(((("Incorrect asset attached. Expected: " + strAssetIdA) + " or ") + strAssetIdB)) | |
465 | 337 | } | |
466 | 338 | ||
467 | 339 | ||
468 | 340 | ||
469 | 341 | @Callable(i) | |
470 | 342 | func shutdown () = if (!(isActive)) | |
471 | 343 | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
472 | 344 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
473 | 345 | then throw("Only admin can call this function") | |
474 | 346 | else suspend("Paused by admin") | |
475 | 347 | ||
476 | 348 | ||
477 | 349 | ||
478 | 350 | @Callable(i) | |
479 | 351 | func activate () = if (isActive) | |
480 | 352 | then throw("DApp is already active") | |
481 | 353 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
482 | 354 | then throw("Only admin can call this function") | |
483 | 355 | else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)] | |
484 | 356 | ||
485 | 357 | ||
486 | 358 | ||
487 | 359 | @Callable(i) | |
488 | 360 | func takeIntoAccountExtraFunds (amountLeave) = { | |
489 | 361 | let uncountableAmountEnrollAssetA = (accountBalanceWithStakedA - balanceA) | |
490 | 362 | let uncountableAmountEnrollAssetB = (accountBalanceWithStakedB - balanceB) | |
491 | 363 | let amountEnrollA = (uncountableAmountEnrollAssetA - (if ((assetIdA == unit)) | |
492 | 364 | then amountLeave | |
493 | 365 | else 0)) | |
494 | 366 | let amountEnrollB = (uncountableAmountEnrollAssetB - (if ((assetIdB == unit)) | |
495 | 367 | then amountLeave | |
496 | 368 | else 0)) | |
497 | 369 | if (!(isActive)) | |
498 | 370 | then throw("DApp is inactive at this moment") | |
499 | 371 | else if ((i.caller != this)) | |
500 | 372 | then throw("Only the DApp itself can call this function") | |
501 | 373 | else if ((0 > amountLeave)) | |
502 | 374 | then throw(("Argument 'amountLeave' cannot be negative. Actual: " + toString(amountLeave))) | |
503 | 375 | else if (if ((0 > uncountableAmountEnrollAssetA)) | |
504 | 376 | then true | |
505 | 377 | else (0 > uncountableAmountEnrollAssetB)) | |
506 | 378 | then suspend("Enroll amount negative") | |
507 | 379 | else if (if ((0 > amountEnrollA)) | |
508 | 380 | then true | |
509 | 381 | else (0 > amountEnrollB)) | |
510 | 382 | then throw("Too large amountLeave") | |
511 | 383 | else [IntegerEntry(keyBalanceA, (balanceA + amountEnrollA)), IntegerEntry(keyBalanceB, (balanceB + amountEnrollB)), IntegerEntry(("last_income_" + strAssetIdA), amountEnrollA), IntegerEntry(("last_income_" + strAssetIdB), amountEnrollB)] | |
512 | 384 | } | |
513 | 385 | ||
514 | 386 | ||
515 | 387 | @Verifier(tx) | |
516 | 388 | func verify () = match tx { | |
517 | 389 | case invoke: InvokeScriptTransaction => | |
518 | - | let callTakeIntoAccount = if ((invoke.dApp == this)) | |
519 | - | then (invoke.function == "takeIntoAccountExtraFunds") | |
520 | - | else false | |
521 | - | let callStaking = if ((invoke.dApp == stakingAddress)) | |
522 | - | then if (if (if ((invoke.function == "lockNeutrino")) | |
523 | - | then (size(invoke.payments) == 1) | |
524 | - | else false) | |
525 | - | then (invoke.payments[0].assetId == USDN) | |
526 | - | else false) | |
527 | - | then true | |
528 | - | else if ((invoke.function == "unlockNeutrino")) | |
529 | - | then (size(invoke.payments) == 0) | |
530 | - | else false | |
531 | - | else false | |
532 | - | let exchangeToWaves = if (if (if ((invoke.dApp == USDNToWavesExchanger)) | |
533 | - | then (invoke.function == "exchange") | |
534 | - | else false) | |
535 | - | then (assetIdA == USDN) | |
390 | + | if (if (if (sigVerify(invoke.bodyBytes, invoke.proofs[0], adminPubKeyStaking)) | |
391 | + | then (invoke.dApp == stakingAddressUSDN) | |
536 | 392 | else false) | |
537 | 393 | then true | |
538 | - | else if ((assetIdB == USDN)) | |
539 | - | then (invoke.payments[0].assetId == USDN) | |
394 | + | else if (if (sigVerify(invoke.bodyBytes, invoke.proofs[0], adminPubKeyStaking)) | |
395 | + | then (invoke.function == "exchange") | |
396 | + | else false) | |
397 | + | then if (if (if (if ((assetIdA == NSBT)) | |
398 | + | then (assetIdB == USDN) | |
399 | + | else false) | |
400 | + | then (invoke.dApp == swopUSDNtoWAVES) | |
401 | + | else false) | |
402 | + | then if ((invoke.payments[0].assetId == unit)) | |
403 | + | then true | |
404 | + | else (invoke.payments[0].assetId == USDN) | |
405 | + | else false) | |
406 | + | then true | |
407 | + | else if (if ((assetIdA == NSBT)) | |
408 | + | then (assetIdB == SWOP) | |
409 | + | else false) | |
410 | + | then if (if ((invoke.dApp == swopUSDNtoNSBT)) | |
411 | + | then (invoke.payments[0].assetId == USDN) | |
412 | + | else false) | |
413 | + | then true | |
414 | + | else if ((invoke.dApp == swopUSDNtoWAVES)) | |
415 | + | then if ((invoke.payments[0].assetId == unit)) | |
416 | + | then true | |
417 | + | else (invoke.payments[0].assetId == USDN) | |
418 | + | else false | |
419 | + | else false | |
420 | + | else false) | |
421 | + | then true | |
422 | + | else if (if (sigVerify(invoke.bodyBytes, invoke.proofs[0], adminPubKeyStaking)) | |
423 | + | then (invoke.dApp == this) | |
424 | + | else false) | |
425 | + | then (invoke.function == "takeIntoAccountExtraFunds") | |
540 | 426 | else false | |
541 | - | let signedByAdmin = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
542 | - | then true | |
543 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey2)) | |
544 | - | then true | |
545 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey3)) | |
546 | - | then true | |
547 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKeyStaking) | |
548 | - | if (if (if (callTakeIntoAccount) | |
549 | - | then true | |
550 | - | else callStaking) | |
551 | - | then true | |
552 | - | else exchangeToWaves) | |
553 | - | then signedByAdmin | |
554 | - | else false | |
555 | 427 | case _ => | |
556 | 428 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
557 | 429 | then 1 | |
558 | 430 | else 0 | |
559 | 431 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
560 | 432 | then 1 | |
561 | 433 | else 0 | |
562 | 434 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
563 | 435 | then 1 | |
564 | 436 | else 0 | |
565 | 437 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
566 | 438 | } | |
567 | 439 |
github/deemru/w8io/169f3d6 122.71 ms ◑