6 | | - | let NEUTRINO = base58'3PNikM6yp4NqcSU8guxQtmR5onr2D4e8yTJ' |
---|
7 | | - | |
---|
8 | | - | @Callable(i) |
---|
9 | | - | func stakeUSDN (amount) = { |
---|
10 | | - | let USDNBalance = assetBalance(this, USDN) |
---|
11 | | - | if (!((USDNBalance > amount))) |
---|
12 | | - | then throw("exceeds the available amount") |
---|
13 | | - | else { |
---|
14 | | - | let result = invoke(Address(NEUTRINO), "lockNeutrino", nil, [AttachedPayment(USDN, amount)]) |
---|
15 | | - | if ((result == result)) |
---|
16 | | - | then { |
---|
17 | | - | let stakedUSDN = valueOrElse(getInteger(this, "staked_usdn_amount"), 0) |
---|
18 | | - | let totalStakedUSDN = (stakedUSDN + amount) |
---|
19 | | - | $Tuple2([IntegerEntry("staked_usdn_amount", totalStakedUSDN)], unit) |
---|
20 | | - | } |
---|
21 | | - | else throw("Strict value is not equal to itself.") |
---|
22 | | - | } |
---|
23 | | - | } |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | |
---|
27 | | - | @Callable(i) |
---|
28 | | - | func unstakeUSDN () = { |
---|
29 | | - | let totalStakedUSDN = getIntegerValue(this, "staked_usdn_amount") |
---|
30 | | - | let totalStakedUSDNNeutrino = getIntegerValue(Address(NEUTRINO), ("rpd_balance_DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p_" + toString(this))) |
---|
31 | | - | if (!((totalStakedUSDN == totalStakedUSDNNeutrino))) |
---|
32 | | - | then throw("amounts are not matching, check it!!!") |
---|
33 | | - | else { |
---|
34 | | - | let result = invoke(Address(NEUTRINO), "unlockNeutrino", [totalStakedUSDN, "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"], nil) |
---|
35 | | - | if ((result == result)) |
---|
36 | | - | then $Tuple2([BooleanEntry("unstaked_usdn", true), IntegerEntry("unstaked_usdn_amount", totalStakedUSDN), IntegerEntry("staked_usdn_amount", 0)], unit) |
---|
37 | | - | else throw("Strict value is not equal to itself.") |
---|
38 | | - | } |
---|
39 | | - | } |
---|
40 | | - | |
---|
41 | | - | |
---|
42 | | - | |
---|
43 | | - | @Callable(i) |
---|
44 | | - | func stakeWaves (amount) = { |
---|
45 | | - | let availableWavesBalance = wavesBalance(this).available |
---|
46 | | - | if (!(((availableWavesBalance - 200000000) >= amount))) |
---|
47 | | - | then throw("not enough waves amount to lease") |
---|
48 | | - | else { |
---|
49 | | - | let LeaseAction = Lease(Address(base58'3P9DEDP5VbyXQyKtXDUt2crRPn5B7gs6ujc'), amount) |
---|
50 | | - | let leaseId = calculateLeaseId(LeaseAction) |
---|
51 | | - | let leasedAmount = valueOrElse(getInteger(this, "leased_amount"), 0) |
---|
52 | | - | let totalLeasedAmount = (leasedAmount + amount) |
---|
53 | | - | $Tuple2([LeaseAction, IntegerEntry("leased_amount", totalLeasedAmount), BinaryEntry("leasing_id", leaseId)], unit) |
---|
54 | | - | } |
---|
55 | | - | } |
---|
56 | | - | |
---|
57 | | - | |
---|
58 | | - | |
---|
59 | | - | @Callable(i) |
---|
60 | | - | func unstakeWaves () = { |
---|
61 | | - | let leaseid = getBinaryValue(this, "leasing_id") |
---|
62 | | - | $Tuple2([DeleteEntry("staked_usdn_amount"), DeleteEntry("unstaked_usdn"), DeleteEntry("unstaked_usdn_amount"), LeaseCancel(leaseid)], unit) |
---|
63 | | - | } |
---|
64 | | - | |
---|
65 | | - | |
---|
66 | | - | |
---|
67 | | - | @Callable(i) |
---|
68 | | - | func sendit () = if ((toString(i.caller) != "3PJVLNCkc7ChN4ADTTwDzGWyCXgVNuF124s")) |
---|
69 | | - | then throw("not that") |
---|
70 | | - | else $Tuple2([ScriptTransfer(i.caller, 1000, base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p')], unit) |
---|