tx · CNm6PsJGTfca5VHvPPmyuy2paPBc7xcd9JDMCT5M9ZBs 3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW: -0.01000000 Waves 2022.04.01 22:57 [1989971] smart account 3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW > SELF 0.00000000 Waves
{ "type": 13, "id": "CNm6PsJGTfca5VHvPPmyuy2paPBc7xcd9JDMCT5M9ZBs", "fee": 1000000, "feeAssetId": null, "timestamp": 1648843055492, "version": 2, "chainId": 84, "sender": "3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW", "senderPublicKey": "3JY9vAw1X3RjuU83Lkd7Yq6JhZPkbNeuXbuE2pyvEnB3", "proofs": [ "3vK2H1hnojTqzJUqXKvZih3NZa2vHpLBBL68SyxKTnTKV29ffS6yiBppEjQ2HRUyCBgNqQt92mxqU3mpmi9avz7M" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAAAQAAAAAEdXNkTgEAAAAgD/IcEqzkxDya7EYaqyWosOy6BytGzG2IcvC14pJJAbQAAAABAAAAAWkBAAAABXN0YWtlAAAAAAMJAQAAAAIhPQAAAAIICQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAAAAAAB2Fzc2V0SWQFAAAABHVzZE4JAAACAAAAAQIAAAAQdW5leHBlY3RlZCBhc3NldAQAAAAQY3VycmVudExpcXVpZGl0eQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBoAAAACBQAAAAR0aGlzCQAEJQAAAAEIBQAAAAFpAAAADG9yaWdpbkNhbGxlcgAAAAAAAAAAAAQAAAAMbmV3TGlxdWlkaXR5CQAAZAAAAAIFAAAAEGN1cnJlbnRMaXF1aWRpdHkICQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAAAAAABmFtb3VudAkABRQAAAACCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQAEJQAAAAEIBQAAAAFpAAAADG9yaWdpbkNhbGxlcgUAAAAMbmV3TGlxdWlkaXR5BQAAAANuaWwFAAAADG5ld0xpcXVpZGl0eQAAAABXtF8K", "height": 1989971, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DbVP2cPsh6EWpsU2o9XbWjLxjWmKieewrLeoRFHWuzFx Next: FS3q5sRWRu8czYhAFKeeZuJMFGCwdRXHTSxLevybYx6z Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let usdN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
5 | 5 | ||
6 | - | let staker = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW') | |
7 | - | ||
8 | - | let leasePool = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW') | |
9 | - | ||
10 | - | let shareToken = base58'496Ep8DDZwru81HjT5YAj7vUvYUi4zxyrHCgkD9GXmwe' | |
11 | - | ||
12 | 6 | @Callable(i) | |
13 | - | func addLiquidity () = if (if ((i.payments[0].assetId != unit)) | |
14 | - | then true | |
15 | - | else (i.payments[1].assetId != usdN)) | |
16 | - | then throw("unexpected assets") | |
7 | + | func stake () = if ((i.payments[0].assetId != usdN)) | |
8 | + | then throw("unexpected asset") | |
17 | 9 | else { | |
18 | - | let r = invoke(staker, "stake", nil, [i.payments[1]]) | |
19 | - | if ((r == r)) | |
20 | - | then { | |
21 | - | let stakingAmount = match r { | |
22 | - | case a: Int => | |
23 | - | a | |
24 | - | case _ => | |
25 | - | throw("unexpected result type from the staker") | |
26 | - | } | |
27 | - | let stakingAmountKey = ("STAKING_AMOUNT_" + toString(i.caller)) | |
28 | - | let leaseAmountKey = ("LEASE_AMOUNT_" + toString(i.caller)) | |
29 | - | let idKey = ("ID_" + toString(i.caller)) | |
30 | - | let leasedAmount = valueOrElse(getInteger(this, leaseAmountKey), 0) | |
31 | - | let leaseId = getString(this, idKey) | |
32 | - | let newLease = Lease(leasePool, (leasedAmount + i.payments[0].amount)) | |
33 | - | let newLeaseId = calculateLeaseId(newLease) | |
34 | - | let cancel = match leaseId { | |
35 | - | case id: String => | |
36 | - | [LeaseCancel(fromBase58String(id))] | |
37 | - | case _ => | |
38 | - | [StringEntry(idKey, toBase58String(newLeaseId))] | |
39 | - | } | |
40 | - | (cancel ++ [newLease, ScriptTransfer(i.caller, 1, shareToken), IntegerEntry(leaseAmountKey, (leasedAmount + i.payments[0].amount)), IntegerEntry(stakingAmountKey, stakingAmount)]) | |
41 | - | } | |
42 | - | else throw("Strict value is not equal to itself.") | |
10 | + | let currentLiquidity = valueOrElse(getInteger(this, toString(i.originCaller)), 0) | |
11 | + | let newLiquidity = (currentLiquidity + i.payments[0].amount) | |
12 | + | $Tuple2([IntegerEntry(toString(i.originCaller), newLiquidity)], newLiquidity) | |
43 | 13 | } | |
44 | 14 | ||
45 | 15 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let usdN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
5 | 5 | ||
6 | - | let staker = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW') | |
7 | - | ||
8 | - | let leasePool = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW') | |
9 | - | ||
10 | - | let shareToken = base58'496Ep8DDZwru81HjT5YAj7vUvYUi4zxyrHCgkD9GXmwe' | |
11 | - | ||
12 | 6 | @Callable(i) | |
13 | - | func addLiquidity () = if (if ((i.payments[0].assetId != unit)) | |
14 | - | then true | |
15 | - | else (i.payments[1].assetId != usdN)) | |
16 | - | then throw("unexpected assets") | |
7 | + | func stake () = if ((i.payments[0].assetId != usdN)) | |
8 | + | then throw("unexpected asset") | |
17 | 9 | else { | |
18 | - | let r = invoke(staker, "stake", nil, [i.payments[1]]) | |
19 | - | if ((r == r)) | |
20 | - | then { | |
21 | - | let stakingAmount = match r { | |
22 | - | case a: Int => | |
23 | - | a | |
24 | - | case _ => | |
25 | - | throw("unexpected result type from the staker") | |
26 | - | } | |
27 | - | let stakingAmountKey = ("STAKING_AMOUNT_" + toString(i.caller)) | |
28 | - | let leaseAmountKey = ("LEASE_AMOUNT_" + toString(i.caller)) | |
29 | - | let idKey = ("ID_" + toString(i.caller)) | |
30 | - | let leasedAmount = valueOrElse(getInteger(this, leaseAmountKey), 0) | |
31 | - | let leaseId = getString(this, idKey) | |
32 | - | let newLease = Lease(leasePool, (leasedAmount + i.payments[0].amount)) | |
33 | - | let newLeaseId = calculateLeaseId(newLease) | |
34 | - | let cancel = match leaseId { | |
35 | - | case id: String => | |
36 | - | [LeaseCancel(fromBase58String(id))] | |
37 | - | case _ => | |
38 | - | [StringEntry(idKey, toBase58String(newLeaseId))] | |
39 | - | } | |
40 | - | (cancel ++ [newLease, ScriptTransfer(i.caller, 1, shareToken), IntegerEntry(leaseAmountKey, (leasedAmount + i.payments[0].amount)), IntegerEntry(stakingAmountKey, stakingAmount)]) | |
41 | - | } | |
42 | - | else throw("Strict value is not equal to itself.") | |
10 | + | let currentLiquidity = valueOrElse(getInteger(this, toString(i.originCaller)), 0) | |
11 | + | let newLiquidity = (currentLiquidity + i.payments[0].amount) | |
12 | + | $Tuple2([IntegerEntry(toString(i.originCaller), newLiquidity)], newLiquidity) | |
43 | 13 | } | |
44 | 14 | ||
45 | 15 |
github/deemru/w8io/169f3d6 25.39 ms ◑