tx · DbVP2cPsh6EWpsU2o9XbWjLxjWmKieewrLeoRFHWuzFx

3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW:  -0.01000000 Waves

2022.04.01 22:50 [1989962] smart account 3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW > SELF 0.00000000 Waves

{ "type": 13, "id": "DbVP2cPsh6EWpsU2o9XbWjLxjWmKieewrLeoRFHWuzFx", "fee": 1000000, "feeAssetId": null, "timestamp": 1648842604074, "version": 2, "chainId": 84, "sender": "3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW", "senderPublicKey": "3JY9vAw1X3RjuU83Lkd7Yq6JhZPkbNeuXbuE2pyvEnB3", "proofs": [ "27ocQyJ6fL8qwgumtUssJmmr1v4M7r3GGGCQx3AjRnkasPq6tFifo1VBAYyVXoVsBx31bDC5LoLe7p4MJYLBMz5z" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAABAAAAAAEdXNkTgEAAAAgD/IcEqzkxDya7EYaqyWosOy6BytGzG2IcvC14pJJAbQAAAAABnN0YWtlcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVDRN1hxurYPxlZgKuniaPP5OOF3+bmEyywAAAAAJbGVhc2VQb29sCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUNE3WHG6tg/GVmAq6eJo8/k44Xf5uYTLLAAAAAApzaGFyZVRva2VuAQAAACAupaFKeRVSncUgrvmuFwheLwyjBPMrU8dCt5b8udYrsQAAAAEAAAABaQEAAAAMYWRkTGlxdWlkaXR5AAAAAAMDCQEAAAACIT0AAAACCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAdhc3NldElkBQAAAAR1bml0BgkBAAAAAiE9AAAAAggJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAEAAAAHYXNzZXRJZAUAAAAEdXNkTgkAAAIAAAABAgAAABF1bmV4cGVjdGVkIGFzc2V0cwQAAAABcgkA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NlQ2FuY2VsAAAAAQkAAlkAAAABBQAAAAJpZAUAAAADbmlsCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIFAAAABWlkS2V5CQACWAAAAAEFAAAACm5ld0xlYXNlSWQFAAAAA25pbAkABE4AAAACBQAAAAZjYW5jZWwJAARMAAAAAgUAAAAIbmV3TGVhc2UJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyAAAAAAAAAAABBQAAAApzaGFyZVRva2VuCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAA5sZWFzZUFtb3VudEtleQkAAGQAAAACBQAAAAxsZWFzZWRBbW91bnQICQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAAAAAABmFtb3VudAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAQc3Rha2luZ0Ftb3VudEtleQUAAAANc3Rha2luZ0Ftb3VudAUAAAADbmlsCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAABB3T0n", "height": 1989962, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7uouXWNjPXskm2GAdmV9ykMndJT9yCrfjmCeRiVhGKwh Next: CNm6PsJGTfca5VHvPPmyuy2paPBc7xcd9JDMCT5M9ZBs Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let usdN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'
55
6+let staker = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW')
7+
8+let leasePool = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW')
9+
10+let shareToken = base58'496Ep8DDZwru81HjT5YAj7vUvYUi4zxyrHCgkD9GXmwe'
11+
612 @Callable(i)
7-func stake () = if ((i.payments[0].assetId != usdN))
8- then throw("unexpected asset")
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")
917 else {
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)
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.")
1343 }
1444
1545
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let usdN = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT'
55
6+let staker = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW')
7+
8+let leasePool = Address(base58'3MtgeA4XXgXJ8JUcFnX7U4X5GFzisbnoZcW')
9+
10+let shareToken = base58'496Ep8DDZwru81HjT5YAj7vUvYUi4zxyrHCgkD9GXmwe'
11+
612 @Callable(i)
7-func stake () = if ((i.payments[0].assetId != usdN))
8- then throw("unexpected asset")
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")
917 else {
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)
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.")
1343 }
1444
1545

github/deemru/w8io/169f3d6 
36.04 ms