Sumber dimuat naik... memuat...

Tolong tunjukkan kepada FMZ bagaimana untuk mendapatkan Uniswap V3 jumlah mata wang persendirian

Penulis:hidup menari86, Dicipta: 2023-07-13 13:48:35, Dikemas kini:

Sebagai contoh,https://app.uniswap.org/#/pools/536461Jumlah GRT / ETH di dalamnya


Lebih lanjut

Pencipta Kuantiti - Impian KecilDi samping itu, saya merancang untuk menulis satu artikel yang menerangkan dan meletakkan di perpustakaan.

Pencipta Kuantiti - Impian KecilCuba ini: https://www.fmz.com/digest-topic/10146

Pencipta Kuantiti - Impian KecilSemua ini boleh dilihat di https://etherscan.io/, kod yang dihasilkan hanyalah contoh, kandungan tertentu perlu diselesaikan secara spesifik.

hidup menari86/upload/asset/14dbf23df936e703bfe06.jpg Hasilnya tidak menunjukkan berapa banyak GRT dan ETH yang saya mahu

hidup menari86ABI_UniswapV3Router sama seperti yang saya cari ialah https://etherscan.io/address/0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45#code di dalam ini, ABI_NonfungiblePositionManager tidak sama, boleh saya tanya di mana anda cari?

Pencipta Kuantiti - Impian KecilMungkin ABI tidak betul, atau cara memanggilnya salah tulis, gunakan kod yang saya hantar di atas untuk menguji jika ia berfungsi. `` ABI:"Uniswap:"V3Router:" = const `[{"inputs"::"{"internalType":"address:":"_name:"_factoryV2","Type:":":":":"Type:":":":":":":"Mutability:":":":"Type:":":":":":"Di-payable:":":"Constructor:":":":"Type:":":":"Type:":":":"Type:":":":":"Di-type:":":":":":":"Address:":":":":"type:":":":":"type:":":":":":"type:":":":":"type:":":":":"type:":":":":"type:":":":":"type:":":":"type:":":":"type:":":":"type:":":":"type:":":"type:":":":"type:":":"type:":":"type:":":"type:":":"type:":":"type:":":"type:":":"type:":":"type:":"type:":"type:":"type:":"type:"type:"type:"type:"type:"type:"type:"type:"type:"type:" ABI_NonfungiblePositionManager = `[{"inputs":[{"internalType":"address","name":"_factory","type:":"address"},{"internalType:":":"address","name""WETH9","type:"address"},{"internal","type","address","name":"_tokenDescriptor_type",":"address"}],"stateMutability:":"nonpayable","constructor"},{"anonymous:":":":"type:":":":"false",:":":"inputs:":":":"type:":":":":":":":":"type:":":":":":":":":":"type:":":":":":":":":"type:":":":":":":":":"type:":":":":":":"type:":":":":":":"type:":":":":":":":"type:":":":":":":"O"indexed","type:":":":"WETH9","type:":":":"WETH9","type:":":":":"type:":":":":" const UniswapV3RouterAddress = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45" fungsi main (() { // Alamat dompet yang ingin ditanyakan // const walletAddress = exchange.IO (("address") const walletAddress = "0x28df8b987BE232bA33FdFB8Fc5058C1592A3db26" // Dapatkan alamat kontrak PositionManager untuk Uniswap V3 exchange.IO (("abi", UniswapV3RouterAddress, ABI_UniswapV3Router) const NonfungiblePositionManagerAddress = exchange.IO (("api", UniswapV3RouterAddress, "positionManager") Log ((("NonfungiblePositionManagerAddress:", NonfungiblePositionManagerAddress) // Pendaftaran ABI dalam kontrak positionManager exchange.IO (("abi", NonfungiblePositionManagerAddress, ABI_NonfungiblePositionManager) // Mencari jumlah NFT Uniswap V3 yang dimiliki oleh akaun semasa var nftBalance = exchange.IO (("api", NonfungiblePositionManagerAddress, "balanceOf", walletAddress) Log (("nftBalance:", nftBalance) Pergilah. // Mencari TokenId bagi NFT ini var nftTokenIds = [] for (var i = 0 ; i < nftBalance; i++) { var nftTokenId = exchange.IO (("api", NonfungiblePositionManagerAddress, "tokenOfOwnerByIndex", walletAddress, i) nftTokenIds.push ((nftTokenId) Log (("nftTokenId:", nftTokenId) {C:$0000FF} // Meminta butiran mengenai kedudukan kecairan berdasarkan posisi NFT tokenId var posisi = [] for (var i = 0; i < nftTokenIds.length; i++) { var pos = exchange.IO (("api", NonfungiblePositionManagerAddress, "positions", nftTokenIds[i]) Log (("pos:", pos) // Menganalisis data kedudukan positions.push ((parsePosData ((pos)) {C:$0000FF} Pergilah. var tbl = { jenis: "tabel", title: "LP", cols: ["pair", "fee", "lower", "upper", "liquidity"], barisan: kedudukan {C:$0000FF} LogStatus (("`" + JSON.stringify ((tbl) + "`") {C:$0000FF} Var tokens = {} fungsi init (() { var res = JSON.parse ((HttpQuery (("https://tokens.coingecko.com/uniswap/all.json")) Log (("fetch", res.tokens.length, "tokens from", res.name) _.each ((res.tokens, function ((token) { Tokens[token.symbol] = { name: token.symbol, decimals: token.decimals, alamat: token.address {C:$0000FF} {C:$0000FF} Log (("tokens:", tokens) {C:$0000FF} fungsi parse PosData ((posData) { /* {C:$0000FF} "nonce": "0", Operator: "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "token1": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "Fee": "3000", "feeGrowthInside0LastX128": "552824104363438506727784685971981736468", dan "Sudah lama tidak ada iklan yang berkaitan dengan pertumbuhan di laman web ini". "feeGrowthInside1LastX128": "2419576808699564757520565912733367379", dan "2419576808699564757520565912733367379", dan "241957680869956475752056591273336367379" "tokensOwed0": "0", "tokensOwed1": "0", "token0": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "TickLower": "-62160", "TickLower": "-62160", "TickLower": "TickLower": "-62160", "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickLower": "TickUpper": "-41280", "TickUpper": "-41280", "TickUpper": "-41280", "TickUpper": "-41280", "TickUpper": "Liquidity": "19090316141441365693" {C:$0000FF} */ Pergilah. var token0Symbol = null var token1Symbol = null for (simbol var dalam token) { if (tokens[symbol].address == posData.token0) { token0Symbol = tokens[symbol] } else if (tokens[symbol].address == posData.token1) { token1Symbol = tokens[symbol] {C:$0000FF} {C:$0000FF} return [token0Symbol.name + "_" + token1Symbol.name, posData.fee / 10000 + "%", posData.tickLower, posData.tickUpper, posData.liquidity] {C:$0000FF} `` Ini adalah sebuah laman web di Ethereum.

hidup menari86Kesalahan /upload/asset/14e3b9c329f0e6d2b7e09.jpg 2 kaedah tidak didaftarkan, adakah ABI mencari? https://etherscan.io/address/0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45#code Cari di sini

Pencipta Kuantiti - Impian KecilSkrin yang anda hantar mempunyai butang untuk menyalin ABI, di sudut kanan atas. Menyalin terus. Uniswap pada rantaian lain harus sama. Selain alamat kontrak, alamat kontrak pada rantaian yang sesuai harus diisi. Tidak perlu ringkasan.

hidup menari86/upload/asset/14e185e563e61cd155424.jpg Sila tanya ABI_UniswapV3Router ABI_NonfungiblePositionManager adalah salinan kandungan gambar? Bolehkah sama, isi penuh ABI, ringkasan tidak tahu untuk ringkasan? Kemudian jika menukar rantaian seperti rantaian Arbitrum, selain menukar alamat RPC yang ditambahkan, adakah parameter lain perlu ditukar? Contohnya: https://app.uniswap.org/#/pools/711084 jumlah USDT / ARB di dalam

Pencipta Kuantiti - Impian KecilJika anda ingin mendapatkan kumpulan pertukaran, simpan sendiri, dengan kod berikut: `` const ABI_UniswapV3Router = ` terlalu panjang untuk dihapuskan, untuk mengisi ABI tertentu` const ABI_NonfungiblePositionManager = ` terlalu panjang untuk dihapuskan, untuk mengisi ABI tertentu` const UniswapV3RouterAddress = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45" fungsi main (() { // const walletAddress = exchange.IO (("address") const walletAddress = "atau tentukan alamat dompet" // dapatkan alamat Pengurus kedudukan exchange.IO (("abi", UniswapV3RouterAddress, ABI_UniswapV3Router) const NonfungiblePositionManagerAddress = exchange.IO (("api", UniswapV3RouterAddress, "positionManager") Log ((("NonfungiblePositionManagerAddress:", NonfungiblePositionManagerAddress) exchange.IO (("abi", NonfungiblePositionManagerAddress, ABI_NonfungiblePositionManager) var nftBalance = exchange.IO (("api", NonfungiblePositionManagerAddress, "balanceOf", walletAddress) Log (("nftBalance:", nftBalance) Pergilah. var nftTokenIds = [] for (var i = 0 ; i < nftBalance; i++) { var nftTokenId = exchange.IO (("api", NonfungiblePositionManagerAddress, "tokenOfOwnerByIndex", walletAddress, i) nftTokenIds.push ((nftTokenId) Log (("nftTokenId:", nftTokenId) {C:$0000FF} var posisi = [] for (var i = 0; i < nftTokenIds.length; i++) { var pos = exchange.IO (("api", NonfungiblePositionManagerAddress, "positions", nftTokenIds[i]) Positions.push ((pos)) Log (("pos:", pos) // pos adalah setiap maklumat simpanan yang boleh diselesaikan secara khusus. {C:$0000FF} {C:$0000FF} `` Artikel akan dikemas kini di perpustakaan kemudian.

Pencipta Kuantiti - Impian KecilBoleh, di sini anda perlu menulis contoh pembinaan yang spesifik, anda boleh mengikuti catatan ini.

hidup menari86Boleh tolong saya selesaikan masalah ini?