Advertisement
Guest User

Untitled

a guest
Mar 29th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.13 KB | None | 0 0
  1. <?php
  2. /* Configs */
  3. $apiKey = "ckey_6af14f29d69f44e28f698ccf9b9";
  4. $chain = 56;
  5. $walletAddress = "0xbc57af7dc48201cc1792fff04dba5fe3c3d59210";
  6. $toSearchFor = "0xe9e7cea3dedca5984780bafc599bd69add087d56";
  7. $contractAddress = "0x5f2172b64a33f423bc7f0c48c23f7d3008f7e4fe";
  8. /* Configs */
  9.  
  10. $contractJson = file_get_contents('https://api.covalenthq.com/v1/'.$chain.'/address/'.$walletAddress.'/balances_v2/?key='.$apiKey);
  11.  
  12. $contractResult = json_decode($contractJson);
  13. $contractData = $contractResult->data;
  14. $contractsFound = $contractData->items;
  15.  
  16. $selectedContract = findContract($toSearchFor, $contractsFound);
  17.  
  18. $miningBalance = $selectedContract->balance;
  19.  
  20. $holdersJson = file_get_contents('https://api.covalenthq.com/v1/'.$chain.'/tokens/'.$contractAddress.'/token_holders/?key='.$apiKey.'&page-size=104');
  21. $holdersResult = json_decode($holdersJson);
  22. $holdersData = $holdersResult->data;
  23. $holdersFound = $holdersData->items;
  24.  
  25. function findContract($contract, $array) {
  26. $item = null;
  27.  
  28. foreach($array as $struct) {
  29.  
  30. if ($struct->contract_address == $contract) {
  31. $item = $struct;
  32.  
  33. break;
  34. }
  35. }
  36.  
  37. return $item;
  38. }
  39.  
  40. function fromGWEILib($amount) {
  41. return $amount / 10 ** 9;
  42. }
  43.  
  44. function fromGWEI($amount) {
  45. return $amount / 10 ** 18;
  46. }
  47. ?>
  48.  
  49. <html>
  50. <head>
  51. <title>Librium Dashboard Test</title>
  52. <style>
  53. body {
  54. padding: 25px;
  55. font-family: Helvetica, sans-serif;
  56. text-align:center!important;
  57. }
  58.  
  59. table {
  60. font-family: arial, sans-serif;
  61. border-collapse: collapse;
  62. width: 100%;
  63. }
  64.  
  65. td, th {
  66. border: 1px solid #dddddd;
  67. text-align: left;
  68. padding: 8px;
  69. text-align:center;
  70. }
  71.  
  72. tr:nth-child(even) {
  73. background-color: #dddddd;
  74. }
  75.  
  76. h1, a {
  77. text-align:center!important;
  78. }
  79.  
  80. iframe {
  81. width: 100%;
  82. height: 100%;
  83. border: none;
  84. }
  85.  
  86. textarea {
  87. width: 100%;
  88. height: 100%;
  89. }
  90. </style>
  91. </head>
  92. <body>
  93. <h1>Librium Liquidity Pool Distribution</h1>
  94. <h3>Liquidity Pool Rewards (BUSD): $<?php echo fromGWEI($miningBalance); ?></h3>
  95. <br/><hr><br/>
  96.  
  97. <form name="form2" action="?sender-tool=true" method='POST'>
  98. <input type="checkbox" required/>
  99. <label>I confirm that these rewards have been checked and happy to proceed to the multi-sender tool:</label>
  100. <input type='submit' value='Multi-sender Tool'>
  101. </form>
  102.  
  103. <hr style="margin-bottom:10px;">
  104.  
  105. <?php
  106. $filter = ['0x000000000000000000000000000000000000dead', '0x402e3ae60856a4a9df89c6cf22f137d570e75ca2', '0xf8647175cce3e77aacf298ae4b2b985c031108ff', '0x81e0ef68e103ee65002d3cf766240ed1c070334d', '0xf566cd1191a9c76b19d8c6408ec76adc25f1adc2', '0xd1076848d998bde9d738a703ab2c456de2e9e11f'];
  107.  
  108. if ($_GET['sender-tool']) {
  109.  
  110. $realIndex = 1;
  111. $totalBalance = 0;
  112. $percentageTotal = 0;
  113. $lines = [];
  114.  
  115. for ($i=0;$i<count($holdersFound);$i++) {
  116. if (!in_array($holdersFound[$i]->address, $filter)) {
  117. $index = $realIndex;
  118. $percentage = 1;
  119. $tokens = ($miningBalance / 100) * $percentage;
  120. $totalBalance += $tokens;
  121. $percentageTotal += $percentage;
  122. array_push($lines, $holdersFound[$i]->address . ',' . fromGWEI($tokens));
  123. $realIndex++;
  124. }
  125. }
  126.  
  127. $isMatched = "<span style='color:red;'>(Not Matched)</span>";
  128.  
  129. if (intval(fromGWEI($totalBalance)) === intval(fromGWEI($miningBalance))) {
  130. $isMatched = "<span style='color:#20cd20;'>(Matched)</span>";
  131. }
  132.  
  133. echo 'System Balance: ' . fromGWEI($totalBalance) . ' | Mining Balance: ' . fromGWEI($miningBalance) . ' ' . $isMatched .'<br/><br/><br/>';
  134.  
  135. if (count($lines) > 0){
  136. for ($r=0;$r<count($lines);$r++) {
  137. echo $lines[$r] . '<br/>';
  138. }
  139.  
  140. echo '<script type="text/javascript">window.open("https://cointool.app/multiSender/bsc", "_blank");</script>';
  141. echo '<br><br><hr><br><br>Multi-Sender Website not opened? <a href="https://cointool.app/multiSender/bsc", target="_blank">Click Here</a>';
  142. }
  143. else {
  144. echo "Unable to calculate the rewards. Please try again later";
  145. }
  146. }
  147. else {
  148. echo "<table>
  149. <tr>
  150. <th>#</th>
  151. <th>Address</th>
  152. <th>Tokens</th>
  153. <th>Percentage</th>
  154. <th>Reward</th>
  155. </tr>";
  156.  
  157. $realIndex = 1;
  158. $totalBalance = 0;
  159. $percentageTotal = 0;
  160.  
  161. for ($i=0;$i<count($holdersFound);$i++) {
  162. if (!in_array($holdersFound[$i]->address, $filter)) {
  163. $index = $realIndex;
  164. $percentage = 1;
  165. $tokens = ($miningBalance / 100) * $percentage;
  166. $totalBalance += $tokens;
  167. $percentageTotal += $percentage;
  168. echo '<tr><td>'. ($realIndex++) .'</td><td>'. $holdersFound[$i]->address .'</td><td>'. number_format(fromGWEILib($holdersFound[$i]->balance)) .' $LIB ('.number_format(($holdersFound[$i]->balance / $holdersFound[$i]->total_supply ) * 100, 2).'%)</td><td>'. $percentage .'%</td><td>$'.fromGwei($tokens).'</td></tr>';
  169. }
  170. }
  171.  
  172. $isMatched = "<span style='color:red;'>(Not Matched)</span>";
  173.  
  174. if (intval(fromGWEI($totalBalance)) === intval(fromGWEI($miningBalance))) {
  175. $isMatched = "<span style='color:#20cd20;'>(Matched)</span>";
  176. }
  177.  
  178. echo 'System Balance: $' . fromGWEI($totalBalance) . ' | Mining Balance: $' . fromGWEI($miningBalance) . ' ' . $isMatched .'<br/><br/><br/>';
  179.  
  180. echo "</table>";
  181. }
  182. ?>
  183.  
  184. </body>
  185. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement