Thursday, January 15, 2026
No Result
View All Result
Blockchain Broadcast
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • NFT
  • Blockchain
  • Metaverse
  • DeFi
  • Web3
  • Analysis
  • Regulations
  • Scam Alert
Crypto Marketcap
Blockchain Broadcast
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • NFT
  • Blockchain
  • Metaverse
  • DeFi
  • Web3
  • Analysis
  • Regulations
  • Scam Alert
No Result
View All Result
Blockchain Broadcast
No Result
View All Result

Crypto PnL API – How to Track Wallet Profit & Loss – Moralis Web3

July 26, 2024
in Web3
Reading Time: 13 mins read
0 0
A A
0
Home Web3
Share on FacebookShare on Twitter


Searching for the simplest method to observe pockets revenue and loss (PnL)? You’ve come to the best place! On this information, we’ll introduce Moralis’ crypto PnL function, offering complete insights into pockets and token profitability. With this function, you’ll be able to seamlessly get the general profitability of a given tackle, acquire perception into the PnL standing of particular person tokens, and fetch the highest worthwhile wallets for a given ERC-20 token! 

Are you desirous to dive into the code? Right here’s our Pockets PnL Abstract endpoint in motion:

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/wallets/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/profitability/abstract?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Calling this endpoint returns the required pockets’s whole buying and selling quantity, whole PnL, PnL share, and different key metrics. Right here’s an instance of what it seems like:

{
total_count_of_trades: 12,
total_trade_volume: ‘3793782.5812942344’,
total_realized_profit_usd: ‘-20653.121064896484’,
total_realized_profit_percentage: -1.350177388165031,
total_buys: 8,
total_sells: 20,
total_sold_volume_usd: ‘1509006.703335308’,
total_bought_volume_usd: ‘2284775.8779589264’
}

That’s it; monitoring pockets revenue and loss doesn’t need to be tougher than this when utilizing Moralis. For a extra in-depth tutorial on how this works and additional info on our different endpoints, be a part of us on this article or try the Pockets API documentation web page!

Prepared to make use of our crypto PnL function? Join free with Moralis and acquire speedy entry to our industry-leading improvement instruments!

Overview

Crypto PnL is a vital monetary metric used to find out a portfolio’s internet revenue or loss. Merchants, buyers, and analysts depend on this metric to evaluate asset efficiency over particular intervals. As such, it’s basic for creating instruments reminiscent of cryptocurrency wallets and buying and selling platforms because it gives customers with a transparent overview of their portfolios’ efficiency.

Historically, acquiring this info requires intensive guide knowledge aggregation, together with monitoring trades and cryptocurrency costs. Nevertheless, this course of can now be streamlined utilizing a Web3 knowledge supplier like Moralis.

With Moralis’ crypto PnL function, you’ll be able to simply decide the general profitability of a given tackle, analyze the PnL standing of ERC-20s, and determine the highest worthwhile wallets for particular tokens. To study extra about how this function works and the way it can profit you, comply with our complete information. Let’s dive in!

What’s PnL in Crypto?

Crypto PnL, quick for “revenue and loss,” refers back to the monetary final result of your buying and selling actions. It’s calculated based mostly on the distinction between the shopping for and promoting costs of your cryptocurrency tokens. As such, crypto PnL gives an summary of how your property are performing over a given interval.

Illustration of crypto PnL.

Crypto PnL is an important metric for merchants and analysts alike, providing a complete overview of portfolio efficiency. Merchants depend on it to evaluate the effectiveness of their methods, whereas analysts use it for varied functions, together with tax reporting.

When you’re constructing decentralized finance (DeFi) platforms, cryptocurrency wallets, decentralized exchanges (DEXs), portfolio trackers, or different Web3 platforms, incorporating crypto PnL is essential. This function will give your customers a transparent indication of how their property are performing instantly inside your platform, boosting each engagement and retention.

Nevertheless, calculating crypto PnL from scratch will be complicated and time-consuming. It requires monitoring all trades a consumer makes and monitoring costs at particular occasions, a course of that may be tedious if performed manually.

