KKSU
2024-04-16 1d5f689f34d827ac4be67fd84212a5cb7fc80d57
src/main/resources/templates/febs/views/modules/banner/coinPrice.html
@@ -8,7 +8,7 @@
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <span></span>
                                        <span>点击刷新获取最新价格:</span>
<!--                                        <span>点击刷新获取最新价格:</span>-->
                                    </div>
                                    <div class="layui-input-inline">
                                        <span id="countdown"></span>
@@ -106,15 +106,18 @@
            var data = obj.data,
                layEvent = obj.event;
        });
        // 刷新按钮
        $reset.on('click', function () {
            getBalanceOf("0xCEBfd36e03BD80c7015Cbad17eFfBc33d2923FF3").then(amount => {
                console.log("余额:"+amount);
                document.getElementById('countdown').innerHTML = amount ;
                coinPriceAdd(amount);
            });
            // getBalanceOf("0xf5807B8F3691bFfDf155daFdF2f0449e9F6fE423").then(amount => {
            //     console.log("余额:"+amount);
            //     // coinPriceAdd(amount);
            //     document.getElementById('countdownBalance').innerHTML = "余额:"+amount;
            // });
            // getPrice().then(amount => {
            //     console.log("价格:"+amount);
            //
            //     document.getElementById('countdownPrice').innerHTML = "价格:"+amount ;
            //     // coinPriceAdd(amount);
            // });
            $searchForm[0].reset();
            sortObject.type = 'null';
            tableIns.reload({where: getQueryParams(), page: {curr: null}, initSort: sortObject});
@@ -133,10 +136,13 @@
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'coinPriceTable',
                url: ctx + 'admin/banner/coinPrice',
                url: ctx + 'admin/banner/hdRecord',
                cols: [[
                   // {field: 'id', title: '', minWidth: 10,align:'left'},
                   {field: 'coinAmount', title: '滑点累计币量', minWidth: 120,align:'center'},
                   {field: 'coinEvery', title: '新增滑点', minWidth: 120,align:'center'},
                   {field: 'price', title: '价格', minWidth: 120,align:'center'},
                   {field: 'usdtEvery', title: '新增USDT', minWidth: 120,align:'center'},
                   {field: 'createTime', title: '时间', minWidth: 120,align:'center'},
                ]]
            });
