tx · GDCV9izPX1v5AkRUCBmMpYN7L1mW6qmAMhFJ7eNA5pSp

3NCCpaecUeQcHCJGnv1ZocqT3xAz2wiXFwe:  -0.05000000 Waves

2022.05.11 12:17 [2046808] smart account 3NCCpaecUeQcHCJGnv1ZocqT3xAz2wiXFwe > SELF 0.00000000 Waves

{ "type": 13, "id": "GDCV9izPX1v5AkRUCBmMpYN7L1mW6qmAMhFJ7eNA5pSp", "fee": 5000000, "feeAssetId": null, "timestamp": 1652260734371, "version": 2, "chainId": 84, "sender": "3NCCpaecUeQcHCJGnv1ZocqT3xAz2wiXFwe", "senderPublicKey": "FX5ZmtqMuiefGRPoKkAcBUEDvaHBS4FSzt8VW49mzcjM", "proofs": [ "2Upf3B9A7muQvLUaFyWYyCMMBKT3Qbm6XSQgCzjvKksorhr3aL1dpAr4m2nYA9xJEu36jtu17YY472sEYsfm7Ksx" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAAAwAAAAACSUQBAAAAIP8QR3aaHO4gAEH6GV3RAr44yVLBwb023LSVkrkR45liAAAAAAJMUAEAAAAgf1BDCThONgyo3aXVGaZPHbvUVh7DJtZBDkYdxqjt6R0AAAAACWlzU3RvcHBlZAcAAAABAAAAAWkBAAAABXN0YWtlAAAAAAQAAAADcG10CQEAAAAFdmFsdWUAAAABCQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAABAAAAAlwbXRBbW91bnQIBQAAAANwbXQAAAAGYW1vdW50BAAAAAlrZXlTdGFrZWQCAAAACVNUQUtFRF9MUAMJAQAAAAIhPQAAAAIIBQAAAANwbXQAAAAHYXNzZXRJZAUAAAACSUQJAAACAAAAAQIAAAAbYXR0YWNoIHRlc3ROU0JUIHRva2VucyBvbmx5AwUAAAAJaXNTdG9wcGVkCQAAAgAAAAECAAAAGXNtYXJ0IGNvbnRyYWN0IGlzIG9uIGxvY2sEAAAACmluVHJlYXN1cnkJAAPwAAAAAgUAAAAEdGhpcwUAAAACSUQEAAAAC3RvdGFsSXNzdWVkBAAAAAckbWF0Y2gwCQAD7AAAAAEFAAAAAkxQAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAVBc3NldAQAAAAFYXNzZXQFAAAAByRtYXRjaDAIBQAAAAVhc3NldAAAAAhxdWFudGl0eQkAAAIAAAABAgAAABBDYW4ndCBmaW5kIGFzc2V0BAAAAAh0cmVhc3VyeQkAAGUAAAACBQAAAAppblRyZWFzdXJ5BQAAAAlwbXRBbW91bnQEAAAAD3NpbmdsZUxQaW5WYWx1ZQkAAGsAAAADBQAAAAt0b3RhbElzc3VlZAAAAAAABfXhAAUAAAAIdHJlYXN1cnkEAAAADWFtb3VudFRvSXNzdWUJAABrAAAAAwUAAAAJcG10QW1vdW50BQAAAA9zaW5nbGVMUGluVmFsdWUAAAAAAAX14QAEAAAAB0xQSXNzdWUJAQAAAAdSZWlzc3VlAAAAAwUAAAACTFAFAAAADWFtb3VudFRvSXNzdWUGBAAAAAh0cmFuc2ZlcgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA1hbW91bnRUb0lzc3VlBQAAAAJMUAQAAAAGc3Rha2VkCQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIFAAAABHRoaXMFAAAACWtleVN0YWtlZAAAAAAAAAAAAAQAAAALdXBkYXRlU3RhdGUJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAlrZXlTdGFrZWQJAABkAAAAAgUAAAAGc3Rha2VkCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAZhbW91bnQJAARMAAAAAgUAAAAHTFBJc3N1ZQkABEwAAAACBQAAAAh0cmFuc2ZlcgkABEwAAAACBQAAAAt1cGRhdGVTdGF0ZQUAAAADbmlsAAAAAN8Tomg=", "height": 2046808, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5fSgVcVzPT8PRVdxvmTKrjQWMwAT39wBLKU1w1aMeXGr Next: GHMshr3656d58JDiHN3buqoj8i2b6HwbyCJTkP8akYFe Diff:
OldNewDifferences
1111 func stake () = {
1212 let pmt = value(i.payments[0])
1313 let pmtAmount = pmt.amount
14+ let keyStaked = "STAKED_LP"
1415 if ((pmt.assetId != ID))
1516 then throw("attach testNSBT tokens only")
1617 else if (isStopped)
2324 case _ =>
2425 throw("Can't find asset")
2526 }
26- let singleLPinValue = ((totalIssued * 100000000) / inTreasury)
27- let amountToIssue = ((pmtAmount * singleLPinValue) / 100000000)
27+ let treasury = (inTreasury - pmtAmount)
28+ let singleLPinValue = fraction(totalIssued, 100000000, treasury)
29+ let amountToIssue = fraction(pmtAmount, singleLPinValue, 100000000)
2830 let LPIssue = Reissue(LP, amountToIssue, true)
2931 let transfer = ScriptTransfer(i.caller, amountToIssue, LP)
30-[LPIssue, transfer]
32+ let staked = valueOrElse(getInteger(this, keyStaked), 0)
33+ let updateState = IntegerEntry(keyStaked, (staked + i.payments[0].amount))
34+[LPIssue, transfer, updateState]
3135 }
3236 }
3337
34-
35-
36-@Callable(i)
37-func withdraw (amount) = {
38- let attached = i.payments[0]
39- let paymentID = i.payments[0].assetId
40- if ((paymentID != LP))
41- then throw("Attach the correct LP token")
42- else {
43- let newAmount = (attached.amount - amount)
44- if ((0 > amount))
45- then throw("Can't withdraw negative amount")
46- else if ((0 > newAmount))
47- then throw("Not enough balance")
48- else {
49- let burning = Burn(LP, amount)
50- let transfer = ScriptTransfer(i.caller, newAmount, ID)
51-[burning, transfer]
52- }
53- }
54- }
55-
56-
57-@Verifier(tx)
58-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
5938
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ID = base58'JAfMu2seKNzTVfqi5w5Pjh4kwwPTZPCEFpc2q2vDyFeh'
55
66 let LP = base58'9ZymB4TJF6oQ3HwYgYFKizAf6m64sQF896mUzcsDJ4Wx'
77
88 let isStopped = false
99
1010 @Callable(i)
1111 func stake () = {
1212 let pmt = value(i.payments[0])
1313 let pmtAmount = pmt.amount
14+ let keyStaked = "STAKED_LP"
1415 if ((pmt.assetId != ID))
1516 then throw("attach testNSBT tokens only")
1617 else if (isStopped)
1718 then throw("smart contract is on lock")
1819 else {
1920 let inTreasury = assetBalance(this, ID)
2021 let totalIssued = match assetInfo(LP) {
2122 case asset: Asset =>
2223 asset.quantity
2324 case _ =>
2425 throw("Can't find asset")
2526 }
26- let singleLPinValue = ((totalIssued * 100000000) / inTreasury)
27- let amountToIssue = ((pmtAmount * singleLPinValue) / 100000000)
27+ let treasury = (inTreasury - pmtAmount)
28+ let singleLPinValue = fraction(totalIssued, 100000000, treasury)
29+ let amountToIssue = fraction(pmtAmount, singleLPinValue, 100000000)
2830 let LPIssue = Reissue(LP, amountToIssue, true)
2931 let transfer = ScriptTransfer(i.caller, amountToIssue, LP)
30-[LPIssue, transfer]
32+ let staked = valueOrElse(getInteger(this, keyStaked), 0)
33+ let updateState = IntegerEntry(keyStaked, (staked + i.payments[0].amount))
34+[LPIssue, transfer, updateState]
3135 }
3236 }
3337
34-
35-
36-@Callable(i)
37-func withdraw (amount) = {
38- let attached = i.payments[0]
39- let paymentID = i.payments[0].assetId
40- if ((paymentID != LP))
41- then throw("Attach the correct LP token")
42- else {
43- let newAmount = (attached.amount - amount)
44- if ((0 > amount))
45- then throw("Can't withdraw negative amount")
46- else if ((0 > newAmount))
47- then throw("Not enough balance")
48- else {
49- let burning = Burn(LP, amount)
50- let transfer = ScriptTransfer(i.caller, newAmount, ID)
51-[burning, transfer]
52- }
53- }
54- }
55-
56-
57-@Verifier(tx)
58-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
5938

github/deemru/w8io/026f985 
48.22 ms