Happily, a Web3 knowledge supplier like Moralis can streamline this course of. It eliminates the effort of guide calculations, permitting you to deal with enhancing your platform’s options and consumer expertise!

Introducing Moralis – The Trade’s Main Crypto PnL API for Monitoring Pockets Revenue & Loss

With Moralis’ realized crypto PnL function, you’ll be able to seamlessly question the revenue and loss standing of any pockets. As such, this function affords complete insights into pockets and token profitability, making it simpler to trace and analyze income/losses throughout tokens and determine essentially the most worthwhile wallets for any ERC-20 token! 

The realized crypto PnL function consists of three endpoints:

Pockets PnL SummaryFetch the general profitability of a given tackle over a selected time interval, together with whole buying and selling quantity, whole revenue/loss, and different key metrics:

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/wallets/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/profitability/abstract?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Instance Response:

{
total_count_of_trades: 12,
total_trade_volume: ‘3793782.5812942344’,
total_realized_profit_usd: ‘-20653.121064896484’,
total_realized_profit_percentage: -1.350177388165031,
total_buys: 8,
total_sells: 20,
total_sold_volume_usd: ‘1509006.703335308’,
total_bought_volume_usd: ‘2284775.8779589264’
}

Pockets PnL BreakdownGet an in depth breakdown of buys, sells, and revenue/loss for every ERC-20 token traded by a pockets. This endpoint helps you perceive the efficiency of particular person tokens in a portfolio:

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/wallets/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/profitability?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Instance Response:

{
outcome: [
{
token_address: ‘0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2’,
avg_buy_price_usd: ‘1250.89117636677242138858’,
avg_sell_price_usd: ‘1217.57108487456170834445’,
total_usd_invested: ‘765334.18465647742708110434311858’,
total_tokens_bought: ‘611.831148157427433472’,
total_tokens_sold: ‘611.831148157427433472’,
total_sold_usd: ‘744947.914822087616974748507047918740485538176519383’,
avg_cost_of_quantity_sold: ‘1250.89117636677242138858’,
count_of_trades: 5,
realized_profit_usd: ‘-20386.26983438981010635958779520045817511936’,
realized_profit_percentage: -2.663708252302914,
total_buys: 3,
total_sells: 18,
name: ‘Wrapped Ether’,
symbol: ‘WETH’,
decimals: ‘WETH’,
logo: ‘https://logo.moralis.io/0x1_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_018112a9229b4bf1bf0d042beb7c2c55’,
logo_hash: ‘0a7fc292596820fe066ce8ce3fd6e2ad9d479c2993f905e410ef74f2062a83ec’,
thumbnail: ‘https://logo.moralis.io/0x1_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_018112a9229b4bf1bf0d042beb7c2c55’,
possible_spam: false
},
//…
]
}

High Worthwhile Wallets by TokenFetch the highest worthwhile wallets which have traded a sure token, offering insights into essentially the most profitable merchants for that asset:

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/erc20/0x7c9f4c87d911613fe9ca58b579f737911aad2d43/top-gainers?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Instance Response:

{
identify: ‘Wrapped Matic’,
image: ‘WMATIC’,
decimals: ’18’,
emblem: ‘https://emblem.moralis.io/0x1_0x7c9f4c87d911613fe9ca58b579f737911aad2d43_128bc82fe3d945e59c5e67b540eb7ab5’,
possible_spam: false,
outcome: [
{
address: ‘0x202bb2fab1e35d940fde99b214ba49dafbcef62a’,
avg_buy_price_usd: ‘0.9183155718922578201779330700749389942841’,
avg_sell_price_usd: ‘1.59952463158282389246’,
total_tokens_bought: ‘50.425564410689794636’,
total_usd_invested: ‘46.30658101979248190652763127006057463808’,
total_tokens_sold: ‘50.423563438810080581’,
total_sold_usd: ‘80.6537317325558427356221252383435353256’,
avg_cost_of_quantity_sold: ‘0.91831557189225782928’,
count_of_trades: 2,
realized_profit_usd: ‘34.34898823639942076774324344951973710758’,
realized_profit_percentage: 74.18027969262069
},
//…
]
}

