tx · GoBArkMb2LyJtg7yG2J8htn46Q6jeptMXPEQ5GPhrfLi 3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X: -0.04000000 Waves 2021.05.17 15:17 [1529659] smart account 3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X > SELF 0.00000000 Waves
{ "type": 13, "id": "GoBArkMb2LyJtg7yG2J8htn46Q6jeptMXPEQ5GPhrfLi", "fee": 4000000, "feeAssetId": null, "timestamp": 1621253842149, "version": 2, "chainId": 84, "sender": "3N88HLHyQgayARc6MXuoJgYJM6Hp9q8AD4X", "senderPublicKey": "7d8ot6oQCGQZb8ATJ6U8KciEiWMyGupkrdYRjcoRfNzs", "proofs": [ "67VPXgjRazYyK2GxxMw5pScRsHQwRmTDnL5G1wXfuJiNkmHdNnd7SHnjrDtr2aii6LjQzTvkwoehzfpPYXjnXXYG", "5pwM7zvZAHvTTKhp37JRq1BP2FAnkRDokMDdV5oYmiqY54rrw8CDjC9md8YEGQR6YzoXvbBea7wuueE5FWnJCqKB" ], "script": "base64:AAIEAAAAAAAAACAIAhIECgIBCBIECgIBCBIECgIBCBIECgIBCBIECgIBCAAAAAMBAAAAEGdldERlcG9zaXRBbW91bnQAAAACAAAACXB1YmxpY0tleQAAAAVhc3NldAMJAAAAAAAAAgUAAAAFYXNzZXQCAAAAAAQAAAAHYmFsYW5jZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgIAAAAIZGVwb3NpdF8FAAAACXB1YmxpY0tleQIAAAAGX1dBVkVTAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAB2JhbGFuY2UEAAAAB2JhbGFuY2UEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAIZGVwb3NpdF8FAAAACXB1YmxpY0tleQIAAAABXw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VudAAAAAVhc3NldAQAAAAJcHVibGljS2V5CQACWAAAAAEIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQQAAAAKY3VycmVudERlcAkBAAAAEGdldERlcG9zaXRBbW91bnQAAAACBQAAAAlwdWJsaWNLZXkFAAAABWFzc2V0AwkAAGYAAAACBQAAAApjdXJyZW50RGVwAAAAAAAAAAAACQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAhkZXBvc2l0XwUAAAAJcHVibGljS2V5AgAAAAFfBQAAAAVhc3NldAkAAGUAAAACBQAAAApjdXJyZW50RGVwBQAAAAZhbW91bnQFAAAAA25pbAkAAAIAAAABAgAAABNOb3RoaW5nIHRvIHdpdGhkcmF3AAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBgZFIp3X", "height": 1529659, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FwmruPTPKcouQSgY1iKbefQphmcAYAzgCKXpeXoSV4Uj Next: CuzvUZ2bjQsCPr74YAzfdZav9BfoS27wrpUKKwjeEeDt Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getDepositAmount (publicKey,asset) = { | |
5 | - | let balance = match getInteger(this, (("deposit_" + publicKey) + "_WAVES")) { | |
6 | - | case a: Int => | |
7 | - | a | |
8 | - | case _ => | |
9 | - | 0 | |
10 | - | } | |
11 | - | balance | |
12 | - | } | |
4 | + | func getDepositAmount (publicKey,asset) = if ((asset == "")) | |
5 | + | then { | |
6 | + | let balance = match getInteger(this, (("deposit_" + publicKey) + "_WAVES")) { | |
7 | + | case a: Int => | |
8 | + | a | |
9 | + | case _ => | |
10 | + | 0 | |
11 | + | } | |
12 | + | balance | |
13 | + | } | |
14 | + | else { | |
15 | + | let balance = match getInteger(this, ((("deposit_" + publicKey) + "_") + asset)) { | |
16 | + | case a: Int => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | 0 | |
20 | + | } | |
21 | + | balance | |
22 | + | } | |
13 | 23 | ||
14 | 24 | ||
15 | 25 | func getBorrowAmount (publicKey,asset) = { | |
23 | 33 | } | |
24 | 34 | ||
25 | 35 | ||
26 | - | func getCollateral (publicKey,asset) = { | |
27 | - | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_") + asset)) { | |
28 | - | case a: Int => | |
29 | - | a | |
30 | - | case _ => | |
31 | - | 0 | |
32 | - | } | |
33 | - | collateral | |
34 | - | } | |
36 | + | func getCollateral (publicKey,asset) = if ((asset == "")) | |
37 | + | then { | |
38 | + | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_Waves") + asset)) { | |
39 | + | case a: Int => | |
40 | + | a | |
41 | + | case _ => | |
42 | + | 0 | |
43 | + | } | |
44 | + | collateral | |
45 | + | } | |
46 | + | else { | |
47 | + | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_") + asset)) { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | 0 | |
52 | + | } | |
53 | + | collateral | |
54 | + | } | |
35 | 55 | ||
36 | 56 | ||
37 | 57 | @Callable(i) | |
38 | 58 | func deposit (amount,asset) = { | |
39 | 59 | let publicKey = toBase58String(i.callerPublicKey) | |
40 | - | let depositAmount = getDepositAmount(publicKey, asset) | |
60 | + | let test = if ((asset == "")) | |
61 | + | then "WAVES" | |
62 | + | else asset | |
63 | + | let depositAmount = getDepositAmount(publicKey, test) | |
41 | 64 | let newDepositAmount = (depositAmount + amount) | |
42 | - | if ((asset == "")) | |
43 | - | then [IntegerEntry((("deposit_" + publicKey) + "_WAVES"), newDepositAmount)] | |
44 | - | else [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
65 | + | [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
45 | 66 | } | |
46 | 67 | ||
47 | 68 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getDepositAmount (publicKey,asset) = { | |
5 | - | let balance = match getInteger(this, (("deposit_" + publicKey) + "_WAVES")) { | |
6 | - | case a: Int => | |
7 | - | a | |
8 | - | case _ => | |
9 | - | 0 | |
10 | - | } | |
11 | - | balance | |
12 | - | } | |
4 | + | func getDepositAmount (publicKey,asset) = if ((asset == "")) | |
5 | + | then { | |
6 | + | let balance = match getInteger(this, (("deposit_" + publicKey) + "_WAVES")) { | |
7 | + | case a: Int => | |
8 | + | a | |
9 | + | case _ => | |
10 | + | 0 | |
11 | + | } | |
12 | + | balance | |
13 | + | } | |
14 | + | else { | |
15 | + | let balance = match getInteger(this, ((("deposit_" + publicKey) + "_") + asset)) { | |
16 | + | case a: Int => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | 0 | |
20 | + | } | |
21 | + | balance | |
22 | + | } | |
13 | 23 | ||
14 | 24 | ||
15 | 25 | func getBorrowAmount (publicKey,asset) = { | |
16 | 26 | let balance = match getInteger(this, ((("borrow_" + publicKey) + "_") + asset)) { | |
17 | 27 | case a: Int => | |
18 | 28 | a | |
19 | 29 | case _ => | |
20 | 30 | 0 | |
21 | 31 | } | |
22 | 32 | balance | |
23 | 33 | } | |
24 | 34 | ||
25 | 35 | ||
26 | - | func getCollateral (publicKey,asset) = { | |
27 | - | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_") + asset)) { | |
28 | - | case a: Int => | |
29 | - | a | |
30 | - | case _ => | |
31 | - | 0 | |
32 | - | } | |
33 | - | collateral | |
34 | - | } | |
36 | + | func getCollateral (publicKey,asset) = if ((asset == "")) | |
37 | + | then { | |
38 | + | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_Waves") + asset)) { | |
39 | + | case a: Int => | |
40 | + | a | |
41 | + | case _ => | |
42 | + | 0 | |
43 | + | } | |
44 | + | collateral | |
45 | + | } | |
46 | + | else { | |
47 | + | let collateral = match getInteger(this, ((("collateral_" + publicKey) + "_") + asset)) { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | 0 | |
52 | + | } | |
53 | + | collateral | |
54 | + | } | |
35 | 55 | ||
36 | 56 | ||
37 | 57 | @Callable(i) | |
38 | 58 | func deposit (amount,asset) = { | |
39 | 59 | let publicKey = toBase58String(i.callerPublicKey) | |
40 | - | let depositAmount = getDepositAmount(publicKey, asset) | |
60 | + | let test = if ((asset == "")) | |
61 | + | then "WAVES" | |
62 | + | else asset | |
63 | + | let depositAmount = getDepositAmount(publicKey, test) | |
41 | 64 | let newDepositAmount = (depositAmount + amount) | |
42 | - | if ((asset == "")) | |
43 | - | then [IntegerEntry((("deposit_" + publicKey) + "_WAVES"), newDepositAmount)] | |
44 | - | else [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
65 | + | [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), newDepositAmount)] | |
45 | 66 | } | |
46 | 67 | ||
47 | 68 | ||
48 | 69 | ||
49 | 70 | @Callable(i) | |
50 | 71 | func depositCollateral (amount,asset) = { | |
51 | 72 | let publicKey = toBase58String(i.callerPublicKey) | |
52 | 73 | let collateralAmount = getCollateral(publicKey, asset) | |
53 | 74 | let newCollateralAmount = (collateralAmount + amount) | |
54 | 75 | [IntegerEntry(((("collateral_" + publicKey) + "_") + asset), newCollateralAmount)] | |
55 | 76 | } | |
56 | 77 | ||
57 | 78 | ||
58 | 79 | ||
59 | 80 | @Callable(i) | |
60 | 81 | func borrow (amount,asset) = { | |
61 | 82 | let publicKey = toBase58String(i.callerPublicKey) | |
62 | 83 | let borrowAmount = getBorrowAmount(publicKey, asset) | |
63 | 84 | let collateral = getCollateral(publicKey, asset) | |
64 | 85 | let maxBorrowAmount = ((collateral * 70) / 100) | |
65 | 86 | let newBorrowAmount = (borrowAmount + amount) | |
66 | 87 | if ((collateral >= maxBorrowAmount)) | |
67 | 88 | then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), newBorrowAmount)] | |
68 | 89 | else throw("Not enough collateral") | |
69 | 90 | } | |
70 | 91 | ||
71 | 92 | ||
72 | 93 | ||
73 | 94 | @Callable(i) | |
74 | 95 | func repay (amount,asset) = { | |
75 | 96 | let publicKey = toBase58String(i.callerPublicKey) | |
76 | 97 | let currentBorr = getBorrowAmount(publicKey, asset) | |
77 | 98 | if ((currentBorr > 0)) | |
78 | 99 | then [IntegerEntry(((("borrow_" + publicKey) + "_") + asset), (currentBorr - amount))] | |
79 | 100 | else throw("Nothing to repay") | |
80 | 101 | } | |
81 | 102 | ||
82 | 103 | ||
83 | 104 | ||
84 | 105 | @Callable(i) | |
85 | 106 | func withdraw (amount,asset) = { | |
86 | 107 | let publicKey = toBase58String(i.callerPublicKey) | |
87 | 108 | let currentDep = getDepositAmount(publicKey, asset) | |
88 | 109 | if ((currentDep > 0)) | |
89 | 110 | then [IntegerEntry(((("deposit_" + publicKey) + "_") + asset), (currentDep - amount))] | |
90 | 111 | else throw("Nothing to withdraw") | |
91 | 112 | } | |
92 | 113 | ||
93 | 114 | ||
94 | 115 | @Verifier(tx) | |
95 | 116 | func verify () = match tx { | |
96 | 117 | case _: DataTransaction => | |
97 | 118 | true | |
98 | 119 | case _: SetScriptTransaction => | |
99 | 120 | true | |
100 | 121 | case _ => | |
101 | 122 | true | |
102 | 123 | } | |
103 | 124 |
github/deemru/w8io/169f3d6 35.98 ms ◑