New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stove-labs/arbitrage-bot-accountant

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stove-labs/arbitrage-bot-accountant

accounting for tezos balances

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

This repository is related to the core library of the arbitrage bot.

The accountant is a plugin that retrieves balances for any given native or token contract. This is used to keep track of balance changes before and after arbitrage is performed.

Learning resource

Challenge

Every token contract follows its own implementation of a token standard. Therefore it is not a viable approach to read the account ballance entry from a ledger Big_map, because we would need to be aware of each and every token implementation.

Solution

Tezos token FA1.2 TZIP-7 and FA2TZIP-12 have on-chain view entrypoints that usually get called by other smart contracts to get the total_supply of token_balance for a given account address. The result is returned through an operation as callback to the caller.

Fortunately, recent protocol upgrades on Tezos have provided a way to call those view entrypoints through the node without the need of injecting any on-chain operation when using the run_view endpoint. Taquito SDK abstracts this and makes this feature easily available to dApp developers.

Implementation

// src/accountant.ts

// FA1.2 getBalance as defined in TZIP-7
await tokenContractInstance.views.getBalance(botAddress).read()

// FA2 balance_of as defined in TZIP-12
await tokenContractInstance.views.balance_of(
  [
    { owner: botAddress, token_id: tokenId },
  ]
).read()

Keywords

FAQs

Package last updated on 28 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc