4 | | - | let BUsd = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
5 | | - | |
---|
6 | | - | let USDT = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
7 | | - | |
---|
8 | | - | let USDC = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
9 | | - | |
---|
10 | | - | let BTC = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
11 | | - | |
---|
12 | | - | let ETH = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
13 | | - | |
---|
14 | | - | let BNB = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
15 | | - | |
---|
16 | | - | let USDN = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
17 | | - | |
---|
18 | | - | let HASH = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
19 | | - | |
---|
20 | | - | let KUSD = base58'HFLaeLdjg9cASsYhvwM9PV3NcCxa3UeVa5KvfYUPQYgJ' |
---|
| 4 | + | let BUsd = base58'nrDXX1zHfGht7xExqNxDu7voCy9wzmc9vJxwcc2jLga' |
---|
38 | | - | let pmt = if ((size(i.payments) == 1)) |
---|
39 | | - | then i.payments[0] |
---|
40 | | - | else throw("Attached payment is required") |
---|
41 | | - | if (if (if (if (if (if (if (if (if (if (if ((0 >= pmt.amount)) |
---|
42 | | - | then (pmt.assetId != BUsd) |
---|
43 | | - | else false) |
---|
44 | | - | then (pmt.assetId != USDT) |
---|
45 | | - | else false) |
---|
46 | | - | then (pmt.assetId != USDC) |
---|
47 | | - | else false) |
---|
48 | | - | then (pmt.assetId != BTC) |
---|
49 | | - | else false) |
---|
50 | | - | then (pmt.assetId != ETH) |
---|
51 | | - | else false) |
---|
52 | | - | then (pmt.assetId != BNB) |
---|
53 | | - | else false) |
---|
54 | | - | then (pmt.assetId != USDN) |
---|
55 | | - | else false) |
---|
56 | | - | then (pmt.assetId != HASH) |
---|
57 | | - | else false) |
---|
58 | | - | then (pmt.assetId != KUSD) |
---|
59 | | - | else false) |
---|
60 | | - | then isDefined(pmt.assetId) |
---|
61 | | - | else false) |
---|
62 | | - | then throw("Can only deposit accepted tokens, and amount should be positive") |
---|
63 | | - | else if (if (if ((ScopeDesc == "")) |
---|
64 | | - | then true |
---|
65 | | - | else (Deliverables == "")) |
---|
66 | | - | then true |
---|
67 | | - | else (FreelancerAddress == "")) |
---|
68 | | - | then throw("Job Scope, Deliverables desc and Freelancer Wallet Address cannot be empty") |
---|
69 | | - | else { |
---|
70 | | - | let AssetUsed = if (isDefined(pmt.assetId)) |
---|
71 | | - | then toBase58String(value(pmt.assetId)) |
---|
72 | | - | else "Waves" |
---|
73 | | - | [StringEntry((toBase58String(i.caller.bytes) + "_Scope"), ScopeDesc), StringEntry((toBase58String(i.caller.bytes) + "_Deliv"), Deliverables), StringEntry((toBase58String(i.caller.bytes) + "_Asset"), AssetUsed), StringEntry((toBase58String(i.caller.bytes) + "_Freelancer"), FreelancerAddress), IntegerEntry((toBase58String(i.caller.bytes) + "_Payment"), pmt.amount)] |
---|
74 | | - | } |
---|
| 25 | + | let NewBalance = (UserBalance + pmt.amount) |
---|
| 26 | + | [IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), NewBalance)] |
---|
81 | | - | func PayFreelancer (PayFreelancer) = { |
---|
82 | | - | let FreeLancerPayment = (toBase58String(i.caller.bytes) + "_Payment") |
---|
83 | | - | let FreelancerAddress = (toBase58String(i.caller.bytes) + "_Freelancer") |
---|
84 | | - | let PaymentAsset = (toBase58String(i.caller.bytes) + "_Asset") |
---|
85 | | - | let Paidtrx = (toBase58String(i.caller.bytes) + "_Paidtrx") |
---|
86 | | - | let amount = match getInteger(this, FreeLancerPayment) { |
---|
| 33 | + | func WithdrawLiq (UnstakedAmount) = { |
---|
| 34 | + | let UserLiquidity = (toBase58String(i.caller.bytes) + "_Liq") |
---|
| 35 | + | let LastUnstakeBlock = (toBase58String(i.caller.bytes) + "_LastUnstake") |
---|
| 36 | + | let trxUnstakeNum = (toBase58String(i.caller.bytes) + "_trxUnstake") |
---|
| 37 | + | let dAppFrees = Address(dAppFees) |
---|
| 38 | + | let WaitTime = 10 |
---|
| 39 | + | let FeePaid = 1 |
---|
| 40 | + | let amount = match getInteger(this, UserLiquidity) { |
---|
98 | | - | let FreelancerAddressStr = getStringValue(this, FreelancerAddress) |
---|
99 | | - | let PaymentAssetId = getStringValue(this, PaymentAsset) |
---|
100 | | - | let AddressFreeLancer = addressFromStringValue(FreelancerAddressStr) |
---|
101 | | - | let dAppFrees = Address(dAppFees) |
---|
102 | | - | let AssetUsed = if ((PaymentAssetId == "Waves")) |
---|
103 | | - | then unit |
---|
104 | | - | else fromBase58String(PaymentAssetId) |
---|
105 | | - | if ((0 >= (((95 * amount) / 100) - (PayFreelancer * 100000000)))) |
---|
106 | | - | then throw(("You do not have enough funds to make payment, your available funds are: " + toString((amount / 100000000)))) |
---|
107 | | - | else if (if ((PaidtrxLast >= 12)) |
---|
108 | | - | then (amount > 0) |
---|
| 52 | + | let LastUnstakeBlockValue = match getInteger(this, LastUnstakeBlock) { |
---|
| 53 | + | case a: Int => |
---|
| 54 | + | a |
---|
| 55 | + | case _ => |
---|
| 56 | + | 0 |
---|
| 57 | + | } |
---|
| 58 | + | let UserBalance = (amount - (UnstakedAmount * 10000000)) |
---|
| 59 | + | if ((0 >= UserBalance)) |
---|
| 60 | + | then throw(("You do not have enough funds to withdraw, your available funds are: " + toString((amount / 100000000)))) |
---|
| 61 | + | else if (if ((trxUnstakeValue == 2)) |
---|
| 62 | + | then (height > (trxUnstakeValue + WaitTime)) |
---|
112 | | - | let UserAccount = if ((PaidtrxLast == 11)) |
---|
113 | | - | then 0 |
---|
114 | | - | else (amount - (PayFreelancer * 100000000)) |
---|
115 | | - | let Payment2Freelance = if ((PaidtrxLast == 11)) |
---|
116 | | - | then ((95 * amount) / 100) |
---|
117 | | - | else ((95 * PayFreelancer) * 1000000) |
---|
118 | | - | let FeePaid = if ((PaidtrxLast == 11)) |
---|
119 | | - | then ((5 * amount) / 100) |
---|
120 | | - | else ((5 * PayFreelancer) * 1000000) |
---|
121 | | - | let PaidtrxValue = if ((PaidtrxLast == 11)) |
---|
122 | | - | then 0 |
---|
123 | | - | else (PaidtrxLast + 1) |
---|
124 | | - | $Tuple2([IntegerEntry((toBase58String(i.caller.bytes) + "_Payment"), UserAccount), IntegerEntry((toBase58String(i.caller.bytes) + "_Paidtrx"), PaidtrxValue), ScriptTransfer(AddressFreeLancer, Payment2Freelance, AssetUsed), ScriptTransfer(dAppFrees, FeePaid, AssetUsed)], AssetUsed) |
---|
| 66 | + | let NewTrx = (trxUnstakeValue + 1) |
---|
| 67 | + | $Tuple2([IntegerEntry((toBase58String(i.caller.bytes) + "_trxUnstake"), NewTrx), IntegerEntry((toBase58String(i.caller.bytes) + "_Liq"), UserBalance), IntegerEntry((toBase58String(i.caller.bytes) + "_trxUnstake"), height), ScriptTransfer(i.caller, (UnstakedAmount * 10000000), BUsd), ScriptTransfer(dAppFrees, (FeePaid * 100000000), BUsd)], BUsd) |
---|
127 | | - | |
---|
128 | | - | |
---|
129 | | - | |
---|
130 | | - | @Callable(i) |
---|
131 | | - | func AdminTransfer (User,Freelancer,ToFreelancer,ToUser,AdminFee) = if ((i.caller.bytes != AdmindApp)) |
---|
132 | | - | then throw("Only Admin can do this") |
---|
133 | | - | else if ((((ToUser + ToFreelancer) + AdminFee) != 100)) |
---|
134 | | - | then throw("Total of Percentages cannot be different from 100%") |
---|
135 | | - | else { |
---|
136 | | - | let FreeLancerPayment = (User + "_Payment") |
---|
137 | | - | let FreelancerAddress = (User + "_Freelancer") |
---|
138 | | - | let PaymentAsset = (toBase58String(i.caller.bytes) + "_Asset") |
---|
139 | | - | let amount = match getInteger(this, FreeLancerPayment) { |
---|
140 | | - | case a: Int => |
---|
141 | | - | a |
---|
142 | | - | case _ => |
---|
143 | | - | 0 |
---|
144 | | - | } |
---|
145 | | - | let FreelancerAddressStr = getStringValue(this, FreelancerAddress) |
---|
146 | | - | let AddressFreeLancer = addressFromStringValue(FreelancerAddressStr) |
---|
147 | | - | let PaymentAssetId = getStringValue(this, PaymentAsset) |
---|
148 | | - | let dAppFrees = Address(dAppFees) |
---|
149 | | - | let AddressUser = addressFromStringValue(User) |
---|
150 | | - | let AssetUsed = if ((PaymentAssetId == "Waves")) |
---|
151 | | - | then unit |
---|
152 | | - | else fromBase58String(PaymentAssetId) |
---|
153 | | - | if ((amount == 0)) |
---|
154 | | - | then throw("User's balance is 0 BUsdc cannot realize any payment") |
---|
155 | | - | else $Tuple2([IntegerEntry((User + "_Payment"), 0), ScriptTransfer(AddressFreeLancer, ((ToFreelancer * amount) / 100), AssetUsed), ScriptTransfer(AddressUser, ((ToUser * amount) / 100), AssetUsed), ScriptTransfer(dAppFrees, ((AdminFee * amount) / 100), AssetUsed)], AssetUsed) |
---|
156 | | - | } |
---|