15 | | - | func RegisterPairForVoting (EnterAssetID,days) = { |
---|
16 | | - | let pmt1 = value(i.payments[0]) |
---|
17 | | - | let pmt2 = value(i.payments[1]) |
---|
18 | | - | let maximumvotingdays = 90 |
---|
19 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
20 | | - | let TN = !(isDefined(pmt2.assetId)) |
---|
21 | | - | let oneday = 1440 |
---|
22 | | - | let NoOfDaysBlocks = (oneday * days) |
---|
23 | | - | let gap = (NoOfDaysBlocks - 43199) |
---|
24 | | - | let votesrequired = ((100000 + ((11574 * gap) / 10000)) * 100000000) |
---|
25 | | - | let votingExpire = (height + NoOfDaysBlocks) |
---|
26 | | - | let fetchpair = getString(this, ("Pair_UV_" + EnterAssetID)) |
---|
27 | | - | let votingstatus = "F" |
---|
28 | | - | let assetinfopmt2 = fromBase58String(EnterAssetID) |
---|
29 | | - | if ((43 > size(EnterAssetID))) |
---|
30 | | - | then throw("Wrong AssetID is Entered for Voting. Please Enter a Valid AssetID. Probably you entered an AssetID less than 43 Chars.") |
---|
31 | | - | else if ((29 >= days)) |
---|
32 | | - | then throw("Enter no. of days in between 30 to 90.") |
---|
33 | | - | else if ((days > maximumvotingdays)) |
---|
34 | | - | then throw("You Entered days greater than 90 please Enter no. of days in between 1 to 90.") |
---|
35 | | - | else if ((fetchpair == EnterAssetID)) |
---|
36 | | - | then throw("Pair Already Exist in Voting List.") |
---|
37 | | - | else if ((size(i.payments) != 2)) |
---|
38 | | - | then throw("Two attached assets expected as payment. Kindly Attach payment1 = CODE Token & payment2 = Token you want to List for Voting.") |
---|
39 | | - | else if ((pmt1.assetId != CODEAssetID)) |
---|
40 | | - | then throw("Incorrect asset attached for Voting in payment[1], please attach 2000 CODE Token only.") |
---|
41 | | - | else if ((pmt1.amount != 10000000)) |
---|
42 | | - | then throw((((("You attached only " + toString(fraction(pmt1.amount, 1, 100000000))) + ".") + toString(fraction(pmt1.amount, 1, 10000000))) + " CODE for Voting in payment[1], please attach 2000 CODE Token.")) |
---|
43 | | - | else if ((pmt2.assetId != assetinfopmt2)) |
---|
44 | | - | then throw("Input String & Attached AssetID in payment2 is not matching.") |
---|
45 | | - | else if ((TN == true)) |
---|
46 | | - | then throw("You Attached TN Asset ID for Voting, please attach fsTN instead of TN or Token You want to list in payment[2].") |
---|
47 | | - | else [StringEntry(("Pair_UV_" + EnterAssetID), EnterAssetID), StringEntry(("Voting_Status_" + EnterAssetID), votingstatus), IntegerEntry(("Voting_SH_" + EnterAssetID), height), IntegerEntry(("Voting_EH_" + EnterAssetID), votingExpire), IntegerEntry(("Voting_Period_" + EnterAssetID), NoOfDaysBlocks), IntegerEntry(("Listing_Fee_" + EnterAssetID), pmt1.amount), IntegerEntry(("Votes_Req_" + EnterAssetID), (votesrequired / 3)), IntegerEntry(("Votes_Rcvd_" + EnterAssetID), 0), ScriptTransfer(CollectCODEFeeAddress, pmt1.amount, CODEAssetID)] |
---|
| 39 | + | func SetPreSaleParameters (Presale_Start_TimeStamp,Presale_End_TimeStamp,Token_Price,Soft_Cap_Amount,Hard_Cap_Amount,Allow_Refund) = { |
---|
| 40 | + | let StartTS = Presale_Start_TimeStamp |
---|
| 41 | + | let EndTS = Presale_End_TimeStamp |
---|
| 42 | + | let read_funding_round = match getInteger(this, "Current_Funding_Round") { |
---|
| 43 | + | case a: Int => |
---|
| 44 | + | a |
---|
| 45 | + | case _ => |
---|
| 46 | + | 0 |
---|
| 47 | + | } |
---|
| 48 | + | let current_round = (read_funding_round + 1) |
---|
| 49 | + | if ((i.caller != controller_address)) |
---|
| 50 | + | then throw((("This Address is not Authorized. Only " + toString(controller_address)) + " is Authorized Address to Sign it.")) |
---|
| 51 | + | else if ((lastBlock.timestamp > Presale_Start_TimeStamp)) |
---|
| 52 | + | then throw(expiredtserror) |
---|
| 53 | + | else if ((size(toString(Presale_Start_TimeStamp)) != 13)) |
---|
| 54 | + | then throw("Start Timestamp is Wrong. Please Enter a Valid Timestamp. Probably you entered an Timestamp less than 13 Chars.") |
---|
| 55 | + | else if ((size(toString(Presale_End_TimeStamp)) != 13)) |
---|
| 56 | + | then throw("End Timestamp is Wrong. Please Enter a Valid Timestamp. Probably you entered an Timestamp less than 13 Chars.") |
---|
| 57 | + | else if ((1 > Token_Price)) |
---|
| 58 | + | then throw(priceerror) |
---|
| 59 | + | else if ((StartTS >= EndTS)) |
---|
| 60 | + | then throw(tserror) |
---|
| 61 | + | else if ((Soft_Cap_Amount > Hard_Cap_Amount)) |
---|
| 62 | + | then throw(caperror) |
---|
| 63 | + | else [IntegerEntry("Current_Funding_Round", current_round), IntegerEntry((toString(current_round) + "_Presale_Start_TimeStamp"), StartTS), IntegerEntry((toString(current_round) + "_Presale_End_TimeStamp"), EndTS), IntegerEntry((toString(current_round) + "_Token_Price"), Token_Price), IntegerEntry((toString(current_round) + "_Soft_Cap_Amount"), Soft_Cap_Amount), IntegerEntry((toString(current_round) + "_Hard_Cap_Amount"), Hard_Cap_Amount), IntegerEntry((toString(current_round) + "_Initiated_Height"), height), BooleanEntry((toString(current_round) + "_Allow_Refund"), Allow_Refund), StringEntry("message", presale_init_msg)] |
---|
77 | | - | let individualvotescount = (individualvotes + pmt.amount) |
---|
78 | | - | let checkwhitelist = (checkvotesreceived >= checkvotesrequired) |
---|
79 | | - | let info = valueOrErrorMessage(assetInfo(fromBase58String(EnterAssetID)), (("Asset " + EnterAssetID) + " doesn't exist")) |
---|
80 | | - | if ((checkpairisavailableornot != EnterAssetID)) |
---|
81 | | - | then throw("Pair is not available in Voting List.") |
---|
82 | | - | else if ((height > checkendheight)) |
---|
83 | | - | then throw((("Voting timeline for " + EnterAssetID) + " is expired.")) |
---|
84 | | - | else if ((pmt.assetId != CODEAssetID)) |
---|
85 | | - | then throw((("Kindly Attach Only " + toBase58String(CODEAssetID)) + " Token.")) |
---|
86 | | - | else if ((VotingStatus == NewVotingStatus)) |
---|
87 | | - | then throw((("Voting for " + EnterAssetID) + " pair is completed & it’s available in whitelist.")) |
---|
88 | | - | else if (checkwhitelist) |
---|
89 | | - | then [StringEntry(("Voting_Status_" + EnterAssetID), NewVotingStatus), IntegerEntry(((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID)), 0), IntegerEntry(((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID), 0), IntegerEntry(("Total_of_Pair_Txns_" + EnterAssetID), 0), IntegerEntry(((("Total_Swap_Fee_Collected_" + EnterAssetID) + "_") + toBase58String(USDTAssetID)), 0), IntegerEntry(("Total_Swap_Fee_Collected_" + EnterAssetID), 0), IntegerEntry(((("Votes_Rcvd_" + calleraddress) + "_") + EnterAssetID), individualvotescount)] |
---|
90 | | - | else [IntegerEntry(("Votes_Rcvd_" + EnterAssetID), newvotescount), IntegerEntry(((("Votes_Rcvd_" + calleraddress) + "_") + EnterAssetID), individualvotescount)] |
---|
| 94 | + | let total_auto_withdraw_txns = (read_auto_withdraw_txns + 1) |
---|
| 95 | + | let read_total_txns = match getInteger(this, (toString(Enter_Presale_Round) + "_total_txns")) { |
---|
| 96 | + | case a: Int => |
---|
| 97 | + | a |
---|
| 98 | + | case _ => |
---|
| 99 | + | 0 |
---|
| 100 | + | } |
---|
| 101 | + | let total_txns = (read_total_txns + 1) |
---|
| 102 | + | let read_user_total_funds_deposited = match getInteger(this, ((toString(Enter_Presale_Round) + "_") + currentKey)) { |
---|
| 103 | + | case a: Int => |
---|
| 104 | + | a |
---|
| 105 | + | case _ => |
---|
| 106 | + | 0 |
---|
| 107 | + | } |
---|
| 108 | + | let user_total_funds_deposited = (read_user_total_funds_deposited + pmt.amount) |
---|
| 109 | + | let pending_softcap_status = (read_Soft_Cap_Amount - total_funds_collection) |
---|
| 110 | + | let pending_hardcap_status = (read_Hard_Cap_Amount - total_funds_collection) |
---|
| 111 | + | if (isDefined(pmt.assetId)) |
---|
| 112 | + | then throw(pymterror) |
---|
| 113 | + | else if ((read_round_token_price > pmt.amount)) |
---|
| 114 | + | then throw((((orderpymterror + "[") + toString(read_round_token_price)) + "/10^8.]")) |
---|
| 115 | + | else if ((read_round_start_ts > lastBlock.timestamp)) |
---|
| 116 | + | then throw((launch_error + toString(read_round_start_ts))) |
---|
| 117 | + | else if ((lastBlock.timestamp > read_round_end_ts)) |
---|
| 118 | + | then throw(presale_end_err) |
---|
| 119 | + | else if (if ((pending_softcap_status > 0)) |
---|
| 120 | + | then (pending_hardcap_status > 0) |
---|
| 121 | + | else false) |
---|
| 122 | + | then [IntegerEntry((toString(Enter_Presale_Round) + "_Funds_Collection"), total_funds_collection), IntegerEntry(((toString(Enter_Presale_Round) + "_") + currentKey), user_total_funds_deposited), IntegerEntry((toString(Enter_Presale_Round) + "_total_auto_withdraw_txns"), read_auto_withdraw_txns), IntegerEntry((toString(Enter_Presale_Round) + "_total_txns"), total_txns), IntegerEntry((toString(Enter_Presale_Round) + "_pending_softcap_status"), pending_softcap_status), IntegerEntry((toString(Enter_Presale_Round) + "_pending_hardcap_status"), pending_hardcap_status), StringEntry((toString(Enter_Presale_Round) + "_softcap_status"), "No"), StringEntry((toString(Enter_Presale_Round) + "_hardcap_status"), "No"), BooleanEntry((toString(Enter_Presale_Round) + "_Allow_Refund"), read_Allow_Refund), StringEntry("message", ordermsg)] |
---|
| 123 | + | else if (if (if ((0 >= pending_softcap_status)) |
---|
| 124 | + | then (pending_hardcap_status > 0) |
---|
| 125 | + | else false) |
---|
| 126 | + | then (total_auto_withdraw_txns == 1) |
---|
| 127 | + | else false) |
---|
| 128 | + | then [IntegerEntry((toString(Enter_Presale_Round) + "_Funds_Collection"), total_funds_collection), IntegerEntry(((toString(Enter_Presale_Round) + "_") + currentKey), user_total_funds_deposited), IntegerEntry((toString(Enter_Presale_Round) + "_total_auto_withdraw_txns"), total_auto_withdraw_txns), IntegerEntry((toString(Enter_Presale_Round) + "_total_txns"), total_txns), IntegerEntry((toString(Enter_Presale_Round) + "_pending_softcap_status"), pending_softcap_status), IntegerEntry((toString(Enter_Presale_Round) + "_pending_hardcap_status"), pending_hardcap_status), StringEntry((toString(Enter_Presale_Round) + "_softcap_status"), "Yes"), StringEntry((toString(Enter_Presale_Round) + "_hardcap_status"), "No"), BooleanEntry((toString(Enter_Presale_Round) + "_Allow_Refund"), false), ScriptTransfer(controller_address, total_funds_collection, unit), StringEntry("message", ordermsg)] |
---|
| 129 | + | else if (if (if ((0 >= pending_softcap_status)) |
---|
| 130 | + | then (pending_hardcap_status > 0) |
---|
| 131 | + | else false) |
---|
| 132 | + | then (total_auto_withdraw_txns > 1) |
---|
| 133 | + | else false) |
---|
| 134 | + | then [IntegerEntry((toString(Enter_Presale_Round) + "_Funds_Collection"), total_funds_collection), IntegerEntry(((toString(Enter_Presale_Round) + "_") + currentKey), user_total_funds_deposited), IntegerEntry((toString(Enter_Presale_Round) + "_total_auto_withdraw_txns"), total_auto_withdraw_txns), IntegerEntry((toString(Enter_Presale_Round) + "_total_txns"), total_txns), IntegerEntry((toString(Enter_Presale_Round) + "_pending_softcap_status"), pending_softcap_status), IntegerEntry((toString(Enter_Presale_Round) + "_pending_hardcap_status"), pending_hardcap_status), StringEntry((toString(Enter_Presale_Round) + "_softcap_status"), "Yes"), StringEntry((toString(Enter_Presale_Round) + "_hardcap_status"), "No"), BooleanEntry((toString(Enter_Presale_Round) + "_Allow_Refund"), false), ScriptTransfer(controller_address, pmt.amount, unit), StringEntry("message", ordermsg)] |
---|
| 135 | + | else if (if (if ((0 >= pending_softcap_status)) |
---|
| 136 | + | then (0 >= pending_hardcap_status) |
---|
| 137 | + | else false) |
---|
| 138 | + | then (total_auto_withdraw_txns == 1) |
---|
| 139 | + | else false) |
---|
| 140 | + | then [IntegerEntry((toString(Enter_Presale_Round) + "_Funds_Collection"), total_funds_collection), IntegerEntry(((toString(Enter_Presale_Round) + "_") + currentKey), user_total_funds_deposited), IntegerEntry((toString(Enter_Presale_Round) + "_total_auto_withdraw_txns"), total_auto_withdraw_txns), IntegerEntry((toString(Enter_Presale_Round) + "_total_txns"), total_txns), IntegerEntry((toString(Enter_Presale_Round) + "_pending_softcap_status"), pending_softcap_status), IntegerEntry((toString(Enter_Presale_Round) + "_pending_hardcap_status"), pending_hardcap_status), StringEntry((toString(Enter_Presale_Round) + "_softcap_status"), "Yes"), StringEntry((toString(Enter_Presale_Round) + "_hardcap_status"), "Yes"), BooleanEntry((toString(Enter_Presale_Round) + "_Allow_Refund"), false), ScriptTransfer(controller_address, total_funds_collection, unit), StringEntry("message", ordermsg)] |
---|
| 141 | + | else if (if (if ((0 >= pending_softcap_status)) |
---|
| 142 | + | then (0 >= pending_hardcap_status) |
---|
| 143 | + | else false) |
---|
| 144 | + | then (total_auto_withdraw_txns > 1) |
---|
| 145 | + | else false) |
---|
| 146 | + | then [IntegerEntry((toString(Enter_Presale_Round) + "_Funds_Collection"), total_funds_collection), IntegerEntry(((toString(Enter_Presale_Round) + "_") + currentKey), user_total_funds_deposited), IntegerEntry((toString(Enter_Presale_Round) + "_total_auto_withdraw_txns"), total_auto_withdraw_txns), IntegerEntry((toString(Enter_Presale_Round) + "_total_txns"), total_txns), IntegerEntry((toString(Enter_Presale_Round) + "_pending_softcap_status"), pending_softcap_status), IntegerEntry((toString(Enter_Presale_Round) + "_pending_hardcap_status"), pending_hardcap_status), StringEntry((toString(Enter_Presale_Round) + "_softcap_status"), "Yes"), StringEntry((toString(Enter_Presale_Round) + "_hardcap_status"), "Yes"), BooleanEntry((toString(Enter_Presale_Round) + "_Allow_Refund"), false), ScriptTransfer(controller_address, pmt.amount, unit), StringEntry("message", ordermsg)] |
---|
| 147 | + | else throw("Error.") |
---|
96 | | - | func WithdrawVotedTokens (EnterAssetID) = { |
---|
97 | | - | let pmt = if ((size(i.payments) == 1)) |
---|
98 | | - | then i.payments[0] |
---|
99 | | - | else throw("0.1 TN Token is required as Attached payment.") |
---|
100 | | - | let calleraddress = toBase58String(i.caller.bytes) |
---|
101 | | - | let checkendheight = getIntegerValue(this, ("Voting_EH_" + EnterAssetID)) |
---|
102 | | - | let checkpairisavailableornot = getString(this, ("Pair_UV_" + EnterAssetID)) |
---|
103 | | - | let checkuservotingbalance = valueOrErrorMessage(getInteger(this, ((("Votes_Rcvd_" + calleraddress) + "_") + EnterAssetID)), (calleraddress + " Address never voted & exist in list.")) |
---|
104 | | - | let pendingblocksforprojectexpire = (checkendheight - height) |
---|
105 | | - | if ((checkpairisavailableornot != EnterAssetID)) |
---|
106 | | - | then throw("Pair is not available in Voting List.") |
---|
107 | | - | else if ((checkendheight > height)) |
---|
108 | | - | then throw((("Voting Already Running. You can withdraw your CODE Token after " + toString(pendingblocksforprojectexpire)) + " blocks")) |
---|
109 | | - | else if ((0 >= checkuservotingbalance)) |
---|
110 | | - | then throw("You don't have any dues of CODE balance in this Voting Pair.") |
---|
111 | | - | else if (isDefined(pmt.assetId)) |
---|
112 | | - | then throw("Don't attach any other asset. Please attach 0.1 TN as a fee to release your token") |
---|
113 | | - | else if ((pmt.amount != 10000000)) |
---|
114 | | - | then throw("Please attach 0.1 TN as a fee to release your token.") |
---|
115 | | - | else [IntegerEntry(((("Votes_Rcvd_" + calleraddress) + "_") + EnterAssetID), 0), ScriptTransfer(i.caller, checkuservotingbalance, CODEAssetID)] |
---|
| 153 | + | func Refund (Enter_Presale_Round) = { |
---|
| 154 | + | let WAVES = unit |
---|
| 155 | + | let currentKey = toBase58String(i.caller.bytes) |
---|
| 156 | + | let read_Initiated_Height = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Initiated_Height")), "Initiated Height not Found for this Presale Round.") |
---|
| 157 | + | let read_round_token_price = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Token_Price")), "Token Price not Found for this Presale Round.") |
---|
| 158 | + | let read_round_start_ts = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Presale_Start_TimeStamp")), "Start Timestamp not Found for this Presale Round.") |
---|
| 159 | + | let read_round_end_ts = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Presale_End_TimeStamp")), "End Timestamp not Found for this Presale Round.") |
---|
| 160 | + | let read_Soft_Cap_Amount = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Soft_Cap_Amount")), "Soft Cap Amount not Found for this Presale Round.") |
---|
| 161 | + | let read_Hard_Cap_Amount = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Hard_Cap_Amount")), "Hard Cap Amount not Found for this Presale Round.") |
---|
| 162 | + | let read_total_funds_collection = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Funds_Collection")), "Total Funds Collection not Found for this Presale Round.") |
---|
| 163 | + | let read_user_total_funds_deposited = valueOrErrorMessage(getInteger(this, ((toString(Enter_Presale_Round) + "_") + currentKey)), "No Deposit was made by this Address for this Presale Round.") |
---|
| 164 | + | let read_Allow_Refund = valueOrErrorMessage(getBoolean(this, (toString(Enter_Presale_Round) + "_Allow_Refund")), "Allow_Refund has no Boolen Entry for this Presale Round.") |
---|
| 165 | + | let pending_softcap_status = (read_Soft_Cap_Amount - read_total_funds_collection) |
---|
| 166 | + | let pending_hardcap_status = (read_Hard_Cap_Amount - read_total_funds_collection) |
---|
| 167 | + | let milliseconds = 1000 |
---|
| 168 | + | let minute = (60 * milliseconds) |
---|
| 169 | + | let round_time_difference = (read_round_end_ts - read_round_start_ts) |
---|
| 170 | + | let additional_safe_blocks = 10 |
---|
| 171 | + | let blockstimetomature = ((read_Initiated_Height + fraction(round_time_difference, 1, minute)) + additional_safe_blocks) |
---|
| 172 | + | let pending_refunds = (read_total_funds_collection - read_user_total_funds_deposited) |
---|
| 173 | + | if ((blockstimetomature > lastBlock.height)) |
---|
| 174 | + | then throw((((presale_not_end_err + " Please Wait Until ~") + toString(blockstimetomature)) + " Height is reached.")) |
---|
| 175 | + | else if ((read_Allow_Refund == false)) |
---|
| 176 | + | then throw(refund_err) |
---|
| 177 | + | else if ((read_user_total_funds_deposited == 0)) |
---|
| 178 | + | then throw("Refund has been Already Claimed by this Address.") |
---|
| 179 | + | else if (if ((pending_softcap_status > 0)) |
---|
| 180 | + | then (pending_hardcap_status > 0) |
---|
| 181 | + | else false) |
---|
| 182 | + | then [ScriptTransfer(addressFromStringValue(currentKey), read_user_total_funds_deposited, WAVES), IntegerEntry(((toString(Enter_Presale_Round) + "_") + "Pending_Refund"), pending_refunds), IntegerEntry(((toString(Enter_Presale_Round) + "_") + currentKey), 0), StringEntry("message", refund_init_msg)] |
---|
| 183 | + | else if (if ((0 >= pending_softcap_status)) |
---|
| 184 | + | then (pending_hardcap_status > 0) |
---|
| 185 | + | else false) |
---|
| 186 | + | then throw("SoftCap Already Reached for this Round. Please Click on 'Claim Tokens' Function to Receive Your Tokens.") |
---|
| 187 | + | else if (if ((0 >= pending_softcap_status)) |
---|
| 188 | + | then (0 >= pending_hardcap_status) |
---|
| 189 | + | else false) |
---|
| 190 | + | then throw("SoftCap and Hard Already Reached for this Round. Please Click on Claim to Receive Your Tokens.") |
---|
| 191 | + | else throw("Wrong Entry Found.") |
---|
121 | | - | func IssueLPToken (EnterAssetID) = { |
---|
122 | | - | let adminrights = valueOrErrorMessage(getString(this, "LP_Admin_Rights"), "LP Admin Rights are Not Included into Smart Contract. Deploy Admin Rights First.") |
---|
123 | | - | let calleraddress = toBase58String(i.caller.bytes) |
---|
124 | | - | let checkpairisavailableornot = valueOrErrorMessage(getString(this, ("Pair_UV_" + EnterAssetID)), "Asset not Found in Whitelisted Token") |
---|
125 | | - | let info = valueOrErrorMessage(assetInfo(fromBase58String(EnterAssetID)), (("Asset " + EnterAssetID) + " doesn't exist")) |
---|
126 | | - | let name = info.name |
---|
127 | | - | let decimals = info.decimals |
---|
128 | | - | let NewVotingStatus = "P" |
---|
129 | | - | let VotingStatus = valueOrErrorMessage(getString(this, ("Voting_Status_" + EnterAssetID)), ("Voting Status is Missing for " + EnterAssetID)) |
---|
130 | | - | let LPissue = Issue((("LP-" + take(name, 8)) + "-USDT"), (((("LP-" + name) + "-USDT") + " is a Liquidity Provider Token Issued Against ") + EnterAssetID), (1 * pow(10, 0, fraction((decimals + 6), 1, 2), 0, 0, UP)), fraction((decimals + 6), 1, 2), true) |
---|
131 | | - | let LPid = calculateAssetId(LPissue) |
---|
132 | | - | if ((adminrights != calleraddress)) |
---|
133 | | - | then throw((("Your are not allowded to Issue LP Token. Only " + adminrights) + " can issue the LP Token.")) |
---|
134 | | - | else if ((checkpairisavailableornot != EnterAssetID)) |
---|
135 | | - | then throw("Pair is not available in Voting List.") |
---|
136 | | - | else if ((VotingStatus != NewVotingStatus)) |
---|
137 | | - | then throw("LP Token must be a Whitelisted Token.") |
---|
138 | | - | else [LPissue, StringEntry(("LP_" + EnterAssetID), toBase58String(LPid))] |
---|
| 197 | + | func Claim_Tokens (Enter_Presale_Round) = { |
---|
| 198 | + | let currentKey = toBase58String(i.caller.bytes) |
---|
| 199 | + | let scale = 100000000 |
---|
| 200 | + | let read_soft_cap_status = valueOrErrorMessage(getString(this, (toString(Enter_Presale_Round) + "_softcap_status")), "SoftCap Status not Found for this Presale Round.") |
---|
| 201 | + | let read_hard_cap_status = valueOrErrorMessage(getString(this, (toString(Enter_Presale_Round) + "_hardcap_status")), "HardCap Status not Found for this Presale Round.") |
---|
| 202 | + | let read_round_token_price = valueOrErrorMessage(getInteger(this, (toString(Enter_Presale_Round) + "_Token_Price")), "Token Price not Found for this Presale Round.") |
---|
| 203 | + | let read_user_total_funds_deposited = valueOrErrorMessage(getInteger(this, ((toString(Enter_Presale_Round) + "_") + currentKey)), "No Deposit was made by this Address for this Presale Round.") |
---|
| 204 | + | let calculate_total_tokens = fraction(read_user_total_funds_deposited, scale, read_round_token_price) |
---|
| 205 | + | let user_tokens_claim_amount = fraction(read_user_total_funds_deposited, scale, read_round_token_price) |
---|
| 206 | + | let read_total_tokens_claimed = match getInteger(this, (toString(Enter_Presale_Round) + "_Tokens_Claimed")) { |
---|
| 207 | + | case a: Int => |
---|
| 208 | + | a |
---|
| 209 | + | case _ => |
---|
| 210 | + | 0 |
---|
| 211 | + | } |
---|
| 212 | + | let total_tokens_claimed = (read_total_tokens_claimed + user_tokens_claim_amount) |
---|
| 213 | + | let pending_tokens_claimed = (calculate_total_tokens - user_tokens_claim_amount) |
---|
| 214 | + | if ((read_soft_cap_status == "No")) |
---|
| 215 | + | then throw("No Tokens Claim,as SoftCap Amount didn't reach numbers for this Round.") |
---|
| 216 | + | else if (if ((read_soft_cap_status == "Yes")) |
---|
| 217 | + | then true |
---|
| 218 | + | else (read_hard_cap_status == "Yes")) |
---|
| 219 | + | then [IntegerEntry((toString(Enter_Presale_Round) + "_Tokens_Claimed"), total_tokens_claimed), IntegerEntry((toString(Enter_Presale_Round) + "_Pending_Tokens_To_Claim"), pending_tokens_claimed), ScriptTransfer(addressFromStringValue(currentKey), user_tokens_claim_amount, BML_TokenID)] |
---|
| 220 | + | else throw("Wrong Entry Found.") |
---|
144 | | - | func SwapAssetToUSDTPairEntry (EnterAssetID) = { |
---|
145 | | - | let calleraddress = toBase58String(i.caller.bytes) |
---|
146 | | - | let pmt = if ((size(i.payments) == 1)) |
---|
147 | | - | then i.payments[0] |
---|
148 | | - | else throw("Whitelisted Token is required as Attached payment[1].") |
---|
149 | | - | let checkpairisavailableornot = getString(this, ("Pair_UV_" + EnterAssetID)) |
---|
150 | | - | let VotingStatus = getStringValue(this, ("Voting_Status_" + EnterAssetID)) |
---|
151 | | - | let CheckUSDTBalance = getIntegerValue(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) |
---|
152 | | - | let CheckAssetBalance = getIntegerValue(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) |
---|
153 | | - | let newbalanceofUSDT = fraction(CheckUSDTBalance, CheckAssetBalance, (CheckAssetBalance + pmt.amount)) |
---|
154 | | - | let quantityofpriceasset = (CheckUSDTBalance - newbalanceofUSDT) |
---|
155 | | - | let CurrentVotingStatus = "F" |
---|
156 | | - | let SwapFee = 3 |
---|
157 | | - | let SwapFeetoreceive = ((quantityofpriceasset * SwapFee) / 1000) |
---|
158 | | - | let userbalancetoreceive = (quantityofpriceasset - SwapFeetoreceive) |
---|
159 | | - | let SumupofAssetToUSDTSwapFee = match getInteger(this, ((("Total_Swap_Fee_Collected_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) { |
---|
160 | | - | case a: Int => |
---|
161 | | - | a |
---|
162 | | - | case _ => |
---|
163 | | - | 0 |
---|
164 | | - | } |
---|
165 | | - | let NewSumupofAssetToUSDTSwapFee = (SumupofAssetToUSDTSwapFee + SwapFeetoreceive) |
---|
166 | | - | let SumupAssetBalance = match getInteger(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) { |
---|
167 | | - | case a: Int => |
---|
168 | | - | a |
---|
169 | | - | case _ => |
---|
170 | | - | 0 |
---|
171 | | - | } |
---|
172 | | - | let NewSumupofAssetBalance = (CheckAssetBalance + pmt.amount) |
---|
173 | | - | let SumupUSDTBalance = match getInteger(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) { |
---|
174 | | - | case a: Int => |
---|
175 | | - | a |
---|
176 | | - | case _ => |
---|
177 | | - | 0 |
---|
178 | | - | } |
---|
179 | | - | let NewSumupofUSDTBalance = (CheckUSDTBalance - quantityofpriceasset) |
---|
180 | | - | let TOPT = match getIntegerValue(this, ("Total_of_Pair_Txns_" + EnterAssetID)) { |
---|
181 | | - | case a: Int => |
---|
182 | | - | a |
---|
183 | | - | case _ => |
---|
184 | | - | 0 |
---|
185 | | - | } |
---|
186 | | - | let NewTPT = (TOPT + 1) |
---|
187 | | - | if ((EnterAssetID == toBase58String(USDTAssetID))) |
---|
188 | | - | then throw("Input can Never be a USDT AssetID. Enter Whitelisted AssetID in input & Attach Whitelisted Asset as an attachment Token in payment[1].") |
---|
189 | | - | else if ((checkpairisavailableornot != EnterAssetID)) |
---|
190 | | - | then throw("Pair is not available in Whitelisted Asset.") |
---|
191 | | - | else if ((VotingStatus == CurrentVotingStatus)) |
---|
192 | | - | then throw((EnterAssetID + " is not A Whitelisted Token Yet.")) |
---|
193 | | - | else if ((pmt.assetId == USDTAssetID)) |
---|
194 | | - | then throw("You can't Attach USDT as an Attached Payment. Only Whitelisted Tokens are accepted.") |
---|
195 | | - | else if ((pmt.assetId != fromBase58String(EnterAssetID))) |
---|
196 | | - | then throw(("Incorrect asset attached, please attach or send " + EnterAssetID)) |
---|
197 | | - | else if ((CheckUSDTBalance == 0)) |
---|
198 | | - | then throw("Swap Pair Need to Add Liquidity first into Pool. Only After that Pair will be activated for Swapping.") |
---|
199 | | - | else if ((CheckAssetBalance == 0)) |
---|
200 | | - | then throw("Swap Pair Need to Add Liquidity first into Pool. Only After that Pair will be activated for Swapping.") |
---|
201 | | - | else if ((10000000 > quantityofpriceasset)) |
---|
202 | | - | then throw((("Your Attached Asset Amount is very low. Attach More " + EnterAssetID) + " Tokens to Claim the minimum Amount of 10 dollar atleast.")) |
---|
203 | | - | else if ((quantityofpriceasset > CheckUSDTBalance)) |
---|
204 | | - | then throw((("Pool Only has a Liquidity of " + toString((CheckUSDTBalance / pow(10, 0, 6, 0, 0, UP)))) + " USDT. Add Liquidity into Pool.")) |
---|
205 | | - | else [IntegerEntry(((("Total_Swap_Fee_Collected_" + EnterAssetID) + "_") + toBase58String(USDTAssetID)), NewSumupofAssetToUSDTSwapFee), IntegerEntry(("Total_of_Pair_Txns_" + EnterAssetID), NewTPT), IntegerEntry(((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID), NewSumupofAssetBalance), IntegerEntry(((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID)), NewSumupofUSDTBalance), ScriptTransfer(i.caller, userbalancetoreceive, USDTAssetID), ScriptTransfer(CollectUSDTSwapFeeAddress, SwapFeetoreceive, USDTAssetID)] |
---|
| 226 | + | func Mint_BML (TokenName,TokenDescription) = { |
---|
| 227 | + | let asset = Issue(TokenName, TokenDescription, 1, 8, true) |
---|
| 228 | + | let assetId = calculateAssetId(asset) |
---|
| 229 | + | if ((i.caller != controller_address)) |
---|
| 230 | + | then throw((("This Address is not Authorized. Only " + toString(controller_address)) + " is Authorized Address to Sign it.")) |
---|
| 231 | + | else [asset, StringEntry("BML_TokenID", toBase58String(assetId)), Burn(assetId, 1)] |
---|
209 | | - | |
---|
210 | | - | @Callable(i) |
---|
211 | | - | func SwapUSDTToAssetPairEntry (EnterAssetID) = { |
---|
212 | | - | let calleraddress = toBase58String(i.caller.bytes) |
---|
213 | | - | let pmt = if ((size(i.payments) == 1)) |
---|
214 | | - | then i.payments[0] |
---|
215 | | - | else throw("Only USDT Token is required as an Attached payment[1].") |
---|
216 | | - | let CheckUSDTBalance = getIntegerValue(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) |
---|
217 | | - | let CheckAssetBalance = getIntegerValue(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) |
---|
218 | | - | let newbalanceofAsset = fraction(CheckUSDTBalance, CheckAssetBalance, (CheckUSDTBalance + pmt.amount)) |
---|
219 | | - | let quantityofpriceasset = (CheckAssetBalance - newbalanceofAsset) |
---|
220 | | - | let checkpairisavailableornot = getString(this, ("Pair_UV_" + EnterAssetID)) |
---|
221 | | - | let VotingStatus = getStringValue(this, ("Voting_Status_" + EnterAssetID)) |
---|
222 | | - | let CurrentVotingStatus = "F" |
---|
223 | | - | let SwapFee = 3 |
---|
224 | | - | let SwapFeetoreceive = ((quantityofpriceasset * SwapFee) / 1000) |
---|
225 | | - | let userbalancetoreceive = (quantityofpriceasset - SwapFeetoreceive) |
---|
226 | | - | let SumupofUSDTToAssetSwapFee = match getInteger(this, ("Total_Swap_Fee_Collected_" + EnterAssetID)) { |
---|
227 | | - | case a: Int => |
---|
228 | | - | a |
---|
229 | | - | case _ => |
---|
230 | | - | 0 |
---|
231 | | - | } |
---|
232 | | - | let NewSumupofUSDTToAssetSwapFee = (SumupofUSDTToAssetSwapFee + SwapFeetoreceive) |
---|
233 | | - | let SumupAssetBalance = match getInteger(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) { |
---|
234 | | - | case a: Int => |
---|
235 | | - | a |
---|
236 | | - | case _ => |
---|
237 | | - | 0 |
---|
238 | | - | } |
---|
239 | | - | let NewSumupofAssetBalance = (CheckAssetBalance - quantityofpriceasset) |
---|
240 | | - | let SumupUSDTBalance = match getInteger(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) { |
---|
241 | | - | case a: Int => |
---|
242 | | - | a |
---|
243 | | - | case _ => |
---|
244 | | - | 0 |
---|
245 | | - | } |
---|
246 | | - | let NewSumupofUSDTBalance = (CheckUSDTBalance + pmt.amount) |
---|
247 | | - | let TOPT = match getIntegerValue(this, ("Total_of_Pair_Txns_" + EnterAssetID)) { |
---|
248 | | - | case a: Int => |
---|
249 | | - | a |
---|
250 | | - | case _ => |
---|
251 | | - | 0 |
---|
252 | | - | } |
---|
253 | | - | let NewTPT = (TOPT + 1) |
---|
254 | | - | if ((checkpairisavailableornot != EnterAssetID)) |
---|
255 | | - | then throw("Pair is not available in Whitelisted Asset.") |
---|
256 | | - | else if ((VotingStatus == CurrentVotingStatus)) |
---|
257 | | - | then throw((EnterAssetID + " is not A Whitelisted Token Yet.")) |
---|
258 | | - | else if ((EnterAssetID == toBase58String(USDTAssetID))) |
---|
259 | | - | then throw("Input can Never be a USDT AssetID. Enter Whitelisted AssetID in input & Attach USDT as an attachment Token in payment[1].") |
---|
260 | | - | else if ((pmt.assetId != USDTAssetID)) |
---|
261 | | - | then throw("You can Attach USDT as an Attached Payment[1] to Swap USDT To Required Token. Any other asset else than USDT will be rejected.") |
---|
262 | | - | else if ((10000000 > pmt.amount)) |
---|
263 | | - | then throw("Your Attached USDT Amount is very low. Attach Atleast 10 USDT to Claim the minimum Tokens.") |
---|
264 | | - | else if ((CheckUSDTBalance == 0)) |
---|
265 | | - | then throw("Swap Pair Need to Add Liquidity first into Pool. Only After that Pair will be activated for Swapping.") |
---|
266 | | - | else if ((CheckAssetBalance == 0)) |
---|
267 | | - | then throw("Swap Pair Need to Add Liquidity first into Pool. Only After that Pair will be activated for Swapping.") |
---|
268 | | - | else if ((quantityofpriceasset > CheckAssetBalance)) |
---|
269 | | - | then throw((("Pool Only has a Liquidity of " + toString(CheckAssetBalance)) + " Tokens. Add Liquidity into Pool.")) |
---|
270 | | - | else [IntegerEntry(("Total_Swap_Fee_Collected_" + EnterAssetID), NewSumupofUSDTToAssetSwapFee), IntegerEntry(("Total_of_Pair_Txns_" + EnterAssetID), NewTPT), IntegerEntry(((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID), NewSumupofAssetBalance), IntegerEntry(((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID)), NewSumupofUSDTBalance), ScriptTransfer(i.caller, userbalancetoreceive, fromBase58String(EnterAssetID)), ScriptTransfer(CollectAssetSwapFeeAddress, SwapFeetoreceive, fromBase58String(EnterAssetID))] |
---|
271 | | - | } |
---|
272 | | - | |
---|
273 | | - | |
---|
274 | | - | |
---|
275 | | - | @Callable(i) |
---|
276 | | - | func AddLiquidity (EnterAssetID) = { |
---|
277 | | - | let calleraddress = toBase58String(i.caller.bytes) |
---|
278 | | - | let pmt1 = value(i.payments[0]) |
---|
279 | | - | let pmt2 = value(i.payments[1]) |
---|
280 | | - | let checkpairisavailableornot = getString(this, ("Pair_UV_" + EnterAssetID)) |
---|
281 | | - | let VotingStatus = getStringValue(this, ("Voting_Status_" + EnterAssetID)) |
---|
282 | | - | let ReissueassetId = fromBase58String(valueOrErrorMessage(getString(this, ("LP_" + EnterAssetID)), "LP Token is Missing or May be not Generated.")) |
---|
283 | | - | let CurrentVotingStatus = "F" |
---|
284 | | - | let CheckUSDTBalance = getIntegerValue(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) |
---|
285 | | - | let CheckAssetBalance = getIntegerValue(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) |
---|
286 | | - | let decimalsinfo = valueOrErrorMessage(assetInfo(fromBase58String(EnterAssetID)), (("Asset " + EnterAssetID) + " doesn't exist")) |
---|
287 | | - | let decimals = decimalsinfo.decimals |
---|
288 | | - | let arg1 = pow((CheckUSDTBalance / pow(10, 6, 6, 0, 0, UP)), 0, 1, 0, 0, UP) |
---|
289 | | - | let arg2 = pow((CheckAssetBalance / pow(10, decimals, decimals, 0, 0, UP)), 0, 1, 0, 0, UP) |
---|
290 | | - | let args3 = pow((((arg1 * 1000000) / arg2) * pow(10, 0, decimals, 0, 0, UP)), 0, 1, 0, 0, UP) |
---|
291 | | - | let bothassetsdecimals = (6 + decimals) |
---|
292 | | - | let sharedecimals = (bothassetsdecimals / 2) |
---|
293 | | - | let quantityofEnterAssetID = fraction(args3, pmt1.amount, pow(10, 0, bothassetsdecimals, 0, 0, UP)) |
---|
294 | | - | let quantityofLPToken1 = pow((fraction(pmt1.amount, 1, pow(10, 0, decimals, 0, 0, UP)) * fraction(pmt2.amount, 1, pow(10, 0, 6, 0, 0, UP))), 0, 5, 1, sharedecimals, DOWN) |
---|
295 | | - | let USDTHoldingInPair = match getInteger(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) { |
---|
296 | | - | case a: Int => |
---|
297 | | - | a |
---|
298 | | - | case _ => |
---|
299 | | - | 0 |
---|
300 | | - | } |
---|
301 | | - | let NewUSDTHoldingInPair = (USDTHoldingInPair + pmt2.amount) |
---|
302 | | - | let AssetHoldingInPair = match getInteger(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) { |
---|
303 | | - | case a: Int => |
---|
304 | | - | a |
---|
305 | | - | case _ => |
---|
306 | | - | 0 |
---|
307 | | - | } |
---|
308 | | - | let NewAssetHoldingInPair = (AssetHoldingInPair + pmt1.amount) |
---|
309 | | - | let LPTokenIssued = match getIntegerValue(this, ("Total_LP_" + EnterAssetID)) { |
---|
310 | | - | case a: Int => |
---|
311 | | - | a |
---|
312 | | - | case _ => |
---|
313 | | - | 0 |
---|
314 | | - | } |
---|
315 | | - | let NewLPTokenIssued = (LPTokenIssued + quantityofLPToken1) |
---|
316 | | - | if ((checkpairisavailableornot != EnterAssetID)) |
---|
317 | | - | then throw("Pair is not available in Whitelisted Asset.") |
---|
318 | | - | else if ((VotingStatus == CurrentVotingStatus)) |
---|
319 | | - | then throw((EnterAssetID + " is not A Whitelisted Token Yet.")) |
---|
320 | | - | else if ((EnterAssetID == toBase58String(USDTAssetID))) |
---|
321 | | - | then throw("Input can Never be a USDT AssetID. Enter Whitelisted AssetID in input as well as in payment[1] & Attach USDT as an attachment Token in payment[2].") |
---|
322 | | - | else if ((size(i.payments) != 2)) |
---|
323 | | - | then throw("Two attached assets expected as payment in 50%-50%. Kindly Attach payment1 = Token you want to add for Liquidity & payment2 = Equivalent Amount of USDT Token.") |
---|
324 | | - | else if ((pmt1.assetId == USDTAssetID)) |
---|
325 | | - | then throw("You Attached USDT asset in payment[1], please attach only whitelisted Token in payment[1] along with USDT in payment[2].") |
---|
326 | | - | else if ((pmt1.assetId != fromBase58String(EnterAssetID))) |
---|
327 | | - | then throw("Incorrect asset attached for Liquidity in payment[1], please attach String Asset or Whitelisted Token only.") |
---|
328 | | - | else if ((pmt1.assetId != fromBase58String(EnterAssetID))) |
---|
329 | | - | then throw("Incorrect asset attached for Liquidity in payment[1], please attach String Asset or Whitelisted Token only.") |
---|
330 | | - | else if ((pmt2.assetId != USDTAssetID)) |
---|
331 | | - | then throw("Wrong Asset Attached in payments[2], Please attach payment[1] = Liquidity Token & payment[2] = USDT Token.") |
---|
332 | | - | else if ((10000000 > pmt2.amount)) |
---|
333 | | - | then throw("please attach atleast 10 USDT in payment[2] & Equivalent worth of Token in payment[1]") |
---|
334 | | - | else if ((pmt2.amount != quantityofEnterAssetID)) |
---|
335 | | - | then throw(("Attached payment[2] quantity is not matching as per attached payment[1].payment[2] must be " + toString(quantityofEnterAssetID))) |
---|
336 | | - | else [IntegerEntry(((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID)), NewUSDTHoldingInPair), IntegerEntry(((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID), NewAssetHoldingInPair), IntegerEntry(("Total_LP_" + EnterAssetID), NewLPTokenIssued), Reissue(ReissueassetId, quantityofLPToken1, true), ScriptTransfer(i.caller, quantityofLPToken1, ReissueassetId)] |
---|
337 | | - | } |
---|
338 | | - | |
---|
339 | | - | |
---|
340 | | - | |
---|
341 | | - | @Callable(i) |
---|
342 | | - | func RemoveLiquidity (EnterAssetID) = { |
---|
343 | | - | let calleraddress = toBase58String(i.caller.bytes) |
---|
344 | | - | let pmt = if ((size(i.payments) == 1)) |
---|
345 | | - | then i.payments[0] |
---|
346 | | - | else throw("No payment attached, Please Attach LP Token as payment[1].") |
---|
347 | | - | let checkpairisavailableornot = getString(this, ("Pair_UV_" + EnterAssetID)) |
---|
348 | | - | let VotingStatus = getStringValue(this, ("Voting_Status_" + EnterAssetID)) |
---|
349 | | - | let ReissueableassetId = fromBase58String(valueOrErrorMessage(getString(this, ("LP_" + EnterAssetID)), "LP Token is Missing or not Generated.")) |
---|
350 | | - | let CurrentVotingStatus = "F" |
---|
351 | | - | let CheckUSDTBalance = getIntegerValue(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) |
---|
352 | | - | let CheckAssetBalance = getIntegerValue(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) |
---|
353 | | - | let decimalsinfo = valueOrErrorMessage(assetInfo(fromBase58String(EnterAssetID)), (("Asset " + EnterAssetID) + " doesn't exist")) |
---|
354 | | - | let decimals = decimalsinfo.decimals |
---|
355 | | - | let arg1 = pow((CheckUSDTBalance / pow(10, 6, 6, 0, 0, UP)), 0, 1, 0, 0, UP) |
---|
356 | | - | let arg2 = pow((CheckAssetBalance / pow(10, decimals, decimals, 0, 0, UP)), 0, 1, 0, 0, UP) |
---|
357 | | - | let args3 = pow((((arg1 * 1000000) / arg2) * pow(10, 0, decimals, 0, 0, UP)), 0, 1, 0, 0, UP) |
---|
358 | | - | let bothassetsdecimals = (6 + decimals) |
---|
359 | | - | let sharedecimals = (bothassetsdecimals / 2) |
---|
360 | | - | let SquareofAttachedPymt = fraction(pow(pmt.amount, sharedecimals, 2, 0, 6, HALFUP), 1, fraction(args3, 1, pow(10, 0, 6, 0, 0, UP))) |
---|
361 | | - | let SqrtofAttachPymt = pow(SquareofAttachedPymt, 0, 5, 1, sharedecimals, DOWN) |
---|
362 | | - | let UserLPWorth = fraction(args3, SqrtofAttachPymt, pow(10, 0, bothassetsdecimals, 0, 0, UP)) |
---|
363 | | - | let USDTHoldingInPair = match getInteger(this, ((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID))) { |
---|
364 | | - | case a: Int => |
---|
365 | | - | a |
---|
366 | | - | case _ => |
---|
367 | | - | 0 |
---|
368 | | - | } |
---|
369 | | - | let NewUSDTHoldingInPair = (USDTHoldingInPair - UserLPWorth) |
---|
370 | | - | let AssetHoldingInPair = match getInteger(this, ((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID)) { |
---|
371 | | - | case a: Int => |
---|
372 | | - | a |
---|
373 | | - | case _ => |
---|
374 | | - | 0 |
---|
375 | | - | } |
---|
376 | | - | let NewAssetHoldingInPair = (AssetHoldingInPair - SqrtofAttachPymt) |
---|
377 | | - | let LPTokenIssued = match getIntegerValue(this, ("Total_LP_" + EnterAssetID)) { |
---|
378 | | - | case a: Int => |
---|
379 | | - | a |
---|
380 | | - | case _ => |
---|
381 | | - | 0 |
---|
382 | | - | } |
---|
383 | | - | let NewLPTokenIssued = (LPTokenIssued - pmt.amount) |
---|
384 | | - | if ((checkpairisavailableornot != EnterAssetID)) |
---|
385 | | - | then throw("Pair is not available in Whitelist.") |
---|
386 | | - | else if ((VotingStatus == CurrentVotingStatus)) |
---|
387 | | - | then throw((EnterAssetID + " is not A Whitelist Token Yet.")) |
---|
388 | | - | else if ((fromBase58String(EnterAssetID) == USDTAssetID)) |
---|
389 | | - | then throw("Don't choose USDT AssetID as Input, Only Whitelisted Asset as Input String & Attach LP Tokens as payment[1]") |
---|
390 | | - | else if ((pmt.assetId != ReissueableassetId)) |
---|
391 | | - | then throw("Wrong Asset is attached in payment[1] or LP Token Not Found or Missing.") |
---|
392 | | - | else [Burn(ReissueableassetId, pmt.amount), IntegerEntry(("Total_LP_" + EnterAssetID), NewLPTokenIssued), IntegerEntry(((("Balance_of_" + EnterAssetID) + "_") + toBase58String(USDTAssetID)), NewUSDTHoldingInPair), IntegerEntry(((("Balance_of_" + toBase58String(USDTAssetID)) + "_") + EnterAssetID), NewAssetHoldingInPair), ScriptTransfer(i.caller, UserLPWorth, USDTAssetID), ScriptTransfer(i.caller, SqrtofAttachPymt, fromBase58String(EnterAssetID))] |
---|
393 | | - | } |
---|
394 | | - | |
---|
395 | | - | |
---|
396 | | - | |
---|
397 | | - | @Callable(i) |
---|
398 | | - | func RemoveEntry (Key,Key1,Key2,Key3) = [DeleteEntry(Key), DeleteEntry(Key1), DeleteEntry(Key2), DeleteEntry(Key3)] |
---|
399 | | - | |
---|
400 | | - | |
---|