tx · DUd3FvVSS6eD7sdFHd5xyJM6UaUoVo3r86CEwwmwKGu4 3Mwe3wUHrsNMLXXhVyGowCYHk2nbXq748Wu: -0.00900000 Waves 2022.06.28 13:34 [2116173] smart account 3Mwe3wUHrsNMLXXhVyGowCYHk2nbXq748Wu > SELF 0.00000000 Waves
{ "type": 13, "id": "DUd3FvVSS6eD7sdFHd5xyJM6UaUoVo3r86CEwwmwKGu4", "fee": 900000, "feeAssetId": null, "timestamp": 1656412532710, "version": 2, "chainId": 84, "sender": "3Mwe3wUHrsNMLXXhVyGowCYHk2nbXq748Wu", "senderPublicKey": "8gh5umGWLgKR753skjYwFpBbUhx3hsmmyqBM3KQyLYaE", "proofs": [ "565VXxQy4pjZnfzmPf61vqxk4MFCWHhfAQSQWJoufxqptwEfDpyXAnVTuktdUnKPq3thaAT6YFZQDEuCw5VqRiuv" ], "script": "base64:AAIFAAAAAAAAAAwIAhIAEgASABIAEgAAAAAPAAAAAAh1c2RuVXNkdAEAAAAgeKe/TORdN+2VIdfWflWy/q4Ef+gR/VrWL/1DGC+Wt8AAAAAADXVzZG5Vc2R0TFBUQ0kBAAAAIBG6tC/qJMhI0cdjddgUOO1bmK5/To9FHcuj/RydMcYtAAAAAAh3eFVzZG5MUAEAAAAAAAAAAAt3eFVzZG5MUFRDSQEAAAAAAAAAAAlpc1N0b3BwZWQHAAAAAAtrZXlVc2R0VXNkbgIAAAAJU1RBS0VEX0xQAAAAAAtrZXlDb21wb3VuZAIAAAANRnJvbV9Db21wb3VuZAAAAAAOd3hVc2RuQ29tcG91bmQCAAAAEFdYX1VTRE5fY29tcG91bmQAAAAACWtleVdYVVNETgIAAAAHV1hfVVNETgAAAAAMa2V5V0FWRVNVU0ROAgAAAApXQVZFU19VU0ROAAAAABBrZXlXYXZlc0NvbXBvdW5kAgAAABNXQVZFU19VU0ROX0NPTVBPVU5EAAAAAAprZXlCdGNVc2RuAgAAAAhCVENfVVNETgAAAAASa2V5QnRjVXNkbkNvbXBvdW5kAg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bGYuAAAAAWkBAAAAB2RlZmF1bHQAAAAABAAAAAVkZWZTdAAAAAAABfXhAAQAAAAGdXBkYXRlCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAJa2V5V1hVU0ROBQAAAAVkZWZTdAkABEwAAAACBQAAAAZ1cGRhdGUFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5oazl8A==", "height": 2116173, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8BZs4EjCBDW81poHWgtwibtSbS3d7bcRmjPy1DBA5T8Z Next: Fca1YJz2U9oLEW4P7WtYsP7Uif4T3PnCTqZy3jAv9fje Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let usdnUsdt = base58'97zHFp1C3cB7qfvx8Xv5f2rWp9nUSG5UnAamfPcW6txf' | |
5 | 5 | ||
6 | - | let lpTCI = base58'DKaehEck2SuSrCWyUBY6bR4gEvAMZaEm9pqwiNSPXSvn' | |
6 | + | let usdnUsdtLPTCI = base58'2CD44HANZzsdU7yqRsmz7L9eA2Foh4YYMC4azMbaZEj6' | |
7 | + | ||
8 | + | let wxUsdnLP = base58'' | |
9 | + | ||
10 | + | let wxUsdnLPTCI = base58'' | |
7 | 11 | ||
8 | 12 | let isStopped = false | |
9 | 13 | ||
10 | - | let | |
14 | + | let keyUsdtUsdn = "STAKED_LP" | |
11 | 15 | ||
12 | 16 | let keyCompound = "From_Compound" | |
13 | 17 | ||
18 | + | let wxUsdnCompound = "WX_USDN_compound" | |
19 | + | ||
20 | + | let keyWXUSDN = "WX_USDN" | |
21 | + | ||
22 | + | let keyWAVESUSDN = "WAVES_USDN" | |
23 | + | ||
24 | + | let keyWavesCompound = "WAVES_USDN_COMPOUND" | |
25 | + | ||
26 | + | let keyBtcUsdn = "BTC_USDN" | |
27 | + | ||
28 | + | let keyBtcUsdnCompound = "BTC_USDN_COMPOUND" | |
29 | + | ||
30 | + | let keyEthUsdn = "ETH_USDN" | |
31 | + | ||
32 | + | let keyEthUsdnCompound = "ETH_USDN_COMPOUND" | |
33 | + | ||
14 | 34 | @Callable(i) | |
15 | - | func | |
35 | + | func depositWxUsdnLP () = { | |
16 | 36 | let pmt = value(i.payments[0]) | |
17 | 37 | let pmtAmount = pmt.amount | |
18 | - | if ((pmt.assetId != | |
19 | - | then throw("attach | |
38 | + | if ((pmt.assetId != wxUsdnLP)) | |
39 | + | then throw("attach WXUSDNLP tokens only") | |
20 | 40 | else if (isStopped) | |
21 | 41 | then throw("smart contract is on lock") | |
22 | 42 | else { | |
23 | - | let tkStaked = valueOrElse(getInteger(this, keyStaked), 0) | |
43 | + | let tkStaked = valueOrElse(getInteger(this, keyWXUSDN), 0) | |
44 | + | let totalIssued = match assetInfo(wxUsdnLPTCI) { | |
45 | + | case asset: Asset => | |
46 | + | asset.quantity | |
47 | + | case _ => | |
48 | + | throw("Can't find asset") | |
49 | + | } | |
24 | 50 | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
25 | - | let updateState = IntegerEntry(keyStaked, (tkStaked + i.payments[0].amount)) | |
26 | - | if ((updateState == updateState)) | |
51 | + | let forOne = fraction(totalIssued, 100000000, tkStaked) | |
52 | + | let toIssue = fraction(pmtAmount, forOne, 100000000) | |
53 | + | let updateState = IntegerEntry(keyUsdtUsdn, (tkStaked + pmtAmount)) | |
54 | + | let LPstake = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [pmt]) | |
55 | + | if ((LPstake == LPstake)) | |
27 | 56 | then { | |
28 | - | let totalIssued = match assetInfo(lpTCI) { | |
29 | - | case asset: Asset => | |
30 | - | asset.quantity | |
31 | - | case _ => | |
32 | - | throw("Can't find asset") | |
33 | - | } | |
34 | - | let forOne = fraction(totalIssued, 100000000, tkStaked) | |
35 | - | let toIssue = fraction(pmtAmount, forOne, 100000000) | |
36 | - | let LPstake = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [pmt]) | |
37 | - | if ((LPstake == LPstake)) | |
38 | - | then { | |
39 | - | let LPIssue = Reissue(lpTCI, toIssue, true) | |
40 | - | let transfer = ScriptTransfer(i.caller, toIssue, lpTCI) | |
57 | + | let LPIssue = Reissue(wxUsdnLPTCI, toIssue, true) | |
58 | + | let transfer = ScriptTransfer(i.caller, toIssue, wxUsdnLPTCI) | |
41 | 59 | [LPIssue, transfer, updateState] | |
42 | - | } | |
43 | - | else throw("Strict value is not equal to itself.") | |
44 | 60 | } | |
45 | 61 | else throw("Strict value is not equal to itself.") | |
46 | 62 | } | |
49 | 65 | ||
50 | 66 | ||
51 | 67 | @Callable(i) | |
52 | - | func compound () = { | |
68 | + | func depositUsdtUsdnLP () = { | |
69 | + | let pmt = value(i.payments[0]) | |
70 | + | let pmtAmount = pmt.amount | |
71 | + | if ((pmt.assetId != usdnUsdt)) | |
72 | + | then throw("attach USDTUSDNLP tokens only") | |
73 | + | else if (isStopped) | |
74 | + | then throw("smart contract is on lock") | |
75 | + | else { | |
76 | + | let tkStaked = valueOrElse(getInteger(this, keyUsdtUsdn), 0) | |
77 | + | let totalIssued = match assetInfo(usdnUsdtLPTCI) { | |
78 | + | case asset: Asset => | |
79 | + | asset.quantity | |
80 | + | case _ => | |
81 | + | throw("Can't find asset") | |
82 | + | } | |
83 | + | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
84 | + | let forOne = fraction(totalIssued, 100000000, tkStaked) | |
85 | + | let toIssue = fraction(pmtAmount, forOne, 100000000) | |
86 | + | let updateState = IntegerEntry(keyUsdtUsdn, (tkStaked + pmtAmount)) | |
87 | + | let LPstake = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [pmt]) | |
88 | + | if ((LPstake == LPstake)) | |
89 | + | then { | |
90 | + | let LPIssue = Reissue(usdnUsdtLPTCI, toIssue, true) | |
91 | + | let transfer = ScriptTransfer(i.caller, toIssue, usdnUsdtLPTCI) | |
92 | + | [LPIssue, transfer, updateState] | |
93 | + | } | |
94 | + | else throw("Strict value is not equal to itself.") | |
95 | + | } | |
96 | + | } | |
97 | + | ||
98 | + | ||
99 | + | ||
100 | + | @Callable(i) | |
101 | + | func compoundUSDTUSDNLP () = { | |
53 | 102 | let compound = value(i.payments[0]) | |
54 | 103 | let ca = compound.amount | |
55 | - | if ((compound.assetId != | |
104 | + | if ((compound.assetId != usdnUsdt)) | |
56 | 105 | then throw("attach USDTUSDNLP tokens only") | |
57 | 106 | else { | |
58 | 107 | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
59 | - | let totalStaked = valueOrElse(getInteger(this, | |
108 | + | let totalStaked = valueOrElse(getInteger(this, keyUsdtUsdn), 0) | |
60 | 109 | let stakeC = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [compound]) | |
61 | 110 | if ((stakeC == stakeC)) | |
62 | 111 | then { | |
63 | - | let updateState = IntegerEntry(keyStaked, (totalStaked + ca)) | |
112 | + | let updateState = IntegerEntry(keyUsdtUsdn, (totalStaked + ca)) | |
113 | + | let tc = IntegerEntry(keyCompound, (fromCompound + ca)) | |
114 | + | [updateState, tc] | |
115 | + | } | |
116 | + | else throw("Strict value is not equal to itself.") | |
117 | + | } | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func compoundWXUSDNLP () = { | |
124 | + | let compound = value(i.payments[0]) | |
125 | + | let ca = compound.amount | |
126 | + | if ((compound.assetId != wxUsdnLP)) | |
127 | + | then throw("attach WXUSDNLP tokens only") | |
128 | + | else { | |
129 | + | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
130 | + | let totalStaked = valueOrElse(getInteger(this, keyUsdtUsdn), 0) | |
131 | + | let stakeC = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [compound]) | |
132 | + | if ((stakeC == stakeC)) | |
133 | + | then { | |
134 | + | let updateState = IntegerEntry(keyUsdtUsdn, (totalStaked + ca)) | |
64 | 135 | let tc = IntegerEntry(keyCompound, (fromCompound + ca)) | |
65 | 136 | [updateState, tc] | |
66 | 137 | } | |
73 | 144 | @Callable(i) | |
74 | 145 | func default () = { | |
75 | 146 | let defSt = 100000000 | |
76 | - | let update = IntegerEntry( | |
147 | + | let update = IntegerEntry(keyWXUSDN, defSt) | |
77 | 148 | [update] | |
78 | 149 | } | |
79 | 150 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let usdnUsdt = base58'97zHFp1C3cB7qfvx8Xv5f2rWp9nUSG5UnAamfPcW6txf' | |
5 | 5 | ||
6 | - | let lpTCI = base58'DKaehEck2SuSrCWyUBY6bR4gEvAMZaEm9pqwiNSPXSvn' | |
6 | + | let usdnUsdtLPTCI = base58'2CD44HANZzsdU7yqRsmz7L9eA2Foh4YYMC4azMbaZEj6' | |
7 | + | ||
8 | + | let wxUsdnLP = base58'' | |
9 | + | ||
10 | + | let wxUsdnLPTCI = base58'' | |
7 | 11 | ||
8 | 12 | let isStopped = false | |
9 | 13 | ||
10 | - | let | |
14 | + | let keyUsdtUsdn = "STAKED_LP" | |
11 | 15 | ||
12 | 16 | let keyCompound = "From_Compound" | |
13 | 17 | ||
18 | + | let wxUsdnCompound = "WX_USDN_compound" | |
19 | + | ||
20 | + | let keyWXUSDN = "WX_USDN" | |
21 | + | ||
22 | + | let keyWAVESUSDN = "WAVES_USDN" | |
23 | + | ||
24 | + | let keyWavesCompound = "WAVES_USDN_COMPOUND" | |
25 | + | ||
26 | + | let keyBtcUsdn = "BTC_USDN" | |
27 | + | ||
28 | + | let keyBtcUsdnCompound = "BTC_USDN_COMPOUND" | |
29 | + | ||
30 | + | let keyEthUsdn = "ETH_USDN" | |
31 | + | ||
32 | + | let keyEthUsdnCompound = "ETH_USDN_COMPOUND" | |
33 | + | ||
14 | 34 | @Callable(i) | |
15 | - | func | |
35 | + | func depositWxUsdnLP () = { | |
16 | 36 | let pmt = value(i.payments[0]) | |
17 | 37 | let pmtAmount = pmt.amount | |
18 | - | if ((pmt.assetId != | |
19 | - | then throw("attach | |
38 | + | if ((pmt.assetId != wxUsdnLP)) | |
39 | + | then throw("attach WXUSDNLP tokens only") | |
20 | 40 | else if (isStopped) | |
21 | 41 | then throw("smart contract is on lock") | |
22 | 42 | else { | |
23 | - | let tkStaked = valueOrElse(getInteger(this, keyStaked), 0) | |
43 | + | let tkStaked = valueOrElse(getInteger(this, keyWXUSDN), 0) | |
44 | + | let totalIssued = match assetInfo(wxUsdnLPTCI) { | |
45 | + | case asset: Asset => | |
46 | + | asset.quantity | |
47 | + | case _ => | |
48 | + | throw("Can't find asset") | |
49 | + | } | |
24 | 50 | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
25 | - | let updateState = IntegerEntry(keyStaked, (tkStaked + i.payments[0].amount)) | |
26 | - | if ((updateState == updateState)) | |
51 | + | let forOne = fraction(totalIssued, 100000000, tkStaked) | |
52 | + | let toIssue = fraction(pmtAmount, forOne, 100000000) | |
53 | + | let updateState = IntegerEntry(keyUsdtUsdn, (tkStaked + pmtAmount)) | |
54 | + | let LPstake = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [pmt]) | |
55 | + | if ((LPstake == LPstake)) | |
27 | 56 | then { | |
28 | - | let totalIssued = match assetInfo(lpTCI) { | |
29 | - | case asset: Asset => | |
30 | - | asset.quantity | |
31 | - | case _ => | |
32 | - | throw("Can't find asset") | |
33 | - | } | |
34 | - | let forOne = fraction(totalIssued, 100000000, tkStaked) | |
35 | - | let toIssue = fraction(pmtAmount, forOne, 100000000) | |
36 | - | let LPstake = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [pmt]) | |
37 | - | if ((LPstake == LPstake)) | |
38 | - | then { | |
39 | - | let LPIssue = Reissue(lpTCI, toIssue, true) | |
40 | - | let transfer = ScriptTransfer(i.caller, toIssue, lpTCI) | |
57 | + | let LPIssue = Reissue(wxUsdnLPTCI, toIssue, true) | |
58 | + | let transfer = ScriptTransfer(i.caller, toIssue, wxUsdnLPTCI) | |
41 | 59 | [LPIssue, transfer, updateState] | |
42 | - | } | |
43 | - | else throw("Strict value is not equal to itself.") | |
44 | 60 | } | |
45 | 61 | else throw("Strict value is not equal to itself.") | |
46 | 62 | } | |
47 | 63 | } | |
48 | 64 | ||
49 | 65 | ||
50 | 66 | ||
51 | 67 | @Callable(i) | |
52 | - | func compound () = { | |
68 | + | func depositUsdtUsdnLP () = { | |
69 | + | let pmt = value(i.payments[0]) | |
70 | + | let pmtAmount = pmt.amount | |
71 | + | if ((pmt.assetId != usdnUsdt)) | |
72 | + | then throw("attach USDTUSDNLP tokens only") | |
73 | + | else if (isStopped) | |
74 | + | then throw("smart contract is on lock") | |
75 | + | else { | |
76 | + | let tkStaked = valueOrElse(getInteger(this, keyUsdtUsdn), 0) | |
77 | + | let totalIssued = match assetInfo(usdnUsdtLPTCI) { | |
78 | + | case asset: Asset => | |
79 | + | asset.quantity | |
80 | + | case _ => | |
81 | + | throw("Can't find asset") | |
82 | + | } | |
83 | + | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
84 | + | let forOne = fraction(totalIssued, 100000000, tkStaked) | |
85 | + | let toIssue = fraction(pmtAmount, forOne, 100000000) | |
86 | + | let updateState = IntegerEntry(keyUsdtUsdn, (tkStaked + pmtAmount)) | |
87 | + | let LPstake = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [pmt]) | |
88 | + | if ((LPstake == LPstake)) | |
89 | + | then { | |
90 | + | let LPIssue = Reissue(usdnUsdtLPTCI, toIssue, true) | |
91 | + | let transfer = ScriptTransfer(i.caller, toIssue, usdnUsdtLPTCI) | |
92 | + | [LPIssue, transfer, updateState] | |
93 | + | } | |
94 | + | else throw("Strict value is not equal to itself.") | |
95 | + | } | |
96 | + | } | |
97 | + | ||
98 | + | ||
99 | + | ||
100 | + | @Callable(i) | |
101 | + | func compoundUSDTUSDNLP () = { | |
53 | 102 | let compound = value(i.payments[0]) | |
54 | 103 | let ca = compound.amount | |
55 | - | if ((compound.assetId != | |
104 | + | if ((compound.assetId != usdnUsdt)) | |
56 | 105 | then throw("attach USDTUSDNLP tokens only") | |
57 | 106 | else { | |
58 | 107 | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
59 | - | let totalStaked = valueOrElse(getInteger(this, | |
108 | + | let totalStaked = valueOrElse(getInteger(this, keyUsdtUsdn), 0) | |
60 | 109 | let stakeC = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [compound]) | |
61 | 110 | if ((stakeC == stakeC)) | |
62 | 111 | then { | |
63 | - | let updateState = IntegerEntry(keyStaked, (totalStaked + ca)) | |
112 | + | let updateState = IntegerEntry(keyUsdtUsdn, (totalStaked + ca)) | |
113 | + | let tc = IntegerEntry(keyCompound, (fromCompound + ca)) | |
114 | + | [updateState, tc] | |
115 | + | } | |
116 | + | else throw("Strict value is not equal to itself.") | |
117 | + | } | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func compoundWXUSDNLP () = { | |
124 | + | let compound = value(i.payments[0]) | |
125 | + | let ca = compound.amount | |
126 | + | if ((compound.assetId != wxUsdnLP)) | |
127 | + | then throw("attach WXUSDNLP tokens only") | |
128 | + | else { | |
129 | + | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) | |
130 | + | let totalStaked = valueOrElse(getInteger(this, keyUsdtUsdn), 0) | |
131 | + | let stakeC = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [compound]) | |
132 | + | if ((stakeC == stakeC)) | |
133 | + | then { | |
134 | + | let updateState = IntegerEntry(keyUsdtUsdn, (totalStaked + ca)) | |
64 | 135 | let tc = IntegerEntry(keyCompound, (fromCompound + ca)) | |
65 | 136 | [updateState, tc] | |
66 | 137 | } | |
67 | 138 | else throw("Strict value is not equal to itself.") | |
68 | 139 | } | |
69 | 140 | } | |
70 | 141 | ||
71 | 142 | ||
72 | 143 | ||
73 | 144 | @Callable(i) | |
74 | 145 | func default () = { | |
75 | 146 | let defSt = 100000000 | |
76 | - | let update = IntegerEntry( | |
147 | + | let update = IntegerEntry(keyWXUSDN, defSt) | |
77 | 148 | [update] | |
78 | 149 | } | |
79 | 150 | ||
80 | 151 | ||
81 | 152 | @Verifier(tx) | |
82 | 153 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
83 | 154 |
github/deemru/w8io/026f985 31.40 ms ◑