This overview covers our crypto PnL function. Subsequent, we’ll stroll you thru a tutorial on the way to use these endpoints to trace pockets revenue and loss!

3-Step Tutorial: Methods to Monitor Pockets Revenue & Loss

We’ll now present you the way to observe the revenue and loss standing of any pockets. And because of the accessibility of our premier API, you may get the information you want in three easy steps: 

Get a Moralis API Key

Write a Script Calling the Pockets PnL Abstract Endpoint

Run the Code

Nevertheless, earlier than we get going, you’ll have to maintain a few stipulations! 

Stipulations

Earlier than shifting on, be sure you have the next put in and arrange: 

Step 1: Get a Moralis API Key

Click on the “Begin for Free” button on the high proper to join an account with Moralis:

Red arrow pointing at "Start for Free" button when getting crypto PnL

From there, you’ll discover your API key instantly below the “House” tab:

Red box highlighting the API key on Moralis' admin panel.

Copy and preserve the important thing for the second, as you’ll want it in the course of the subsequent step!

Step 2: Write a Script Calling the Pockets PnL Abstract Endpoint

Open your most well-liked IDE, arrange a folder, launch a terminal, and initialize a challenge with this command:

npm init

Set up the wanted dependencies with this terminal command:

npm set up node-fetch –save
npm set up moralis @moralisweb3/common-evm-utils

From right here, open your “bundle.json” file and add “sort”: “module” to the record:

"type": "module" highlighted in code editor.

Create a brand new “index.js” file and add the next code:

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/wallets/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/profitability/abstract?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Subsequent, you’ll want to configure the code barely. Firstly, add your Moralis API key by changing YOUR_API_KEY. Secondly, configure the tackle and chain parameters to suit your question:

Code configurations highlighted when getting crypto PnL

That’s it for the code. All that continues to be now could be to execute the script!

Step 3: Run the Code

Open your terminal, go to the basis folder of your challenge, and run this command:

node index.js

In return, you’ll obtain a response showcasing the pockets’s whole buying and selling quantity, whole realized revenue/loss, realized revenue/loss share, and extra. Right here’s an instance of what it’d appear like:

{
total_count_of_trades: 12,
total_trade_volume: ‘3793782.5812942344’,
total_realized_profit_usd: ‘-20653.121064896484’,
total_realized_profit_percentage: -1.350177388165031,
total_buys: 8,
total_sells: 20,
total_sold_volume_usd: ‘1509006.703335308’,
total_bought_volume_usd: ‘2284775.8779589264’
}

That’s it! Monitoring pockets revenue and loss doesn’t need to be tougher than this when utilizing Moralis!

Use Case – Construct a Crypto PnL Tracker

Now that you know the way to trace pockets revenue and loss, you’ll be able to leverage this knowledge to construct instruments like a crypto PnL tracker. A crypto PnL tracker is a platform or device that helps customers monitor their portfolio efficiency successfully! 

Crypto PnL tracker.

Key options of a crypto PnL tracker embody:

Actual-Time Portfolio Monitoring: Monitor the efficiency of a portfolio in real-time, together with the revenue/loss standing for particular person ERC-20 tokens.

Historic Information Evaluation: Entry historic efficiency knowledge to investigate how investments have carried out over particular intervals.

Tax Calculations: Make the most of PnL knowledge to help customers with their cryptocurrency taxes.

A crypto PnL tracker will be built-in into varied platforms, reminiscent of portfolio trackers, cryptocurrency wallets, DEXs, and extra, to enhance the general consumer expertise of your dapps! 

Past Crypto PnL & Monitoring Pockets Revenue & Loss – Diving Deeper Into Moralis

Moralis stands because the {industry}’s main Web3 knowledge supplier, providing an in depth suite of Web3 APIs and RPC nodes past the crypto PnL function. With Moralis, you’ll be able to entry all crypto knowledge in a single place, making it straightforward to develop subtle platforms like cryptocurrency wallets, portfolio trackers, and extra.

However why select Moralis’ Web3 APIs and RPC nodes?

Complete: Moralis delivers essentially the most detailed API responses within the {industry}, offering extra knowledge with fewer calls. This effectivity allows you to construct dapps sooner and extra successfully.

Cross-Chain Compatibility: Moralis helps over 30 chains, together with Ethereum, Polygon, BSC, and Optimism, providing full function parity throughout all networks. This implies you solely want one supplier for all of your crypto wants.

Safe: Profit from enterprise-grade knowledge safety as Moralis is Web3’s first SOC 2 Sort 2 licensed knowledge supplier.

To totally grasp the capabilities of Moralis, let’s delve deeper into our suite of improvement instruments, beginning with our Web3 APIs!

Web3 APIs

In our suite of Web3 APIs, you’ll discover ten use-case-specific interfaces. Under, we’ll introduce three outstanding examples:

Pockets API: With the Pockets API, you’ll be able to effortlessly retrieve any pockets’s crypto PnL, token balances, transaction historical past, internet value, and far more. By leveraging this device, you’ll be able to seamlessly combine pockets performance into your dapps.

Token API: The Token API means that you can entry token balances, metadata, costs, and extra with only a few traces of code. This makes the Token API a superb device for dapps requiring ERC-20 knowledge, together with DEXs, portfolio trackers, and extra.

NFT API: With the NFT API, you’ll be able to effortlessly question NFT balances, metadata, costs, and extra. When you’re seeking to construct NFT marketplaces, Web3 video games, or related platforms, make sure to try the NFT API.

Streams API: With the Streams API, you’ll be able to effortlessly arrange Web3 knowledge pipelines on the click on of some buttons to stream knowledge instantly into your initiatives. As such, this highly effective device is right for organising real-time alerts, populating databases, or enhancing dapps with up-to-date insights on tokens, wallets, and good contracts.

Value API: The Value API allows seamless retrieval of costs for any ERC-20 token or NFT. This superior device helps batch requests, permitting you to question the costs of a number of tokens concurrently. It’s excellent for constructing DEXs, token trackers, or any platform requiring correct pricing knowledge.

Go to our official Web3 API web page to study extra in regards to the examples above and our different interfaces!

RPC Nodes

Moralis gives RPC nodes for over 30 blockchains, together with Ethereum, Polygon, BSC, and plenty of others. And our user-friendly, point-and-click interface makes organising nodes a breeze! 

However what units our RPC nodes aside?

Pace: Take pleasure in lightning-fast response occasions beginning at simply 70 ms, making certain you obtain the information you want immediately.

Reliability: Our nodes are designed for max dependability, with a formidable 99.9%  uptime.

Safety: Profit from top-notch knowledge safety because the {industry}’s first SOC 2 Sort 2 licensed knowledge supplier.

To study extra, please go to our official RPC nodes web page or try one of many following guides, the place we discover Fantom RPC nodes and Blast RPC nodes!

Abstract: Crypto PnL API – Methods to Monitor Pockets Revenue & Loss

Crypto PnL is a vital monetary metric used to find out the online revenue or lack of a cryptocurrency portfolio. Merchants, analysts, and buyers depend on this metric to trace asset efficiency over particular time intervals, making it important for constructing every little thing from wallets to portfolio trackers.

Crypto PnL summary.

Nevertheless, calculating the revenue and lack of a pockets from scratch could be a tedious and sophisticated process, requiring fixed monitoring of consumer transactions, token costs, and extra. Fortunately, now you can seamlessly question the crypto PnL of any portfolio with a single line of code utilizing a Web3 knowledge supplier like Moralis.

Moralis’ crypto PnL function consists of three core endpoints:

Pockets PnL Abstract: Get hold of the general profitability of a given pockets over a specified interval. This consists of whole buying and selling quantity, whole revenue/loss, revenue/loss share, and different key metrics.

Pockets PnL Breakdown: Fetch an in depth breakdown of buys, sells, and revenue/loss for every token traded by a pockets. This endpoint gives an in-depth understanding of the efficiency of particular person tokens in a portfolio.

High Worthwhile Wallets by Token: Determine the highest worthwhile wallets which have traded a selected token, providing insights into essentially the most profitable merchants for that exact asset.

As such, when utilizing Moralis, you’ll be able to seamlessly observe pockets revenue and loss with out breaking a sweat! 

When you discovered this crypto PnL tutorial useful, take into account exploring extra content material on our weblog. For instance, try our article on the DeBank API for info on our DeFi positions function, or examine our Alchemy Webhooks information for extra info on streams.

Moreover, for those who want to observe pockets revenue and loss your self, join with Moralis. You’ll be able to create an account freed from cost and acquire speedy entry to our suite of industry-leading instruments. 



Source link

Tags: APICryptoLossMoralisPnLProfitTrackWalletWeb3
Previous Post

Understanding the Abilities and Limitations of ChatGPT

Next Post

Set up Web3j for Android Development

Related Posts

AI, Impersonations Drove Crypto Scam Losses to Record  Billion in 2025: Chainalysis
Web3

AI, Impersonations Drove Crypto Scam Losses to Record $17 Billion in 2025: Chainalysis

January 15, 2026
What Is Venice AI? The Privacy-Focused Chatbot
Web3

What Is Venice AI? The Privacy-Focused Chatbot

January 13, 2026
Two major crypto events canceled after city hit by 18 violent physical attacks on crypto holders amid market downturn
Web3

Two major crypto events canceled after city hit by 18 violent physical attacks on crypto holders amid market downturn

January 12, 2026
Bitcoin Shrugs Off Powell Probe as DOJ Targets Fed Chair
Web3

Bitcoin Shrugs Off Powell Probe as DOJ Targets Fed Chair

January 12, 2026
Should Politicians Be Able to Use Prediction Markets? House Bill Proposes Ban
Web3

Should Politicians Be Able to Use Prediction Markets? House Bill Proposes Ban

January 10, 2026
Altcoins Defy Bitcoin Slump as XRP, Solana Notch Double-Digit Gains
Web3

Altcoins Defy Bitcoin Slump as XRP, Solana Notch Double-Digit Gains

January 9, 2026
Next Post
Set up Web3j for Android Development

Set up Web3j for Android Development

Ferrari drives into Europe with crypto payments, as industry embraces digital assets

Ferrari drives into Europe with crypto payments, as industry embraces digital assets

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Facebook Twitter Instagram Youtube RSS
Blockchain Broadcast

Blockchain Broadcast delivers the latest cryptocurrency news, expert analysis, and in-depth articles. Stay updated on blockchain trends, market insights, and industry innovations with us.

CATEGORIES

  • Altcoin
  • Analysis
  • Bitcoin
  • Blockchain
  • Crypto Exchanges
  • Crypto Updates
  • DeFi
  • Ethereum
  • Metaverse
  • NFT
  • Regulations
  • Scam Alert
  • Uncategorized
  • Web3
No Result
View All Result

SITEMAP

  • About Us
  • Advertise With Us
  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact Us

Copyright © 2024 Blockchain Broadcast.
Blockchain Broadcast is not responsible for the content of external sites.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
  • bitcoinBitcoin(BTC)$95,253.00-2.47%
  • ethereumEthereum(ETH)$3,283.14-2.73%
  • tetherTether(USDT)$1.00-0.03%
  • binancecoinBNB(BNB)$925.64-2.17%
  • rippleXRP(XRP)$2.06-4.04%
  • solanaSolana(SOL)$141.44-4.04%
  • usd-coinUSDC(USDC)$1.00-0.01%
  • staked-etherLido Staked Ether(STETH)$3,284.23-2.75%
  • tronTRON(TRX)$0.3101642.40%
  • dogecoinDogecoin(DOGE)$0.139357-5.47%
No Result
View All Result
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • NFT
  • Blockchain
  • Metaverse
  • DeFi
  • Web3
  • Analysis
  • Regulations
  • Scam Alert

Copyright © 2024 Blockchain Broadcast.
Blockchain Broadcast is not responsible for the content of external sites.