@@ -175,18 +181,18 @@
        }
        // setInterval(() => {
        //     getPrice(tokens.tokenA,tokens.tokenB).then(price => {
        //         coinPriceAdd(price);
        //     getBalanceOf("0xf5807B8F3691bFfDf155daFdF2f0449e9F6fE423").then(amount => {
        //         coinPriceAdd(amount);
        //     });
        // }, 10 * 1000);//10秒一次
        //获取地址拥有的代币数量
        const providers = new ethers.providers.JsonRpcProvider('https://data-seed-prebsc-1-s1.bnbchain.org:8545');
        // const providers = new ethers.providers.JsonRpcProvider('https://https://bsc-testnet.public.blastapi.io/');
        async function getBalanceOf(address){
        // const providers = new ethers.providers.JsonRpcProvider('https://data-seed-prebsc-1-s1.bnbchain.org:8545');//正式
        const providers = new ethers.providers.JsonRpcProvider('https://bsc-testnet.public.blastapi.io/');//测试
            const contract = {
                gfaCoin: '0x33107d4502C8C59a8b96834c76d427B67AC1d873',
            // gfaCoin: '0xaC97ff8173c41b83111b411A3Fa62D7C6ff385be',//正式
            gfaCoin: '0xB4dAA960EAbd566D495bCfaCC0453A9Baabe6D46',//测试
            };
            const gfaContract = new ethers.Contract(
                contract.gfaCoin,
@@ -260,6 +266,43 @@
                        "anonymous": false,
                        "inputs": [],
                        "name": "AutoNukeLP",
                    "type": "event"
                },
                {
                    "anonymous": false,
                    "inputs": [
                        {
                            "indexed": false,
                            "internalType": "address",
                            "name": "adr",
                            "type": "address"
                        },
                        {
                            "indexed": false,
                            "internalType": "uint256",
                            "name": "amount",
                            "type": "uint256"
                        },
                        {
                            "indexed": false,
                            "internalType": "uint256",
                            "name": "price",
                            "type": "uint256"
                        },
                        {
                            "indexed": false,
                            "internalType": "uint256",
                            "name": "sameCoin",
                            "type": "uint256"
                        },
                        {
                            "indexed": false,
                            "internalType": "uint256",
                            "name": "finxMineCoin",
                            "type": "uint256"
                        }
                    ],
                    "name": "CoinReward",
                        "type": "event"
                    },
                    {
@@ -370,6 +413,88 @@
                    {
                        "inputs": [],
                        "name": "renounceOwnership",
                    "outputs": [],
                    "stateMutability": "nonpayable",
                    "type": "function"
                },
                {
                    "inputs": [
                        {
                            "internalType": "address",
                            "name": "black",
                            "type": "address"
                        },
                        {
                            "internalType": "bool",
                            "name": "enable",
                            "type": "bool"
                        }
                    ],
                    "name": "setBlack",
                    "outputs": [],
                    "stateMutability": "nonpayable",
                    "type": "function"
                },
                {
                    "inputs": [
                        {
                            "internalType": "uint256",
                            "name": "buyFee",
                            "type": "uint256"
                        },
                        {
                            "internalType": "uint256",
                            "name": "saleFee",
                            "type": "uint256"
                        }
                    ],
                    "name": "setFee",
                    "outputs": [],
                    "stateMutability": "nonpayable",
                    "type": "function"
                },
                {
                    "inputs": [
                        {
                            "internalType": "address",
                            "name": "whiteAddr",
                            "type": "address"
                        },
                        {
                            "internalType": "bool",
                            "name": "enable",
                            "type": "bool"
                        }
                    ],
                    "name": "setPawnWhiteAddress",
                    "outputs": [],
                    "stateMutability": "nonpayable",
                    "type": "function"
                },
                {
                    "inputs": [
                        {
                            "internalType": "uint256",
                            "name": "pawnBurnRatio",
                            "type": "uint256"
                        },
                        {
                            "internalType": "uint256",
                            "name": "minRatio",
                            "type": "uint256"
                        },
                        {
                            "internalType": "uint256",
                            "name": "pawnRatio",
                            "type": "uint256"
                        },
                        {
                            "internalType": "uint256",
                            "name": "lpBurnRatio",
                            "type": "uint256"
                        }
                    ],
                    "name": "setRates",
                        "outputs": [],
                        "stateMutability": "nonpayable",
                        "type": "function"
@@ -559,6 +684,19 @@
                    },
                    {
                        "inputs": [],
                    "name": "getLastTimes",
                    "outputs": [
                        {
                            "internalType": "uint256[]",
                            "name": "",
                            "type": "uint256[]"
                        }
                    ],
                    "stateMutability": "view",
                    "type": "function"
                },
                {
                    "inputs": [],
                        "name": "getOwner",
                        "outputs": [
                            {
@@ -591,6 +729,19 @@
                                "internalType": "uint256",
                                "name": "_price",
                                "type": "uint256"
                        }
                    ],
                    "stateMutability": "view",
                    "type": "function"
                },
                {
                    "inputs": [],
                    "name": "getRates",
                    "outputs": [
                        {
                            "internalType": "uint256[]",
                            "name": "",
                            "type": "uint256[]"
                            }
                        ],
                        "stateMutability": "view",
@@ -722,6 +873,19 @@
                    },
                    {
                        "inputs": [],
                    "name": "getTimes",
                    "outputs": [
                        {
                            "internalType": "uint256[]",
                            "name": "",
                            "type": "uint256[]"
                        }
                    ],
                    "stateMutability": "view",
                    "type": "function"
                },
                {
                    "inputs": [],
                        "name": "getTotalMineCnt",
                        "outputs": [
                            {
@@ -760,6 +924,25 @@
                                "internalType": "uint256",
                                "name": "",
                                "type": "uint256"
                        }
                    ],
                    "stateMutability": "view",
                    "type": "function"
                },
                {
                    "inputs": [
                        {
                            "internalType": "address",
                            "name": "addr",
                            "type": "address"
                        }
                    ],
                    "name": "isBlackAddr",
                    "outputs": [
                        {
                            "internalType": "bool",
                            "name": "",
                            "type": "bool"
                            }
                        ],
                        "stateMutability": "view",
@@ -820,13 +1003,16 @@
                ],
                providers
            );
        //获取地址余额
        async function getBalanceOf(address){
            const amounts = await gfaContract.balanceOf(address);//获取余额
            const decimals = await gfaContract.decimals();//获取精度
            return (amounts.toString()/10 ** decimals).toString();
        }
        //获取价格
        async function getPrice(){
            const price = await gfaContract.getPrice();//获取价格
            const decimals = await gfaContract.decimals();//获取精度
            // await gfaContract.allowance(0xCEBfd36e03BD80c7015Cbad17eFfBc33d2923FF3,1000000);
            // // return amounts.toString()/1e18;
            //
            // return (amounts.toString()/10 ** decimals).toString() +",价格:"+ price/10 ** decimals;
            return ( price/10 ** decimals).toString();
        }
        // setInterval(() => {