tx · 2Zi8bASgFzqwvmfNYcaxN51B1JhskY1PwBKiAwAZX2D2
3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL: -0.01400000 Waves
2019.07.16 15:58 [588411] smart account 3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL > SELF 0.00000000 Waves
{
"type": 13,
"id": "2Zi8bASgFzqwvmfNYcaxN51B1JhskY1PwBKiAwAZX2D2",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1563281959550,
"version": 1,
"sender": "3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL",
"senderPublicKey": "3RTmBp69DqXiohzMXcmVU1pMFssmztWoibFARiKrgTr7",
"proofs": [
"2MyYnUYiZ7u6ir3aU2sEktq11oB5XR3MzBovVksWdrdaDQ6yi8A999EpirscppGU1D6mjugY1rVEYwWHHQchCVDE"
],
"script": "base64:AAIDAAAAAAAAAAAAAAACAAAAAAhJZFRva2VuQQEAAAAg6Sj/x9+sQXsLyMd4sb3avDnHYqUuSNW1qsm9UzCcO+sAAAAACElkVG9rZW5CBQAAAAR1bml0AAAAAQAAAApjb250ZXh0T2JqAQAAAAhleGNoYW5nZQAAAAAEAAAAB2Ftb3VudEEJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAAB2Ftb3VudEEEAAAAB2Ftb3VudEIJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAAB2Ftb3VudEIEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAAB3BheW1lbnQDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0F0dGFjaGVkUGF5bWVudAQAAAABcAUAAAAHJG1hdGNoMAUAAAABcAkAAAIAAAABAgAAABRQYXltZW50IG5vdCBhdHRhY2hlZAQAAAAPYXNzZXRJZFJlY2VpdmVkCAUAAAAHcGF5bWVudAAAAAdhc3NldElkBAAAABJ0b2tlblJlY2VpdmV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AEnRva2VuUmVjZWl2ZUFtb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAHYW1vdW50QQkAAGUAAAACBQAAAAdhbW91bnRBBQAAAA90b2tlblNlbmRBbW91bnQFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAAD3Rva2VuU2VuZEFtb3VudAUAAAALYXNzZXRJZFNlbnQFAAAAA25pbAkAAAIAAAABAgAAABRBc3NldCBpcyBub3QgYWxsb3dlZAAAAADgESq3",
"chainId": 84,
"height": 588411,
"spentComplexity": 0
}
View: original | compacted
Prev: DZir4QPMzTsnknedvq6VHKfKfcYFBim7Uzx5ruV5WyqZ
Next: DbarVWahmHKnZ4pjSotr4EwuTX2CGDxeXhugfuqN5nPu
Diff:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let IdTokenA = base58'BaBy2y5tGsuQZPMM7JHU89zmahR7yybXaVMXpnZ589An' |
---|
| 4 | + | let IdTokenA = base58'GhAFhXzwCYfvcXQ3GHFaQFnCzAuYCT156qFqiYyzfkzv' |
---|
5 | 5 | | |
---|
6 | 6 | | let IdTokenB = unit |
---|
7 | 7 | | |
---|
|
17 | 17 | | } |
---|
18 | 18 | | let assetIdReceived = payment.assetId |
---|
19 | 19 | | let tokenReceiveAmount = payment.amount |
---|
20 | | - | if ((assetIdReceived == IdTokenA)) |
---|
| 20 | + | if ((assetIdReceived == IdTokenB)) |
---|
21 | 21 | | then { |
---|
22 | | - | let tokenSendAmount = fraction(amountA, tokenReceiveAmount, (tokenReceiveAmount + amountB)) |
---|
23 | | - | let assetIdSent = unit |
---|
24 | | - | ScriptResult(WriteSet([DataEntry("amountB", (amountB + tokenReceiveAmount)), DataEntry("amountA", (amountA - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
| 22 | + | let tokenSendAmount = fraction(amountB, tokenReceiveAmount, (tokenReceiveAmount + amountA)) |
---|
| 23 | + | let assetIdSent = IdTokenA |
---|
| 24 | + | ScriptResult(WriteSet([DataEntry("amountB", (amountB - tokenSendAmount)), DataEntry("amountA", (amountA + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
25 | 25 | | } |
---|
26 | | - | else if ((assetIdReceived == IdTokenB)) |
---|
| 26 | + | else if ((assetIdReceived == IdTokenA)) |
---|
27 | 27 | | then { |
---|
28 | | - | let tokenSendAmount = fraction(amountB, tokenReceiveAmount, (tokenReceiveAmount + amountA)) |
---|
29 | | - | let assetIdSent = IdTokenA |
---|
30 | | - | ScriptResult(WriteSet([DataEntry("amountB", (amountB - tokenSendAmount)), DataEntry("amountA", (amountA + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
| 28 | + | let tokenSendAmount = fraction(amountA, tokenReceiveAmount, (tokenReceiveAmount + amountB)) |
---|
| 29 | + | let assetIdSent = unit |
---|
| 30 | + | ScriptResult(WriteSet([DataEntry("amountB", (amountB + tokenReceiveAmount)), DataEntry("amountA", (amountA - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
31 | 31 | | } |
---|
32 | 32 | | else throw("Asset is not allowed") |
---|
33 | 33 | | } |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let IdTokenA = base58'BaBy2y5tGsuQZPMM7JHU89zmahR7yybXaVMXpnZ589An' |
---|
| 4 | + | let IdTokenA = base58'GhAFhXzwCYfvcXQ3GHFaQFnCzAuYCT156qFqiYyzfkzv' |
---|
5 | 5 | | |
---|
6 | 6 | | let IdTokenB = unit |
---|
7 | 7 | | |
---|
8 | 8 | | @Callable(contextObj) |
---|
9 | 9 | | func exchange () = { |
---|
10 | 10 | | let amountA = getIntegerValue(this, "amountA") |
---|
11 | 11 | | let amountB = getIntegerValue(this, "amountB") |
---|
12 | 12 | | let payment = match contextObj.payment { |
---|
13 | 13 | | case p: AttachedPayment => |
---|
14 | 14 | | p |
---|
15 | 15 | | case _ => |
---|
16 | 16 | | throw("Payment not attached") |
---|
17 | 17 | | } |
---|
18 | 18 | | let assetIdReceived = payment.assetId |
---|
19 | 19 | | let tokenReceiveAmount = payment.amount |
---|
20 | | - | if ((assetIdReceived == IdTokenA)) |
---|
| 20 | + | if ((assetIdReceived == IdTokenB)) |
---|
21 | 21 | | then { |
---|
22 | | - | let tokenSendAmount = fraction(amountA, tokenReceiveAmount, (tokenReceiveAmount + amountB)) |
---|
23 | | - | let assetIdSent = unit |
---|
24 | | - | ScriptResult(WriteSet([DataEntry("amountB", (amountB + tokenReceiveAmount)), DataEntry("amountA", (amountA - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
| 22 | + | let tokenSendAmount = fraction(amountB, tokenReceiveAmount, (tokenReceiveAmount + amountA)) |
---|
| 23 | + | let assetIdSent = IdTokenA |
---|
| 24 | + | ScriptResult(WriteSet([DataEntry("amountB", (amountB - tokenSendAmount)), DataEntry("amountA", (amountA + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
25 | 25 | | } |
---|
26 | | - | else if ((assetIdReceived == IdTokenB)) |
---|
| 26 | + | else if ((assetIdReceived == IdTokenA)) |
---|
27 | 27 | | then { |
---|
28 | | - | let tokenSendAmount = fraction(amountB, tokenReceiveAmount, (tokenReceiveAmount + amountA)) |
---|
29 | | - | let assetIdSent = IdTokenA |
---|
30 | | - | ScriptResult(WriteSet([DataEntry("amountB", (amountB - tokenSendAmount)), DataEntry("amountA", (amountA + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
| 28 | + | let tokenSendAmount = fraction(amountA, tokenReceiveAmount, (tokenReceiveAmount + amountB)) |
---|
| 29 | + | let assetIdSent = unit |
---|
| 30 | + | ScriptResult(WriteSet([DataEntry("amountB", (amountB + tokenReceiveAmount)), DataEntry("amountA", (amountA - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
31 | 31 | | } |
---|
32 | 32 | | else throw("Asset is not allowed") |
---|
33 | 33 | | } |
---|
34 | 34 | | |
---|
35 | 35 | | |
---|