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+WoKyIZBusJtmAL21uv12gVr6mwDScyUynLxKWLAAAAABNkQXBwTWluQW1vdW50VG9MZW5kAAAAAAAAAAH0AAAAABVkQXBwTWluQW1vdW50VG9Cb3Jyb3cAAAAAAAAAAGQAAAAAFGRBcHBNaW5Cb3Jyb3dGZWVQZXJjAAAAAAAAAAAKAQAAABNnZXRMZW5kaW5nUG9vbFN0YWNrAAAAAAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzAgAAABBsZW5kaW5nUG9vbFN0YWNrAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAAD2dldEZlZVBvb2xTdGFjawAAAAAEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwIAAAAMZmVlUG9vbFN0YWNrAwkAAAEAAAACBQAAAAckbWF0Y2gwAgA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XJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tlecm3WVg=", "height": 1434367, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Fd53wDKu1Jsw8usMsK9pxtktSdzgHcAYUxq7PGnFKSjD Next: Az4WNCxRGVEcEAzp8X1pbMroYSRd1BKkTDLKS1N71Z6C Diff:
OldNewDifferences
5858 else if ((requestBorrowAmount > assetBalance(this, dAppAssetId)))
5959 then throw("Not enough liquidity available")
6060 else {
61- let minToReceiveFromBorrower = (requestBorrowAmount * ((dAppMinBorrowFeePerc / 100) + 1))
61+ let minToReceiveFromBorrower = (requestBorrowAmount + ((requestBorrowAmount * dAppMinBorrowFeePerc) / 100))
6262 if ((minToReceiveFromBorrower > i.payments[0].amount))
63- then throw((("Insuffisent collateral (must be " + toString(((dAppMinBorrowFeePerc / 100) + 1))) + "% higher than the request)"))
63+ then throw((("Insuffisent collateral (must be " + toString(minToReceiveFromBorrower)) + "% higher than the request)"))
6464 else {
6565 let amountToDispatchInFeePool = (i.payments[0].amount - requestBorrowAmount)
6666 let newLendingPoolStack = (getLendingPoolStack() + requestBorrowAmount)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let dAppAssetName = "test1"
55
66 let dAppAssetId = base58'CyRPSWqSzLmynv4W4REGjqhEefZVg2ZobVbvTLi71UzN'
77
88 let dAppMinAmountToLend = 500
99
1010 let dAppMinAmountToBorrow = 100
1111
1212 let dAppMinBorrowFeePerc = 10
1313
1414 func getLendingPoolStack () = match getInteger(this, "lendingPoolStack") {
1515 case a: Int =>
1616 a
1717 case _ =>
1818 0
1919 }
2020
2121
2222 func getFeePoolStack () = match getInteger(this, "feePoolStack") {
2323 case a: Int =>
2424 a
2525 case _ =>
2626 0
2727 }
2828
2929
3030 @Callable(i)
3131 func addToLendingPool () = if ((size(i.payments) != 1))
3232 then throw("No payment attached")
3333 else if ((i.payments[0].assetId != dAppAssetId))
3434 then throw((("Wrong asset sent (must send '" + dAppAssetName) + "')"))
3535 else if ((dAppMinAmountToLend > i.payments[0].amount))
3636 then throw((((("Insuffisent liquidity (minimum: " + toString(dAppMinAmountToLend)) + " ") + dAppAssetName) + ")"))
3737 else if ((this == i.caller))
3838 then throw("dApp self sending is denied")
3939 else {
4040 let contractData = ((((toString(height) + "_") + toBase58String(dAppAssetId)) + "_") + toString(i.payments[0].amount))
4141 let newLendingPoolStack = (getLendingPoolStack() + i.payments[0].amount)
4242 let issueContract = Issue(("ContractL_" + dAppAssetName), contractData, 1, 0, false)
4343 let issueContractId = calculateAssetId(issueContract)
4444 [IntegerEntry("lendingPoolStack", newLendingPoolStack), issueContract, ScriptTransfer(i.caller, issueContract.quantity, issueContractId)]
4545 }
4646
4747
4848
4949 @Callable(i)
5050 func borrow (requestBorrowAmount) = if ((size(i.payments) != 1))
5151 then throw("No payment attached")
5252 else if ((i.payments[0].assetId != dAppAssetId))
5353 then throw((("Wrong asset sent (must send '" + dAppAssetName) + "')"))
5454 else if ((this == i.caller))
5555 then throw("dApp self sending is denied")
5656 else if ((dAppMinAmountToBorrow > requestBorrowAmount))
5757 then throw(((("Minimum amount to borrow is " + toString(dAppMinAmountToBorrow)) + " ") + dAppAssetName))
5858 else if ((requestBorrowAmount > assetBalance(this, dAppAssetId)))
5959 then throw("Not enough liquidity available")
6060 else {
61- let minToReceiveFromBorrower = (requestBorrowAmount * ((dAppMinBorrowFeePerc / 100) + 1))
61+ let minToReceiveFromBorrower = (requestBorrowAmount + ((requestBorrowAmount * dAppMinBorrowFeePerc) / 100))
6262 if ((minToReceiveFromBorrower > i.payments[0].amount))
63- then throw((("Insuffisent collateral (must be " + toString(((dAppMinBorrowFeePerc / 100) + 1))) + "% higher than the request)"))
63+ then throw((("Insuffisent collateral (must be " + toString(minToReceiveFromBorrower)) + "% higher than the request)"))
6464 else {
6565 let amountToDispatchInFeePool = (i.payments[0].amount - requestBorrowAmount)
6666 let newLendingPoolStack = (getLendingPoolStack() + requestBorrowAmount)
6767 let newFeePoolStack = (getFeePoolStack() + amountToDispatchInFeePool)
6868 let contractData = ((((((toString(height) + "_") + toBase58String(dAppAssetId)) + "_") + toString(requestBorrowAmount)) + "_") + toString(amountToDispatchInFeePool))
6969 let issueContract = Issue(("ContractB_" + dAppAssetName), contractData, 1, 0, false)
7070 let issueContractId = calculateAssetId(issueContract)
7171 [IntegerEntry("lendingPoolStack", newLendingPoolStack), IntegerEntry("feePoolStack", newFeePoolStack), issueContract, ScriptTransfer(i.caller, issueContract.quantity, issueContractId), ScriptTransfer(i.caller, requestBorrowAmount, dAppAssetId)]
7272 }
7373 }
7474
7575
7676 @Verifier(tx)
7777 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
7878

github/deemru/w8io/026f985 
34.86 ms