tx · 3mbQpL9V1L9bRAkhiood43XYiLcUrQKt5bHjxRxs58bh 3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL: -0.01400000 Waves 2019.08.22 15:32 [642328] smart account 3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL > SELF 0.00000000 Waves
{ "type": 13, "id": "3mbQpL9V1L9bRAkhiood43XYiLcUrQKt5bHjxRxs58bh", "fee": 1400000, "feeAssetId": null, "timestamp": 1566477232758, "version": 1, "sender": "3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL", "senderPublicKey": "3RTmBp69DqXiohzMXcmVU1pMFssmztWoibFARiKrgTr7", "proofs": [ "32qW3nLSFzmrVf4pXen6JzKvThPytpiyvUynMdRabSxh4ZxxpxXCmmJJ9ZPu5JHQiovng7EnGXteQnJfWnRwz9Fo" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAAAAAAVvd25lcgEAAAAaAVSTOHBLt7RyJdugRiL5k8zovFc+bobXqh8AAAAADWFzc2V0SWRUb2tlbkEBAAAAIHtxzCCjiO5MvMQa1Azqp+Y2rXgVKpJSDL3j5MzZkFIFAAAAAA1hc3NldElkVG9rZW5CBQAAAAR1bml0AAAAAAljb21pc3Npb24AAAAAAAAAAAAAAAADAAAACmNvbnRleHRPYmoBAAAABGZ1bmQAAAAABAAAAAdwYXltZW50BAAAAAckbWF0Y2gwCAUAAAAKY29udGV4dE9iagAAAAdwYXltZW50AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9BdHRhY2hlZFBheW1lbnQEAAAAAXAFAAAAByRtYXRjaDAFAAAAAXAJAAACAAAAAQIAAAAUUGF5bWVudCBub3QgYXR0YWNoZWQEAAAAD2Fzc2V0SWRSZWNlaXZlZAgFAAAAB3BheW1lbnQAAAAHYXNzZXRJZAQAAAASdG9rZW5SZWNlaXZlQW1vdW50CAUAAAAHcGF5bWVudAAAAAZhbW91bnQDAwkAAAAAAAACBQAAAA9hc3NldElkUmVjZWl2ZWQFA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WZ5AAAAAAYuHoBr", "chainId": 84, "height": 642328, "spentComplexity": 0 } View: original | compacted Prev: E3vfbtkmN1MFjtjdLJ9G6o5CvjKkw3ZNGepKuZYevCpX Next: B2LgimrneTiKrC1WT4AMSUmwMwu1H85FWJh5PNA5SeLi Diff:
Old | New | Differences | |
---|---|---|---|
23 | 23 | then !(isDefined(getString(this, "fundA"))) | |
24 | 24 | else false) | |
25 | 25 | then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", "funded")]) | |
26 | - | else if ((assetIdReceived == assetIdTokenB)) | |
26 | + | else if (if ((assetIdReceived == assetIdTokenB)) | |
27 | + | then !(isDefined(getString(this, "fundB"))) | |
28 | + | else false) | |
27 | 29 | then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", "funded")]) | |
28 | 30 | else throw("already funded or you try to fund with incorrect asset") | |
29 | 31 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let owner = base58'3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL' | |
5 | 5 | ||
6 | 6 | let assetIdTokenA = base58'9Jsnot7RWQmTsfXtezQN7igoS2q1QF1jsotaxwh8Fxp4' | |
7 | 7 | ||
8 | 8 | let assetIdTokenB = unit | |
9 | 9 | ||
10 | 10 | let comission = 0 | |
11 | 11 | ||
12 | 12 | @Callable(contextObj) | |
13 | 13 | func fund () = { | |
14 | 14 | let payment = match contextObj.payment { | |
15 | 15 | case p: AttachedPayment => | |
16 | 16 | p | |
17 | 17 | case _ => | |
18 | 18 | throw("Payment not attached") | |
19 | 19 | } | |
20 | 20 | let assetIdReceived = payment.assetId | |
21 | 21 | let tokenReceiveAmount = payment.amount | |
22 | 22 | if (if ((assetIdReceived == assetIdTokenA)) | |
23 | 23 | then !(isDefined(getString(this, "fundA"))) | |
24 | 24 | else false) | |
25 | 25 | then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", "funded")]) | |
26 | - | else if ((assetIdReceived == assetIdTokenB)) | |
26 | + | else if (if ((assetIdReceived == assetIdTokenB)) | |
27 | + | then !(isDefined(getString(this, "fundB"))) | |
28 | + | else false) | |
27 | 29 | then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", "funded")]) | |
28 | 30 | else throw("already funded or you try to fund with incorrect asset") | |
29 | 31 | } | |
30 | 32 | ||
31 | 33 | ||
32 | 34 | ||
33 | 35 | @Callable(contextObj) | |
34 | 36 | func exchanger (minTokenRecieve) = if (if ((0 > comission)) | |
35 | 37 | then true | |
36 | 38 | else (comission > 100)) | |
37 | 39 | then throw("incorrect comission value") | |
38 | 40 | else { | |
39 | 41 | let amountTokenB = getIntegerValue(this, "amountTokenB") | |
40 | 42 | let amountTokenA = getIntegerValue(this, "amountTokenA") | |
41 | 43 | let payment = match contextObj.payment { | |
42 | 44 | case p: AttachedPayment => | |
43 | 45 | p | |
44 | 46 | case _ => | |
45 | 47 | throw("Payment not attached") | |
46 | 48 | } | |
47 | 49 | let assetIdReceived = payment.assetId | |
48 | 50 | let tokenReceiveAmount = payment.amount | |
49 | 51 | if ((assetIdReceived == assetIdTokenB)) | |
50 | 52 | then { | |
51 | 53 | let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100) | |
52 | 54 | if ((minTokenRecieve > tokenSendAmount)) | |
53 | 55 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
54 | 56 | else { | |
55 | 57 | let assetIdSent = assetIdTokenA | |
56 | 58 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
57 | 59 | } | |
58 | 60 | } | |
59 | 61 | else if ((assetIdReceived == assetIdTokenA)) | |
60 | 62 | then { | |
61 | 63 | let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100) | |
62 | 64 | if ((minTokenRecieve > tokenSendAmount)) | |
63 | 65 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
64 | 66 | else { | |
65 | 67 | let assetIdSent = assetIdTokenB | |
66 | 68 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
67 | 69 | } | |
68 | 70 | } | |
69 | 71 | else throw("Asset is not allowed") | |
70 | 72 | } | |
71 | 73 | ||
72 | 74 | ||
73 | 75 | ||
74 | 76 | @Callable(contextObj) | |
75 | 77 | func withdraw () = { | |
76 | 78 | let BalanceTokenA = assetBalance(this, assetIdTokenA) | |
77 | 79 | let BalanceTokenB = assetBalance(this, assetIdTokenB) | |
78 | 80 | if ((contextObj.caller.bytes == owner)) | |
79 | 81 | then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)])) | |
80 | 82 | else throw("You are not exchanger's owner") | |
81 | 83 | } | |
82 | 84 | ||
83 | 85 | ||
84 | 86 | @Verifier(contextObj) | |
85 | 87 | func verify () = true | |
86 | 88 |
github/deemru/w8io/026f985 23.53 ms ◑