tx · D19hCqgMgnsU22KXdQST57REuJFQmDbxebpQpXzo8E7n 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq: -0.01000000 Waves 2024.03.04 11:21 [3003009] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves
{ "type": 13, "id": "D19hCqgMgnsU22KXdQST57REuJFQmDbxebpQpXzo8E7n", "fee": 1000000, "feeAssetId": null, "timestamp": 1709540473665, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "4EwXkLdq6zoqsLWabTxjDoPgfnwtswNpHhfEfWNKNPJWBofgKJdoyASYhyTEj2i8mjUsQ1KSH8aDap3mTG96e639" ], "script": "base64:BgIECAISAA8AEGFtb3VudEFzc2V0SWRLZXkCDWFtb3VudEFzc2V0SWQAD3ByaWNlQXNzZXRJZEtleQIMcHJpY2VBc3NldElkAApmZWVSYXRlS2V5AgdmZWVSYXRlAQpnZXRBc3NldElkAQ1hc3NldElkU3RyaW5nAwkAAAIFDWFzc2V0SWRTdHJpbmcCBVdBVkVTBQR1bml0CQDZBAEFDWFzc2V0SWRTdHJpbmcBD2dldEFzc2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAJpZAUHJG1hdGNoMAkA8AcCBQR0aGlzBQJpZAgJAO8HAQUEdGhpcwlhdmFpbGFibGUAE2Ftb3VudEFzc2V0SWRTdHJpbmcJARFAZXh0ck5hdGl2ZSgxMDUzKQIFBHRoaXMFEGFtb3VudEFzc2V0SWRLZXkADWFtb3VudEFzc2V0SWQJAQpnZXRBc3NldElkAQUTYW1vdW50QXNzZXRJZFN0cmluZwASYW1vdW50QXNzZXRCYWxhbmNlCQEPZ2V0QXNzZXRCYWxhbmNlAQUNYW1vdW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Y2hlY2tzBA1wYXltZW50QW1vdW50CAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAQJaW5pdEFtQmFsBRJhbW91bnRBc3NldEJhbGFuY2UECWluaXRQckJhbAkAZQIFEXByaWNlQXNzZXRCYWxhbmNlBQ1wYXltZW50QW1vdW50AAAJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAWkBA2ZvbwAJAJQKAgUDbmlsAAAAQWNTUw==", "height": 3003009, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5pdCPCDyatDLkfxt8mLnER4YMzvntECsNYP3WBDqMhRD Next: 2nivHmoga7eHVqiQMFBLchp1TyeJGedErJ4CZQN3mQ5M Diff:
Old | New | Differences | |
---|---|---|---|
37 | 37 | let feeRate = valueOrElse(getInteger(this, feeRateKey), 1000000) | |
38 | 38 | ||
39 | 39 | func calcSendAmount (initAmBal,initPrBal,paymentAmount) = { | |
40 | - | let sendAmount = (initAmBal - fraction(initAmBal, initPrBal, initPrBal)) | |
40 | + | let sendAmount = (initAmBal - fraction(initAmBal, initPrBal, (initPrBal + paymentAmount))) | |
41 | 41 | let newAmBal = (initAmBal - sendAmount) | |
42 | 42 | let newPrBal = (initPrBal + paymentAmount) | |
43 | 43 | let oldK = (initAmBal * initPrBal) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let amountAssetIdKey = "amountAssetId" | |
5 | 5 | ||
6 | 6 | let priceAssetIdKey = "priceAssetId" | |
7 | 7 | ||
8 | 8 | let feeRateKey = "feeRate" | |
9 | 9 | ||
10 | 10 | func getAssetId (assetIdString) = if ((assetIdString == "WAVES")) | |
11 | 11 | then unit | |
12 | 12 | else fromBase58String(assetIdString) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func getAssetBalance (assetId) = match assetId { | |
16 | 16 | case id: ByteVector => | |
17 | 17 | assetBalance(this, id) | |
18 | 18 | case _ => | |
19 | 19 | wavesBalance(this).available | |
20 | 20 | } | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | let amountAssetIdString = getStringValue(this, amountAssetIdKey) | |
24 | 24 | ||
25 | 25 | let amountAssetId = getAssetId(amountAssetIdString) | |
26 | 26 | ||
27 | 27 | let amountAssetBalance = getAssetBalance(amountAssetId) | |
28 | 28 | ||
29 | 29 | let priceAssetIdString = getStringValue(this, priceAssetIdKey) | |
30 | 30 | ||
31 | 31 | let priceAssetId = getAssetId(priceAssetIdString) | |
32 | 32 | ||
33 | 33 | let priceAssetBalance = getAssetBalance(priceAssetId) | |
34 | 34 | ||
35 | 35 | let SCALE8 = 100000000 | |
36 | 36 | ||
37 | 37 | let feeRate = valueOrElse(getInteger(this, feeRateKey), 1000000) | |
38 | 38 | ||
39 | 39 | func calcSendAmount (initAmBal,initPrBal,paymentAmount) = { | |
40 | - | let sendAmount = (initAmBal - fraction(initAmBal, initPrBal, initPrBal)) | |
40 | + | let sendAmount = (initAmBal - fraction(initAmBal, initPrBal, (initPrBal + paymentAmount))) | |
41 | 41 | let newAmBal = (initAmBal - sendAmount) | |
42 | 42 | let newPrBal = (initPrBal + paymentAmount) | |
43 | 43 | let oldK = (initAmBal * initPrBal) | |
44 | 44 | let newK = (newAmBal * newPrBal) | |
45 | 45 | $Tuple7(sendAmount, initAmBal, initPrBal, oldK, newAmBal, newPrBal, newK) | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func swap (i) = { | |
50 | 50 | let checks = [if ((size(i.payments) > 0)) | |
51 | 51 | then true | |
52 | 52 | else throw("should be with 1 payment"), if ((i.payments[0].assetId == priceAssetId)) | |
53 | 53 | then true | |
54 | 54 | else throw(makeString(["payment assetId should be: ", priceAssetIdString], " "))] | |
55 | 55 | if ((checks == checks)) | |
56 | 56 | then { | |
57 | 57 | let paymentAmount = i.payments[0].amount | |
58 | 58 | let initAmBal = amountAssetBalance | |
59 | 59 | let initPrBal = (priceAssetBalance - paymentAmount) | |
60 | 60 | 0 | |
61 | 61 | } | |
62 | 62 | else throw("Strict value is not equal to itself.") | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | @Callable(i) | |
67 | 67 | func foo () = $Tuple2(nil, 0) | |
68 | 68 | ||
69 | 69 |
github/deemru/w8io/169f3d6 36.83 ms ◑