Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Configs */
- $apiKey = "ckey_6af14f29d69f44e28f698ccf9b9";
- $chain = 56;
- $walletAddress = "0xbc57af7dc48201cc1792fff04dba5fe3c3d59210";
- $toSearchFor = "0xe9e7cea3dedca5984780bafc599bd69add087d56";
- $contractAddress = "0x5f2172b64a33f423bc7f0c48c23f7d3008f7e4fe";
- /* Configs */
- $contractJson = file_get_contents('https://api.covalenthq.com/v1/'.$chain.'/address/'.$walletAddress.'/balances_v2/?key='.$apiKey);
- $contractResult = json_decode($contractJson);
- $contractData = $contractResult->data;
- $contractsFound = $contractData->items;
- $selectedContract = findContract($toSearchFor, $contractsFound);
- $miningBalance = $selectedContract->balance;
- $holdersJson = file_get_contents('https://api.covalenthq.com/v1/'.$chain.'/tokens/'.$contractAddress.'/token_holders/?key='.$apiKey.'&page-size=104');
- $holdersResult = json_decode($holdersJson);
- $holdersData = $holdersResult->data;
- $holdersFound = $holdersData->items;
- function findContract($contract, $array) {
- $item = null;
- foreach($array as $struct) {
- if ($struct->contract_address == $contract) {
- $item = $struct;
- break;
- }
- }
- return $item;
- }
- function fromGWEILib($amount) {
- return $amount / 10 ** 9;
- }
- function fromGWEI($amount) {
- return $amount / 10 ** 18;
- }
- ?>
- <html>
- <head>
- <title>Librium Dashboard Test</title>
- <style>
- body {
- padding: 25px;
- font-family: Helvetica, sans-serif;
- text-align:center!important;
- }
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 100%;
- }
- td, th {
- border: 1px solid #dddddd;
- text-align: left;
- padding: 8px;
- text-align:center;
- }
- tr:nth-child(even) {
- background-color: #dddddd;
- }
- h1, a {
- text-align:center!important;
- }
- iframe {
- width: 100%;
- height: 100%;
- border: none;
- }
- textarea {
- width: 100%;
- height: 100%;
- }
- </style>
- </head>
- <body>
- <h1>Librium Liquidity Pool Distribution</h1>
- <h3>Liquidity Pool Rewards (BUSD): $<?php echo fromGWEI($miningBalance); ?></h3>
- <br/><hr><br/>
- <form name="form2" action="?sender-tool=true" method='POST'>
- <input type="checkbox" required/>
- <label>I confirm that these rewards have been checked and happy to proceed to the multi-sender tool:</label>
- <input type='submit' value='Multi-sender Tool'>
- </form>
- <hr style="margin-bottom:10px;">
- <?php
- $filter = ['0x000000000000000000000000000000000000dead', '0x402e3ae60856a4a9df89c6cf22f137d570e75ca2', '0xf8647175cce3e77aacf298ae4b2b985c031108ff', '0x81e0ef68e103ee65002d3cf766240ed1c070334d', '0xf566cd1191a9c76b19d8c6408ec76adc25f1adc2', '0xd1076848d998bde9d738a703ab2c456de2e9e11f'];
- if ($_GET['sender-tool']) {
- $realIndex = 1;
- $totalBalance = 0;
- $percentageTotal = 0;
- $lines = [];
- for ($i=0;$i<count($holdersFound);$i++) {
- if (!in_array($holdersFound[$i]->address, $filter)) {
- $index = $realIndex;
- $percentage = 1;
- $tokens = ($miningBalance / 100) * $percentage;
- $totalBalance += $tokens;
- $percentageTotal += $percentage;
- array_push($lines, $holdersFound[$i]->address . ',' . fromGWEI($tokens));
- $realIndex++;
- }
- }
- $isMatched = "<span style='color:red;'>(Not Matched)</span>";
- if (intval(fromGWEI($totalBalance)) === intval(fromGWEI($miningBalance))) {
- $isMatched = "<span style='color:#20cd20;'>(Matched)</span>";
- }
- echo 'System Balance: ' . fromGWEI($totalBalance) . ' | Mining Balance: ' . fromGWEI($miningBalance) . ' ' . $isMatched .'<br/><br/><br/>';
- if (count($lines) > 0){
- for ($r=0;$r<count($lines);$r++) {
- echo $lines[$r] . '<br/>';
- }
- echo '<script type="text/javascript">window.open("https://cointool.app/multiSender/bsc", "_blank");</script>';
- echo '<br><br><hr><br><br>Multi-Sender Website not opened? <a href="https://cointool.app/multiSender/bsc", target="_blank">Click Here</a>';
- }
- else {
- echo "Unable to calculate the rewards. Please try again later";
- }
- }
- else {
- echo "<table>
- <tr>
- <th>#</th>
- <th>Address</th>
- <th>Tokens</th>
- <th>Percentage</th>
- <th>Reward</th>
- </tr>";
- $realIndex = 1;
- $totalBalance = 0;
- $percentageTotal = 0;
- for ($i=0;$i<count($holdersFound);$i++) {
- if (!in_array($holdersFound[$i]->address, $filter)) {
- $index = $realIndex;
- $percentage = 1;
- $tokens = ($miningBalance / 100) * $percentage;
- $totalBalance += $tokens;
- $percentageTotal += $percentage;
- 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>';
- }
- }
- $isMatched = "<span style='color:red;'>(Not Matched)</span>";
- if (intval(fromGWEI($totalBalance)) === intval(fromGWEI($miningBalance))) {
- $isMatched = "<span style='color:#20cd20;'>(Matched)</span>";
- }
- echo 'System Balance: $' . fromGWEI($totalBalance) . ' | Mining Balance: $' . fromGWEI($miningBalance) . ' ' . $isMatched .'<br/><br/><br/>';
- echo "</table>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement