tx · HuaFuVwHbCHtUDS3m47W62oTZNKsCVEqQVhi6ZWLbMYy 3N4rfXV9DbA9Kbngt5qpNXuziAaBRmCrbHZ: -0.01400000 Waves 2019.08.09 18:19 [623612] smart account 3N4rfXV9DbA9Kbngt5qpNXuziAaBRmCrbHZ > SELF 0.00000000 Waves
{ "type": 13, "id": "HuaFuVwHbCHtUDS3m47W62oTZNKsCVEqQVhi6ZWLbMYy", "fee": 1400000, "feeAssetId": null, "timestamp": 1565363999203, "version": 1, "sender": "3N4rfXV9DbA9Kbngt5qpNXuziAaBRmCrbHZ", "senderPublicKey": "7dgeV8sSzVnj9GqLdFXQktfdiQjrFcWTgDPeQwbs1kyK", "proofs": [ "1M55cM2vUDqbSENbaHut7pQBvsKeYrGHxSM7sAvCgUrc7RVpBnvaRiQzq4aKMTRfB59z8mnkjwyjRuGGyXTjtXg" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FAAAAABFBY2NvdW50QmFsYW5jZUtleQIAAAAIYmFsYW5jZV8AAAAAEE5ldXRyaW5vUHJpY2VLZXkCAAAACm51c2RfcHJpY2UAAAAADEJvbmRDb3VudEtleQIAAAAKYm9uZF9jb3VudAAAAAAMQm9uZFByaWNlS2V5AgAAAApib25kX3ByaWNlAAAAAAxCb25kQmxvY2tLZXkCAAAACmJvbmRfYm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2V0Qm9uZFByaWNlAAAAAAQAAAAJbGFzdENvdW50CQEAAAAMZ2V0Qm9uZENvdW50AAAAAAMJAABnAAAAAgUAAAAJbGFzdFByaWNlBQAAAAVwcmljZQkAAAIAAAABAgAAABJib25kIG5vdCBnZW5lcmF0ZWQJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxCb25kUHJpY2VLZXkFAAAABXByaWNlCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxCb25kT3duZXJLZXkJAAQlAAAAAQgFAAAAAWkAAAAGY2FsbGVyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxCb25kQ291bnRLZXkJAABpAAAAAggFAAAAA3BtdAAAAAZhbW91bnQFAAAABXByaWNlBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABCQEAAAAMZ2V0Qm9uZE93bmVyAAAAAAkAAGgAAAACBQAAAAlsYXN0Q291bnQFAAAACWxhc3RQcmljZQUAAAAPTmV1dHJpbm9Bc3NldElkBQAAAANuaWwAAAAA/Vc9Yg==", "chainId": 84, "height": 623612, "spentComplexity": 0 } View: original | compacted Prev: 7eSqFyCqwwp8T3PfJR1mJjrx15aH1djRov75zabXj8qs Next: none Diff:
Old | New | Differences | |
---|---|---|---|
105 | 105 | func swapNeutrinoToWaves () = { | |
106 | 106 | let price = getNeutrinoPrice() | |
107 | 107 | let pmt = extract(i.payment) | |
108 | - | if ((pmt.assetId | |
108 | + | if ((pmt.assetId != NeutrinoAssetId)) | |
109 | 109 | then throw("can use neutrino only at the moment") | |
110 | 110 | else { | |
111 | 111 | let account = toBase58String(i.caller.bytes) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | func getNumberByKey (key) = match getInteger(this, key) { | |
7 | 7 | case a: Int => | |
8 | 8 | a | |
9 | 9 | case _ => | |
10 | 10 | 0 | |
11 | 11 | } | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func getStrByKey (key) = match getString(this, key) { | |
15 | 15 | case a: String => | |
16 | 16 | a | |
17 | 17 | case _ => | |
18 | 18 | NONE | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | let AccountBalanceKey = "balance_" | |
23 | 23 | ||
24 | 24 | let NeutrinoPriceKey = "nusd_price" | |
25 | 25 | ||
26 | 26 | let BondCountKey = "bond_count" | |
27 | 27 | ||
28 | 28 | let BondPriceKey = "bond_price" | |
29 | 29 | ||
30 | 30 | let BondBlockKey = "bond_block" | |
31 | 31 | ||
32 | 32 | let BondOwnerKey = "bond_owner" | |
33 | 33 | ||
34 | 34 | let BondStatus = "bond_status" | |
35 | 35 | ||
36 | 36 | func getAccountBalanceKey (account) = (AccountBalanceKey + account) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getAccountBalance (account) = getNumberByKey(getAccountBalanceKey(account)) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func getNeutrinoPrice () = getNumberByKey(NeutrinoPriceKey) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getBondCount () = getNumberByKey(BondCountKey) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getBondPrice () = getNumberByKey(BondPriceKey) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getBondStatus () = getNumberByKey(BondPriceKey) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func getBondOrderBlock () = getNumberByKey(BondBlockKey) | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func getBondOwner () = getStrByKey(BondOwnerKey) | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | let Wavelet = 100000000 | |
61 | 61 | ||
62 | 62 | let ExpireBondOrder = 10 | |
63 | 63 | ||
64 | 64 | let ExcecutedStatus = "excecuted" | |
65 | 65 | ||
66 | 66 | let NeutrinoAssetId = base58'4LFQD5CQHi7fpUqNaCyAbaoXPNRuvvdPL6tD7xubtUr4' | |
67 | 67 | ||
68 | 68 | let BondAssetIdString = "4LFQD5CQHi7fpUqNaCyAbaoXPNRuvvdPL6tD7xubtUr4" | |
69 | 69 | ||
70 | 70 | let BondAssetId = toBytes("") | |
71 | 71 | ||
72 | 72 | let NeutrinoName = "Neutrino-USD" | |
73 | 73 | ||
74 | 74 | let NeutrinoSymbol = "N-USD" | |
75 | 75 | ||
76 | 76 | let MinimalBondOrder = (10 * Wavelet) | |
77 | 77 | ||
78 | 78 | func getSupply () = assetBalance(this, NeutrinoAssetId) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func getReserve () = wavesBalance(this) | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | 85 | func setCurrentPrice (price) = WriteSet([DataEntry(NeutrinoPriceKey, price)]) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | ||
89 | 89 | @Callable(i) | |
90 | 90 | func swapWavesToNeutrino () = { | |
91 | 91 | let price = getNeutrinoPrice() | |
92 | 92 | let pmt = extract(i.payment) | |
93 | 93 | if (isDefined(pmt.assetId)) | |
94 | 94 | then throw("can use waves only at the moment") | |
95 | 95 | else { | |
96 | 96 | let account = toBase58String(i.caller.bytes) | |
97 | 97 | let amount = (pmt.amount * price) | |
98 | 98 | TransferSet([ScriptTransfer(addressFromStringValue(account), amount, NeutrinoAssetId)]) | |
99 | 99 | } | |
100 | 100 | } | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | ||
104 | 104 | @Callable(i) | |
105 | 105 | func swapNeutrinoToWaves () = { | |
106 | 106 | let price = getNeutrinoPrice() | |
107 | 107 | let pmt = extract(i.payment) | |
108 | - | if ((pmt.assetId | |
108 | + | if ((pmt.assetId != NeutrinoAssetId)) | |
109 | 109 | then throw("can use neutrino only at the moment") | |
110 | 110 | else { | |
111 | 111 | let account = toBase58String(i.caller.bytes) | |
112 | 112 | let amount = (pmt.amount / price) | |
113 | 113 | TransferSet([ScriptTransfer(addressFromStringValue(account), amount, NeutrinoAssetId)]) | |
114 | 114 | } | |
115 | 115 | } | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | ||
119 | 119 | @Callable(i) | |
120 | 120 | func setBondOrder (price) = { | |
121 | 121 | let priceNeutrino = getNeutrinoPrice() | |
122 | 122 | let reserve = getReserve() | |
123 | 123 | let supply = getSupply() | |
124 | 124 | let deficit = ((supply / priceNeutrino) - reserve) | |
125 | 125 | let pmt = extract(i.payment) | |
126 | 126 | let boudBlock = getBondOrderBlock() | |
127 | 127 | if (isDefined(pmt.assetId)) | |
128 | 128 | then throw("can use waves only at the moment") | |
129 | 129 | else if ((deficit == pmt.amount)) | |
130 | 130 | then throw("amount does not cover deficit") | |
131 | 131 | else if ((boudBlock == 0)) | |
132 | 132 | then if ((MinimalBondOrder > deficit)) | |
133 | 133 | then throw("bond not generated") | |
134 | 134 | else { | |
135 | 135 | let amount = (pmt.amount / price) | |
136 | 136 | ScriptResult(WriteSet([DataEntry(BondBlockKey, height), DataEntry(BondPriceKey, price), DataEntry(BondOwnerKey, toString(i.caller)), DataEntry(BondCountKey, (pmt.amount / price))]), TransferSet([ScriptTransfer(i.caller, amount, NeutrinoAssetId)])) | |
137 | 137 | } | |
138 | 138 | else if (((boudBlock + ExpireBondOrder) > height)) | |
139 | 139 | then throw("TODO") | |
140 | 140 | else { | |
141 | 141 | let lastPrice = getBondPrice() | |
142 | 142 | let lastCount = getBondCount() | |
143 | 143 | if ((lastPrice >= price)) | |
144 | 144 | then throw("bond not generated") | |
145 | 145 | else ScriptResult(WriteSet([DataEntry(BondPriceKey, price), DataEntry(BondOwnerKey, toString(i.caller)), DataEntry(BondCountKey, (pmt.amount / price))]), TransferSet([ScriptTransfer(addressFromStringValue(getBondOwner()), (lastCount * lastPrice), NeutrinoAssetId)])) | |
146 | 146 | } | |
147 | 147 | } | |
148 | 148 | ||
149 | 149 |
github/deemru/w8io/169f3d6 48.60 ms ◑