tx · 22f13Y8yki3QuFz8sik34a4zoPUwtpaN2Ug3kCjWKroy
3MuvmdQpHrmMrszZmrdarf8d95XHbWMcPkM: -0.05000000 Waves
2022.10.31 15:06 [2296559] smart account 3MuvmdQpHrmMrszZmrdarf8d95XHbWMcPkM > SELF 0.00000000 Waves
{
"type": 13,
"id": "22f13Y8yki3QuFz8sik34a4zoPUwtpaN2Ug3kCjWKroy",
"fee": 5000000,
"feeAssetId": null,
"timestamp": 1667218000926,
"version": 2,
"chainId": 84,
"sender": "3MuvmdQpHrmMrszZmrdarf8d95XHbWMcPkM",
"senderPublicKey": "7UnFgjKRHSBUfvTnV31mCr4bNSKGpDZqDJCc98qzC2Ut",
"proofs": [
"4XzDDrm2PKEvnq1JMjmc3MZ1RBSA73oSCuLgYaMpc9Gyaefrk5eDu3zYLPw695NMB8Ht4kUEEa3ZyndijQB1ak96"
],
"script": "base64:AAIFAAAAAAAAABAIAhIFCgMIAQESBQoDCAEBAAAAAwAAAAAETE9ORwAAAAAAAAAAAQAAAAAFU0hPUlQAAAAAAAAAAAIAAAAAB2Fzc2V0SWQBAAAAIPd26vf3g8pl224T7gI7z1gplanB0Y3yS9ps2B1igMjeAAAAAgAAAAFpAQAAABFzd2l0Y2hMb25nVG9TaG9ydAAAAAMAAAAGbWFya2V0AAAABmFtb3VudAAAAAhsZXZlcmFnZQMJAQAAAAIhPQAAAAIIBQAAAAFpAAAABmNhbGxlcgUAAAAEdGhpcwkAAAIAAAABAgAAACh5b3UgYXJlIG5vdCBhbGxvd2VkIHRvIGNoYW5nZSBwb3NpdGlvbnMhBAAAAAhjb250cmFjdAkBAAAAB0FkZHJlc3MAAAABCQACWQAAAAEFAAAABm1hcmtldAQAAAANY2xvc2VQb3NpdGlvbgkAA/wAAAAEBQAAAAhjb250cmFjdAIAAAANY2xvc2VQb3NpdGlvbgUAAAADbmlsBQAAAANuaWwDCQAAAAAAAAIFAAAADWNsb3NlUG9zaXRpb24FAAAADWNsb3NlUG9zaXRpb24EAA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A1zaG9ydFBvc2l0aW9uCQAD/AAAAAQFAAAACGNvbnRyYWN0AgAAABBpbmNyZWFzZVBvc2l0aW9uCQAETAAAAAIFAAAABExPTkcJAARMAAAAAgUAAAAIbGV2ZXJhZ2UJAARMAAAAAgAAAAAAAAAAAQkABEwAAAACAgAAAAAFAAAAA25pbAkABEwAAAACCQEAAAAPQXR0YWNoZWRQYXltZW50AAAAAgUAAAAHYXNzZXRJZAkAAGgAAAACBQAAAAZhbW91bnQAAAAAAAAPQkAFAAAAA25pbAMJAAAAAAAAAgUAAAANc2hvcnRQb3NpdGlvbgUAAAANc2hvcnRQb3NpdGlvbgQAAAAGcmV0dXJuCQAD8AAAAAIFAAAABHRoaXMFAAAAB2Fzc2V0SWQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZyZXR1cm4FAAAAB2Fzc2V0SWQFAAAAA25pbAkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXlNJhfx",
"height": 2296559,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 2xnhuzFekctCcLinYjoLg4uEVBpoZjVotgnk2Egytzvu
Next: DBy9stz42rs9A7ynwxNpbWv5DWbzLasy2HkLKGrpXgic
Diff:
Old | New | | Differences |
---|
8 | 8 | | let assetId = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ' |
---|
9 | 9 | | |
---|
10 | 10 | | @Callable(i) |
---|
11 | | - | func switchLongToShort (market,leverage) = if ((i.caller != this)) |
---|
| 11 | + | func switchLongToShort (market,amount,leverage) = if ((i.caller != this)) |
---|
12 | 12 | | then throw("you are not allowed to change positions!") |
---|
13 | 13 | | else { |
---|
14 | 14 | | let contract = Address(fromBase58String(market)) |
---|
15 | 15 | | let closePosition = invoke(contract, "closePosition", nil, nil) |
---|
16 | 16 | | if ((closePosition == closePosition)) |
---|
17 | 17 | | then { |
---|
18 | | - | let shortPosition = invoke(contract, "increasePosition", [SHORT, leverage, 1, ""], [i.payments[0]]) |
---|
| 18 | + | let shortPosition = invoke(contract, "increasePosition", [SHORT, leverage, 1, ""], [AttachedPayment(assetId, (amount * 1000000))]) |
---|
19 | 19 | | if ((shortPosition == shortPosition)) |
---|
20 | 20 | | then { |
---|
21 | 21 | | let return = assetBalance(this, assetId) |
---|
|
29 | 29 | | |
---|
30 | 30 | | |
---|
31 | 31 | | @Callable(i) |
---|
32 | | - | func switchShortToLong (market,leverage) = if ((i.caller != this)) |
---|
| 32 | + | func switchShortToLong (market,amount,leverage) = if ((i.caller != this)) |
---|
33 | 33 | | then throw("you are not allowed to switch positions") |
---|
34 | 34 | | else { |
---|
35 | 35 | | let contract = Address(fromBase58String(market)) |
---|
36 | 36 | | let closePosition = invoke(contract, "closePosition", nil, nil) |
---|
37 | 37 | | if ((closePosition == closePosition)) |
---|
38 | 38 | | then { |
---|
39 | | - | let shortPosition = invoke(contract, "increasePosition", [LONG, leverage, 1, ""], [i.payments[0]]) |
---|
| 39 | + | let shortPosition = invoke(contract, "increasePosition", [LONG, leverage, 1, ""], [AttachedPayment(assetId, (amount * 1000000))]) |
---|
40 | 40 | | if ((shortPosition == shortPosition)) |
---|
41 | 41 | | then { |
---|
42 | 42 | | let return = assetBalance(this, assetId) |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 5 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let LONG = 1 |
---|
5 | 5 | | |
---|
6 | 6 | | let SHORT = 2 |
---|
7 | 7 | | |
---|
8 | 8 | | let assetId = base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ' |
---|
9 | 9 | | |
---|
10 | 10 | | @Callable(i) |
---|
11 | | - | func switchLongToShort (market,leverage) = if ((i.caller != this)) |
---|
| 11 | + | func switchLongToShort (market,amount,leverage) = if ((i.caller != this)) |
---|
12 | 12 | | then throw("you are not allowed to change positions!") |
---|
13 | 13 | | else { |
---|
14 | 14 | | let contract = Address(fromBase58String(market)) |
---|
15 | 15 | | let closePosition = invoke(contract, "closePosition", nil, nil) |
---|
16 | 16 | | if ((closePosition == closePosition)) |
---|
17 | 17 | | then { |
---|
18 | | - | let shortPosition = invoke(contract, "increasePosition", [SHORT, leverage, 1, ""], [i.payments[0]]) |
---|
| 18 | + | let shortPosition = invoke(contract, "increasePosition", [SHORT, leverage, 1, ""], [AttachedPayment(assetId, (amount * 1000000))]) |
---|
19 | 19 | | if ((shortPosition == shortPosition)) |
---|
20 | 20 | | then { |
---|
21 | 21 | | let return = assetBalance(this, assetId) |
---|
22 | 22 | | [ScriptTransfer(i.caller, return, assetId)] |
---|
23 | 23 | | } |
---|
24 | 24 | | else throw("Strict value is not equal to itself.") |
---|
25 | 25 | | } |
---|
26 | 26 | | else throw("Strict value is not equal to itself.") |
---|
27 | 27 | | } |
---|
28 | 28 | | |
---|
29 | 29 | | |
---|
30 | 30 | | |
---|
31 | 31 | | @Callable(i) |
---|
32 | | - | func switchShortToLong (market,leverage) = if ((i.caller != this)) |
---|
| 32 | + | func switchShortToLong (market,amount,leverage) = if ((i.caller != this)) |
---|
33 | 33 | | then throw("you are not allowed to switch positions") |
---|
34 | 34 | | else { |
---|
35 | 35 | | let contract = Address(fromBase58String(market)) |
---|
36 | 36 | | let closePosition = invoke(contract, "closePosition", nil, nil) |
---|
37 | 37 | | if ((closePosition == closePosition)) |
---|
38 | 38 | | then { |
---|
39 | | - | let shortPosition = invoke(contract, "increasePosition", [LONG, leverage, 1, ""], [i.payments[0]]) |
---|
| 39 | + | let shortPosition = invoke(contract, "increasePosition", [LONG, leverage, 1, ""], [AttachedPayment(assetId, (amount * 1000000))]) |
---|
40 | 40 | | if ((shortPosition == shortPosition)) |
---|
41 | 41 | | then { |
---|
42 | 42 | | let return = assetBalance(this, assetId) |
---|
43 | 43 | | [ScriptTransfer(i.caller, return, assetId)] |
---|
44 | 44 | | } |
---|
45 | 45 | | else throw("Strict value is not equal to itself.") |
---|
46 | 46 | | } |
---|
47 | 47 | | else throw("Strict value is not equal to itself.") |
---|
48 | 48 | | } |
---|
49 | 49 | | |
---|
50 | 50 | | |
---|
51 | 51 | | @Verifier(tx) |
---|
52 | 52 | | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
53 | 53 | | |
---|