1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let token = base58'Fm4qczu6Pepz8KUhh3Heb6LeTVfpSMX5vvNgw3x764CS' |
---|
5 | | - | |
---|
6 | | - | let lpTCI = base58'zMoz8KokhTvMU6GosBdAHrWfg8aCWSpP1nBigwwi63D' |
---|
7 | | - | |
---|
8 | | - | let dapp = base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz' |
---|
9 | | - | |
---|
10 | | - | let isStopped = false |
---|
11 | | - | |
---|
12 | | - | let keyStaked = "STAKED_LP" |
---|
13 | | - | |
---|
14 | | - | let keyCompound = "From_Compound" |
---|
15 | | - | |
---|
16 | | - | @Callable(i) |
---|
17 | | - | func stake () = { |
---|
18 | | - | let pmt = value(i.payments[0]) |
---|
19 | | - | let pmtAmount = pmt.amount |
---|
20 | | - | if ((pmt.assetId != token)) |
---|
21 | | - | then throw("attach USDTUSDNLP tokens only") |
---|
22 | | - | else if (isStopped) |
---|
23 | | - | then throw("smart contract is on lock") |
---|
24 | | - | else { |
---|
25 | | - | let tkStaked = valueOrElse(getInteger(this, keyStaked), 0) |
---|
26 | | - | if ((tkStaked == tkStaked)) |
---|
27 | | - | then { |
---|
28 | | - | let updateState = IntegerEntry(keyStaked, (tkStaked + i.payments[0].amount)) |
---|
29 | | - | if ((updateState == updateState)) |
---|
30 | | - | then if ((updateState == updateState)) |
---|
31 | | - | then { |
---|
32 | | - | let totalIssued = match assetInfo(lpTCI) { |
---|
33 | | - | case asset: Asset => |
---|
34 | | - | asset.quantity |
---|
35 | | - | case _ => |
---|
36 | | - | throw("Can't find asset") |
---|
37 | | - | } |
---|
38 | | - | let treasury = (((tkStaked + assetBalance(this, token)) + pmtAmount) - pmtAmount) |
---|
39 | | - | let forOne = fraction(totalIssued, 100000000, treasury) |
---|
40 | | - | let toIssue = fraction(pmtAmount, forOne, 100000000) |
---|
41 | | - | let LPstake = invoke(Address(base58'3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz'), "stake", nil, [pmt]) |
---|
42 | | - | if ((LPstake == LPstake)) |
---|
43 | | - | then { |
---|
44 | | - | let LPIssue = Reissue(lpTCI, toIssue, true) |
---|
45 | | - | let transfer = ScriptTransfer(i.caller, toIssue, lpTCI) |
---|
46 | | - | [LPIssue, transfer] |
---|
47 | | - | } |
---|
48 | | - | else throw("Strict value is not equal to itself.") |
---|
49 | | - | } |
---|
50 | | - | else throw("Strict value is not equal to itself.") |
---|
51 | | - | else throw("Strict value is not equal to itself.") |
---|
52 | | - | } |
---|
53 | | - | else throw("Strict value is not equal to itself.") |
---|
54 | | - | } |
---|
55 | | - | } |
---|
56 | | - | |
---|
57 | | - | |
---|
58 | | - | |
---|
59 | | - | @Callable(i) |
---|
60 | | - | func compound () = { |
---|
61 | | - | let compound = value(i.payments[0]) |
---|
62 | | - | let compoundAmount = compound.amount |
---|
63 | | - | if ((compound.assetId != token)) |
---|
64 | | - | then throw("attach USDTUSDNLP tokens only") |
---|
65 | | - | else { |
---|
66 | | - | let fromCompound = valueOrElse(getInteger(this, keyCompound), 0) |
---|
67 | | - | let totalStaked = valueOrElse(getInteger(this, keyStaked), 0) |
---|
68 | | - | let updateState = IntegerEntry(keyStaked, (totalStaked + i.payments[0].amount)) |
---|
69 | | - | if ((updateState == updateState)) |
---|
70 | | - | then { |
---|
71 | | - | let totalOfCompound = IntegerEntry(keyCompound, (fromCompound + compoundAmount)) |
---|
72 | | - | if ((totalOfCompound == totalOfCompound)) |
---|
73 | | - | then [updateState, totalOfCompound] |
---|
74 | | - | else throw("Strict value is not equal to itself.") |
---|
75 | | - | } |
---|
76 | | - | else throw("Strict value is not equal to itself.") |
---|
77 | | - | } |
---|
78 | | - | } |
---|
79 | | - | |
---|
80 | | - | |
---|
| 1 | + | # no script |
---|