tx · 13dSrx6iSpxQjaa9ownZP6Nb8rECNHAABVvpLs866Dkx 3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua: -0.01400000 Waves 2021.03.12 13:44 [1434367] smart account 3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua > SELF 0.00000000 Waves
{ "type": 13, "id": "13dSrx6iSpxQjaa9ownZP6Nb8rECNHAABVvpLs866Dkx", "fee": 1400000, "feeAssetId": null, "timestamp": 1615545914583, "version": 2, "chainId": 84, "sender": "3Mz29fiz3zgY9JDbiHKANvHsFgQutdfu4Ua", "senderPublicKey": "CTyHhnVTxf16Z4CmGGneAK8WB5g2QyT4MB8kUn8vPPcu", "proofs": [ "43gxfQ9MEJUTNVLhei24Vgwfqb9ag6G9SVcZFVMcJcmJi5rARwbNmH3jJrEN8cjxP7BRgDq1uWfnnVFJXG3wkcj5" ], "script": "base64:AAIEAAAAAAAAAAkIAhIAEgMKAQEAAAAHAAAAAA1kQXBwQXNzZXROYW1lAgAAAAV0ZXN0MQAAAAALZEFwcEFzc2V0SWQBAAAAILHkp+WoKyIZBusJtmAL21uv12gVr6mwDScyUynLxKWLAAAAABNkQXBwTWluQW1vdW50VG9MZW5kAAAAAAAAAAH0AAAAABVkQXBwTWluQW1vdW50VG9Cb3Jyb3cAAAAAAAAAAGQAAAAAFGRBcHBNaW5Cb3Jyb3dGZWVQZXJjAAAAAAAAAAAKAQAAABNnZXRMZW5kaW5nUG9vbFN0YWNrAAAAAAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzAgAAABBsZW5kaW5nUG9vbFN0YWNrAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAAD2dldEZlZVBvb2xTdGFjawAAAAAEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwIAAAAMZmVlUG9vbFN0YWNrAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAA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JpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tlecm3WVg=", "height": 1434367, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Fd53wDKu1Jsw8usMsK9pxtktSdzgHcAYUxq7PGnFKSjD Next: Az4WNCxRGVEcEAzp8X1pbMroYSRd1BKkTDLKS1N71Z6C Diff:
Old | New | Differences | |
---|---|---|---|
58 | 58 | else if ((requestBorrowAmount > assetBalance(this, dAppAssetId))) | |
59 | 59 | then throw("Not enough liquidity available") | |
60 | 60 | else { | |
61 | - | let minToReceiveFromBorrower = (requestBorrowAmount | |
61 | + | let minToReceiveFromBorrower = (requestBorrowAmount + ((requestBorrowAmount * dAppMinBorrowFeePerc) / 100)) | |
62 | 62 | if ((minToReceiveFromBorrower > i.payments[0].amount)) | |
63 | - | then throw((("Insuffisent collateral (must be " + toString( | |
63 | + | then throw((("Insuffisent collateral (must be " + toString(minToReceiveFromBorrower)) + "% higher than the request)")) | |
64 | 64 | else { | |
65 | 65 | let amountToDispatchInFeePool = (i.payments[0].amount - requestBorrowAmount) | |
66 | 66 | let newLendingPoolStack = (getLendingPoolStack() + requestBorrowAmount) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let dAppAssetName = "test1" | |
5 | 5 | ||
6 | 6 | let dAppAssetId = base58'CyRPSWqSzLmynv4W4REGjqhEefZVg2ZobVbvTLi71UzN' | |
7 | 7 | ||
8 | 8 | let dAppMinAmountToLend = 500 | |
9 | 9 | ||
10 | 10 | let dAppMinAmountToBorrow = 100 | |
11 | 11 | ||
12 | 12 | let dAppMinBorrowFeePerc = 10 | |
13 | 13 | ||
14 | 14 | func getLendingPoolStack () = match getInteger(this, "lendingPoolStack") { | |
15 | 15 | case a: Int => | |
16 | 16 | a | |
17 | 17 | case _ => | |
18 | 18 | 0 | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func getFeePoolStack () = match getInteger(this, "feePoolStack") { | |
23 | 23 | case a: Int => | |
24 | 24 | a | |
25 | 25 | case _ => | |
26 | 26 | 0 | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | @Callable(i) | |
31 | 31 | func addToLendingPool () = if ((size(i.payments) != 1)) | |
32 | 32 | then throw("No payment attached") | |
33 | 33 | else if ((i.payments[0].assetId != dAppAssetId)) | |
34 | 34 | then throw((("Wrong asset sent (must send '" + dAppAssetName) + "')")) | |
35 | 35 | else if ((dAppMinAmountToLend > i.payments[0].amount)) | |
36 | 36 | then throw((((("Insuffisent liquidity (minimum: " + toString(dAppMinAmountToLend)) + " ") + dAppAssetName) + ")")) | |
37 | 37 | else if ((this == i.caller)) | |
38 | 38 | then throw("dApp self sending is denied") | |
39 | 39 | else { | |
40 | 40 | let contractData = ((((toString(height) + "_") + toBase58String(dAppAssetId)) + "_") + toString(i.payments[0].amount)) | |
41 | 41 | let newLendingPoolStack = (getLendingPoolStack() + i.payments[0].amount) | |
42 | 42 | let issueContract = Issue(("ContractL_" + dAppAssetName), contractData, 1, 0, false) | |
43 | 43 | let issueContractId = calculateAssetId(issueContract) | |
44 | 44 | [IntegerEntry("lendingPoolStack", newLendingPoolStack), issueContract, ScriptTransfer(i.caller, issueContract.quantity, issueContractId)] | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | ||
49 | 49 | @Callable(i) | |
50 | 50 | func borrow (requestBorrowAmount) = if ((size(i.payments) != 1)) | |
51 | 51 | then throw("No payment attached") | |
52 | 52 | else if ((i.payments[0].assetId != dAppAssetId)) | |
53 | 53 | then throw((("Wrong asset sent (must send '" + dAppAssetName) + "')")) | |
54 | 54 | else if ((this == i.caller)) | |
55 | 55 | then throw("dApp self sending is denied") | |
56 | 56 | else if ((dAppMinAmountToBorrow > requestBorrowAmount)) | |
57 | 57 | then throw(((("Minimum amount to borrow is " + toString(dAppMinAmountToBorrow)) + " ") + dAppAssetName)) | |
58 | 58 | else if ((requestBorrowAmount > assetBalance(this, dAppAssetId))) | |
59 | 59 | then throw("Not enough liquidity available") | |
60 | 60 | else { | |
61 | - | let minToReceiveFromBorrower = (requestBorrowAmount | |
61 | + | let minToReceiveFromBorrower = (requestBorrowAmount + ((requestBorrowAmount * dAppMinBorrowFeePerc) / 100)) | |
62 | 62 | if ((minToReceiveFromBorrower > i.payments[0].amount)) | |
63 | - | then throw((("Insuffisent collateral (must be " + toString( | |
63 | + | then throw((("Insuffisent collateral (must be " + toString(minToReceiveFromBorrower)) + "% higher than the request)")) | |
64 | 64 | else { | |
65 | 65 | let amountToDispatchInFeePool = (i.payments[0].amount - requestBorrowAmount) | |
66 | 66 | let newLendingPoolStack = (getLendingPoolStack() + requestBorrowAmount) | |
67 | 67 | let newFeePoolStack = (getFeePoolStack() + amountToDispatchInFeePool) | |
68 | 68 | let contractData = ((((((toString(height) + "_") + toBase58String(dAppAssetId)) + "_") + toString(requestBorrowAmount)) + "_") + toString(amountToDispatchInFeePool)) | |
69 | 69 | let issueContract = Issue(("ContractB_" + dAppAssetName), contractData, 1, 0, false) | |
70 | 70 | let issueContractId = calculateAssetId(issueContract) | |
71 | 71 | [IntegerEntry("lendingPoolStack", newLendingPoolStack), IntegerEntry("feePoolStack", newFeePoolStack), issueContract, ScriptTransfer(i.caller, issueContract.quantity, issueContractId), ScriptTransfer(i.caller, requestBorrowAmount, dAppAssetId)] | |
72 | 72 | } | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | @Verifier(tx) | |
77 | 77 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
78 | 78 |
github/deemru/w8io/026f985 34.86 ms ◑