tx · AVBYZBJMgSBP2c76u6KNriv8mqnSGsQFeE36Jy5qojbq 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF: -0.01400000 Waves 2020.03.11 22:49 [904928] smart account 3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF > SELF 0.00000000 Waves
{ "type": 13, "id": "AVBYZBJMgSBP2c76u6KNriv8mqnSGsQFeE36Jy5qojbq", "fee": 1400000, "feeAssetId": null, "timestamp": 1583956145578, "version": 1, "sender": "3N5jpkcHiH5R36y9cYnoXhVHe4pxRkS3peF", "senderPublicKey": "9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3", "proofs": [ "2XYbR7mFCgRDCea1QXeNEJm1WVkr5ZcQSKLCCZ1oJvcg8A5Gmnd5RnuLXNHLj19qTxhdRYRQCHDhVDX5qfM2gXJ" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASABIDCgEBAAAABQAAAAAGRVVDb2luAQAAACDJofoUphCC2vgdQrn0R0tQm4QOreBLRVolNScltI/WUQAAAAAGVVNDb2luAQAAACCWpimiLpI8FZFaHXIW3ZwI74bEgcPecoAv5ODcRcQ7/QAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIIR0OzhzTJc1ozXjp3CfISpQxO2vbrCrTGSiFABFRe8mAAAAAA1PcmFjbGVBZGRyZXNzCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNOQWNvZVdkVVRXbjhjc1hKUEc0N3YxRmp0amNmcXhiNXR1AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAADU9yYWNsZUFkZHJlc3MFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAAAABAAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0c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AwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA5vd25lclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBgf9DKog", "chainId": 84, "height": 904928, "spentComplexity": 0 } View: original | compacted Prev: GFf3SRaMSzZbgvHeTgWQc3eiTy78WnhDvuzqtRGd5wn6 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | case _ => | |
71 | 71 | 0 | |
72 | 72 | } | |
73 | - | let rate = getNumberByKey("waves_usd_2") | |
74 | 73 | let trasferAmount = (pmt.amount / 100) | |
75 | 74 | let newAmount = (currentAmount - trasferAmount) | |
76 | 75 | if ((0 > pmt.amount)) | |
99 | 98 | 0 | |
100 | 99 | } | |
101 | 100 | let rate = getNumberByKey("waves_usd_2") | |
102 | - | let trasferAmount = pmt.amount | |
103 | - | let newAmount = (currentAmount - trasferAmount) | |
104 | - | if ((0 > pmt.amount)) | |
105 | - | then throw("Can't withdraw negative amount") | |
106 | - | else if ((0 > newAmount)) | |
107 | - | then throw("Not enough Waves Deposited") | |
108 | - | else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, unit)])) | |
101 | + | if ((rate == 0)) | |
102 | + | then throw("rate 0") | |
103 | + | else { | |
104 | + | let trasferAmount = ((pmt.amount / rate) * 100) | |
105 | + | let newAmount = (currentAmount - trasferAmount) | |
106 | + | if ((0 > pmt.amount)) | |
107 | + | then throw("Can't withdraw negative amount") | |
108 | + | else if ((0 > newAmount)) | |
109 | + | then throw("Not enough Waves Deposited") | |
110 | + | else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, unit)])) | |
111 | + | } | |
109 | 112 | } | |
110 | 113 | else throw("You Can Withdraw with EUCoin only") | |
111 | 114 | else throw("You Can Withdraw with EUCoin only") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let EUCoin = base58'Ea6CdDfumo8ZFecxUSWKAjZpQXmkRC79WB4ktu3KffPn' | |
5 | 5 | ||
6 | 6 | let USCoin = base58'B957NA5BEM8quCDhe1fUPkqBSdCZdJunNxjGE8FRJkWx' | |
7 | 7 | ||
8 | 8 | let ownerPublicKey = base58'9v3cUhWaBqFKLuHQTbz2osNsxRANDcpaRZja43mFNkR3' | |
9 | 9 | ||
10 | 10 | let OracleAddress = addressFromStringValue("3NAcoeWdUTWn8csXJPG47v1Fjtjcfqxb5tu") | |
11 | 11 | ||
12 | 12 | func getNumberByKey (key) = match getInteger(OracleAddress, key) { | |
13 | 13 | case a: Int => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | 0 | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | @Callable(i) | |
21 | 21 | func deposit () = { | |
22 | 22 | let pmt = extract(i.payment) | |
23 | 23 | if (isDefined(pmt.assetId)) | |
24 | 24 | then if ((pmt.assetId == USCoin)) | |
25 | 25 | then { | |
26 | 26 | let currentKey = toBase58String(i.caller.bytes) | |
27 | 27 | let currentAmount = match getInteger(this, (currentKey + "_uscoin")) { | |
28 | 28 | case a: Int => | |
29 | 29 | a | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | let rate = getNumberByKey("waves_usd_2") | |
34 | 34 | let trasferAmount = (pmt.amount * 100) | |
35 | 35 | let newAmount = (currentAmount + pmt.amount) | |
36 | 36 | ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)])) | |
37 | 37 | } | |
38 | 38 | else throw("can hodl USCoin only at the moment") | |
39 | 39 | else { | |
40 | 40 | let currentKey = toBase58String(i.caller.bytes) | |
41 | 41 | let currentAmount = match getInteger(this, (currentKey + "_waves")) { | |
42 | 42 | case a: Int => | |
43 | 43 | a | |
44 | 44 | case _ => | |
45 | 45 | 0 | |
46 | 46 | } | |
47 | 47 | let rate = getNumberByKey("waves_usd_2") | |
48 | 48 | if ((rate == 0)) | |
49 | 49 | then throw("rate 0") | |
50 | 50 | else { | |
51 | 51 | let trasferAmount = ((pmt.amount * rate) / 100) | |
52 | 52 | let newAmount = (currentAmount + pmt.amount) | |
53 | 53 | ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, EUCoin)])) | |
54 | 54 | } | |
55 | 55 | } | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | 60 | @Callable(i) | |
61 | 61 | func withdrawUSCoin () = { | |
62 | 62 | let pmt = extract(i.payment) | |
63 | 63 | if (isDefined(pmt.assetId)) | |
64 | 64 | then if ((pmt.assetId == EUCoin)) | |
65 | 65 | then { | |
66 | 66 | let currentKey = toBase58String(i.caller.bytes) | |
67 | 67 | let currentAmount = match getInteger(this, (currentKey + "_uscoin")) { | |
68 | 68 | case a: Int => | |
69 | 69 | a | |
70 | 70 | case _ => | |
71 | 71 | 0 | |
72 | 72 | } | |
73 | - | let rate = getNumberByKey("waves_usd_2") | |
74 | 73 | let trasferAmount = (pmt.amount / 100) | |
75 | 74 | let newAmount = (currentAmount - trasferAmount) | |
76 | 75 | if ((0 > pmt.amount)) | |
77 | 76 | then throw("Can't withdraw negative amount") | |
78 | 77 | else if ((0 > newAmount)) | |
79 | 78 | then throw("Not enough USCoin Deposited") | |
80 | 79 | else ScriptResult(WriteSet([DataEntry((currentKey + "_uscoin"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, USCoin)])) | |
81 | 80 | } | |
82 | 81 | else throw("You Can Withdraw with EUCoin only") | |
83 | 82 | else throw("You Can Withdraw with EUCoin only") | |
84 | 83 | } | |
85 | 84 | ||
86 | 85 | ||
87 | 86 | ||
88 | 87 | @Callable(i) | |
89 | 88 | func withdrawWaves () = { | |
90 | 89 | let pmt = extract(i.payment) | |
91 | 90 | if (isDefined(pmt.assetId)) | |
92 | 91 | then if ((pmt.assetId == EUCoin)) | |
93 | 92 | then { | |
94 | 93 | let currentKey = toBase58String(i.caller.bytes) | |
95 | 94 | let currentAmount = match getInteger(this, (currentKey + "_waves")) { | |
96 | 95 | case a: Int => | |
97 | 96 | a | |
98 | 97 | case _ => | |
99 | 98 | 0 | |
100 | 99 | } | |
101 | 100 | let rate = getNumberByKey("waves_usd_2") | |
102 | - | let trasferAmount = pmt.amount | |
103 | - | let newAmount = (currentAmount - trasferAmount) | |
104 | - | if ((0 > pmt.amount)) | |
105 | - | then throw("Can't withdraw negative amount") | |
106 | - | else if ((0 > newAmount)) | |
107 | - | then throw("Not enough Waves Deposited") | |
108 | - | else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, unit)])) | |
101 | + | if ((rate == 0)) | |
102 | + | then throw("rate 0") | |
103 | + | else { | |
104 | + | let trasferAmount = ((pmt.amount / rate) * 100) | |
105 | + | let newAmount = (currentAmount - trasferAmount) | |
106 | + | if ((0 > pmt.amount)) | |
107 | + | then throw("Can't withdraw negative amount") | |
108 | + | else if ((0 > newAmount)) | |
109 | + | then throw("Not enough Waves Deposited") | |
110 | + | else ScriptResult(WriteSet([DataEntry((currentKey + "_waves"), newAmount)]), TransferSet([ScriptTransfer(i.caller, trasferAmount, unit)])) | |
111 | + | } | |
109 | 112 | } | |
110 | 113 | else throw("You Can Withdraw with EUCoin only") | |
111 | 114 | else throw("You Can Withdraw with EUCoin only") | |
112 | 115 | } | |
113 | 116 | ||
114 | 117 | ||
115 | 118 | ||
116 | 119 | @Callable(i) | |
117 | 120 | func getFaucet (amount) = { | |
118 | 121 | let currentKey = toBase58String(i.caller.bytes) | |
119 | 122 | let currentAmount = match getInteger(this, (currentKey + "_faucet")) { | |
120 | 123 | case a: Int => | |
121 | 124 | a | |
122 | 125 | case _ => | |
123 | 126 | 0 | |
124 | 127 | } | |
125 | 128 | if ((0 > amount)) | |
126 | 129 | then throw("Can't withdraw negative amount") | |
127 | 130 | else if ((currentAmount > 0)) | |
128 | 131 | then throw("Faucet already taken") | |
129 | 132 | else ScriptResult(WriteSet([DataEntry((currentKey + "_faucet"), amount)]), TransferSet([ScriptTransfer(i.caller, amount, EUCoin)])) | |
130 | 133 | } | |
131 | 134 | ||
132 | 135 | ||
133 | 136 | @Verifier(tx) | |
134 | 137 | func verify () = match tx { | |
135 | 138 | case d: SetScriptTransaction => | |
136 | 139 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
137 | 140 | case d: DataTransaction => | |
138 | 141 | true | |
139 | 142 | case _ => | |
140 | 143 | false | |
141 | 144 | } | |
142 | 145 |
github/deemru/w8io/169f3d6 25.14 ms ◑