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