tx · 7nT47dFUt85V6BUwnrfgjbojVw2BEJQA3CCiZTadF2LH
3Mv7nXq2V2Dnn9oSkB5feRt6RxtqnPiAXNH: -0.01400000 Waves
2022.04.08 15:50 [1999617] smart account 3Mv7nXq2V2Dnn9oSkB5feRt6RxtqnPiAXNH > SELF 0.00000000 Waves
{
"type": 13,
"id": "7nT47dFUt85V6BUwnrfgjbojVw2BEJQA3CCiZTadF2LH",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1649422277585,
"version": 2,
"chainId": 84,
"sender": "3Mv7nXq2V2Dnn9oSkB5feRt6RxtqnPiAXNH",
"senderPublicKey": "HJ4JLtArYaaiBiWho6gzLRbKUVM6ZVTaKmci6sgFQtEm",
"proofs": [
"3ir3QZCcvH92CeyJ7uiQsNasw6zv4DDrTdbFcTUbcVDgDxgkNAMtF7payPZ4endGULtaoAdvruSQPBmWskaWY765"
],
"script": "base64:AAIFAAAAAAAAAAQIAhIAAAAAAwAAAAACSUQBAAAAAAAAAAACTFABAAAAAAAAAAAJaXNTdG9wcGVkBwAAAAEAAAABaQEAAAAFc3Rha2UAAAAABAAAAANwbXQJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAEAAAACXBtdEFtb3VudAgFAAAAA3BtdAAAAAZhbW91bnQDCQEAAAACIT0AAAACCAUAAAADcG10AAAAB2Fzc2V0SWQFAAAAAklECQAAAgAAAAECAAAAG2F0dGFjaCB0ZXN0TlNCVCB0b2tlbnMgb25seQMFAAAACWlzU3RvcHBlZAkAAAIAAAABAgAAABlzbWFydCBjb250cmFjdCBpcyBvbiBsb2NrBAAAAAppblRyZWFzdXJ5CQAD8AAAAAIFAAAABHRoaXMFAAAAAklEBAAAAAt0b3RhbElzc3VlZAQAAAAHJG1hdGNoMAkAA+wAAAABBQAAAAJMUAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAFQXNzZXQEAAAABWFzc2V0BQAAAAckbWF0Y2gwCAUAAAAFYXNzZXQAAAAIcXVhbnRpdHkJAAACAAAAAQIAAAAQQ2FuJ3QgZmluZCBhc3NldAQAAAAHdG9Jc3N1ZQkAAGkAAAACBQAAAAppblRyZWFzdXJ5BQAAAAt0b3RhbElzc3VlZAkABEwAAAACCQEAAAAHUmVpc3N1ZQAAAAMFAAAAAkxQBQAAAAd0b0lzc3VlBgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAAB3RvSXNzdWUFAAAAAkxQBQAAAANuaWwAAAAAgl0f+w==",
"height": 1999617,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 57e4EAmJV1U94T2inp1oycCAviJHcpQZJnwzkd7JgUam
Next: AHsRxHZqML38ooraMUyBNd5Xf2x4W8BF8o9MCj7dLqZy
Diff:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 5 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let ID = base58'JAfMu2seKNzTVfqi5w5Pjh4kwwPTZPCEFpc2q2vDyFeh' |
---|
| 4 | + | let ID = base58'' |
---|
5 | 5 | | |
---|
6 | | - | let LP = base58'6gryiTrJoLkNzBtZLVBuCyCvnxPY77TVUS2ouYYjjVTU' |
---|
| 6 | + | let LP = base58'' |
---|
7 | 7 | | |
---|
8 | 8 | | let isStopped = false |
---|
9 | 9 | | |
---|
|
17 | 17 | | then throw("smart contract is on lock") |
---|
18 | 18 | | else { |
---|
19 | 19 | | let inTreasury = assetBalance(this, ID) |
---|
20 | | - | let totalIssued = IntegerEntry("6gryiTrJoLkNzBtZLVBuCyCvnxPY77TVUS2ouYYjjVTU", 100) |
---|
21 | | - | let test = totalIssued.value |
---|
22 | | - | let singleLPinValue = (test / inTreasury) |
---|
23 | | - | let LPIssue = Reissue(LP, singleLPinValue, true) |
---|
24 | | - | let transfer = ScriptTransfer(i.caller, singleLPinValue, LP) |
---|
25 | | - | [LPIssue, transfer] |
---|
| 20 | + | let totalIssued = match assetInfo(LP) { |
---|
| 21 | + | case asset: Asset => |
---|
| 22 | + | asset.quantity |
---|
| 23 | + | case _ => |
---|
| 24 | + | throw("Can't find asset") |
---|
| 25 | + | } |
---|
| 26 | + | let toIssue = (inTreasury / totalIssued) |
---|
| 27 | + | [Reissue(LP, toIssue, true), ScriptTransfer(i.caller, toIssue, LP)] |
---|
26 | 28 | | } |
---|
27 | 29 | | } |
---|
28 | 30 | | |
---|
29 | | - | |
---|
30 | | - | |
---|
31 | | - | @Callable(i) |
---|
32 | | - | func withdraw (amount) = { |
---|
33 | | - | let attached = i.payments[0] |
---|
34 | | - | let paymentID = i.payments[0].assetId |
---|
35 | | - | if ((paymentID != LP)) |
---|
36 | | - | then throw("Attach the correct LP token") |
---|
37 | | - | else { |
---|
38 | | - | let newAmount = (attached.amount - amount) |
---|
39 | | - | if ((0 > amount)) |
---|
40 | | - | then throw("Can't withdraw negative amount") |
---|
41 | | - | else if ((0 > newAmount)) |
---|
42 | | - | then throw("Not enough balance") |
---|
43 | | - | else { |
---|
44 | | - | let burning = Burn(LP, amount) |
---|
45 | | - | let transfer = ScriptTransfer(i.caller, newAmount, ID) |
---|
46 | | - | [burning, transfer] |
---|
47 | | - | } |
---|
48 | | - | } |
---|
49 | | - | } |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | @Verifier(tx) |
---|
53 | | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
54 | 31 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 5 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let ID = base58'JAfMu2seKNzTVfqi5w5Pjh4kwwPTZPCEFpc2q2vDyFeh' |
---|
| 4 | + | let ID = base58'' |
---|
5 | 5 | | |
---|
6 | | - | let LP = base58'6gryiTrJoLkNzBtZLVBuCyCvnxPY77TVUS2ouYYjjVTU' |
---|
| 6 | + | let LP = base58'' |
---|
7 | 7 | | |
---|
8 | 8 | | let isStopped = false |
---|
9 | 9 | | |
---|
10 | 10 | | @Callable(i) |
---|
11 | 11 | | func stake () = { |
---|
12 | 12 | | let pmt = i.payments[0] |
---|
13 | 13 | | let pmtAmount = pmt.amount |
---|
14 | 14 | | if ((pmt.assetId != ID)) |
---|
15 | 15 | | then throw("attach testNSBT tokens only") |
---|
16 | 16 | | else if (isStopped) |
---|
17 | 17 | | then throw("smart contract is on lock") |
---|
18 | 18 | | else { |
---|
19 | 19 | | let inTreasury = assetBalance(this, ID) |
---|
20 | | - | let totalIssued = IntegerEntry("6gryiTrJoLkNzBtZLVBuCyCvnxPY77TVUS2ouYYjjVTU", 100) |
---|
21 | | - | let test = totalIssued.value |
---|
22 | | - | let singleLPinValue = (test / inTreasury) |
---|
23 | | - | let LPIssue = Reissue(LP, singleLPinValue, true) |
---|
24 | | - | let transfer = ScriptTransfer(i.caller, singleLPinValue, LP) |
---|
25 | | - | [LPIssue, transfer] |
---|
| 20 | + | let totalIssued = match assetInfo(LP) { |
---|
| 21 | + | case asset: Asset => |
---|
| 22 | + | asset.quantity |
---|
| 23 | + | case _ => |
---|
| 24 | + | throw("Can't find asset") |
---|
| 25 | + | } |
---|
| 26 | + | let toIssue = (inTreasury / totalIssued) |
---|
| 27 | + | [Reissue(LP, toIssue, true), ScriptTransfer(i.caller, toIssue, LP)] |
---|
26 | 28 | | } |
---|
27 | 29 | | } |
---|
28 | 30 | | |
---|
29 | | - | |
---|
30 | | - | |
---|
31 | | - | @Callable(i) |
---|
32 | | - | func withdraw (amount) = { |
---|
33 | | - | let attached = i.payments[0] |
---|
34 | | - | let paymentID = i.payments[0].assetId |
---|
35 | | - | if ((paymentID != LP)) |
---|
36 | | - | then throw("Attach the correct LP token") |
---|
37 | | - | else { |
---|
38 | | - | let newAmount = (attached.amount - amount) |
---|
39 | | - | if ((0 > amount)) |
---|
40 | | - | then throw("Can't withdraw negative amount") |
---|
41 | | - | else if ((0 > newAmount)) |
---|
42 | | - | then throw("Not enough balance") |
---|
43 | | - | else { |
---|
44 | | - | let burning = Burn(LP, amount) |
---|
45 | | - | let transfer = ScriptTransfer(i.caller, newAmount, ID) |
---|
46 | | - | [burning, transfer] |
---|
47 | | - | } |
---|
48 | | - | } |
---|
49 | | - | } |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | @Verifier(tx) |
---|
53 | | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
54 | 31 | | |
---|