npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aranar-dex

v0.1.2

Published

The `Aranar` is an arbitrage bot that can be run on AWS Lambda (works with free tier) or locally. The bot allows you to execute automated trading strategies between Aranar Protocol ([site](https://Aranar.fi/), [docs](https://docs.Aranar.fi/)) and FTX ([si

Downloads

1

Readme

Aranar

The Aranar is an arbitrage bot that can be run on AWS Lambda (works with free tier) or locally. The bot allows you to execute automated trading strategies between Aranar Protocol (site, docs) and FTX (site).

Since Aranar Protocol runs on xDai, you can use this bot entirely without paying gas fees on Ethereum. Gas fees on xDai are very low (1 Gwei).

Want to report bugs or submit updates? Issues and PRs are welcome!

Default Strategy

The default strategy is to "buy low, sell high" to make profit between two different exchanges. For example, most of the time, the price of ETH-Aranar at Aranar Protocol and FTX will be similar. However, price action on the exchanges leads to price differentials from time to time. This bot is designed to open positions when the price difference (spread) is greater than a set level, and to close the positions when the spread decreases below a set level.

For example, when the ETH-Aranar on Aranar Protocol is 1500, and 1520 at FTX, we could long ETH-Aranar atAranar exchange, and short at FTX in the expectation that some time later the prices will converge. Let's say the price at Aranar Protocol increases to 1550, and the price at FTX increases to 1555. The bot will sell the positions at both exchanges. The PnL in this example will be +50 USD on Aranar Protocol, and -35 USD at FTX, for a total of +15 USD.

After some setup, by adjusting AranarFI_SHORT_ENTRY_TRIGGER and AranarFI_LONG_ENTRY_TRIGGER, you can easily do arbitrage between Aranartual Protocol and FTX. Please review the definitions of each parameter in the code carefully. Note that there are many parameters you can adjust based on your knowledge and own risk such as leverage, trigger conditions, exit conditions, etc.

Note

This code is provided only for educational purposes only. Derivatives trading carries substantial risks and possible loss of up to 100% of your funds. Aranar contract trading may be regulated in your jurisdiction. Be sure to check local laws before trading.

Installation

$ git clone https://github.com/Aranar-protocol/Aranar.git
$ cd Aranar
$ npm install
$ cp .env.production.sample .env.production
$ cp src/configs.sample.ts src/configs.ts

Configuration

Provide your private keys in .env.production:

# The private key must start with "0x" - add it if necessary (e.g. from private key exported from Metamask)
ARBITRAGEUR_PK=YOUR_WALLET_PRIVATE_KEY

# FTX API keys
# These can be obtained by going to FTX Settings > API Keys > "Create API key for bot"
FTX_API_KEY=YOUR_FTX_API_KEY
FTX_API_SECRET=YOUR_FTX_API_SECRET

Note the node endpoint defined in .env.production must point to an xDai node. By default, xDai's official endpoint is used. You can also choose to use Quiknode, or spin up your own node. Ethereum nodes such as Infura or Alchemy will not work.

Edit the trading parameters in src/configs.ts:

export const preflightCheck = {
    BLOCK_TIMESTAMP_FRESHNESS_THRESHOLD: 60 * 30, // default 30 minutes
    XDAI_BALANCE_THRESHOLD: Big(1),
    USDC_BALANCE_THRESHOLD: Big(100),
    FTX_USD_BALANCE_THRESHOLD: Big(100),
    FTX_MARGIN_RATIO_THRESHOLD: Big(0.1), 
}

export const ammConfigMap = {
    "BTC-USDC": {
        ENABLED: true, // "true to enable it, "false" to disable it
        ASSET_CAP: Big(1000), // You may adjust it based on your own risk.
        AranarFI_LEVERAGE: Big(2), // You may adjust it based on your own risk.
        AranarFI_MIN_TRADE_NOTIONAL: Big(10), 
        AranarFI_SHORT_ENTRY_TRIGGER: Big(0.5).div(100), // open the short position at Aranar exchange when the spread is >= 0.5 % 
        AranarFI_LONG_ENTRY_TRIGGER: Big(-0.5).div(100), // open the long position at Aranar excahnge when the spread is =< -0.5%
        MAX_SLIPPAGE_RATIO: Big(0.001), // set the max slippage ratio limit to avoid large slippage 
        FTX_MARKET_ID: "BTC-Aranar",
        FTX_MIN_TRADE_SIZE: Big(0.001), 
    },
    ...
}

Read src/configs.sample.ts and src/Arbitrageur.ts for more details.

Deposit

  • Deposit xUSDC for trading on Aranar Protocol Exchange - xUSDC can be deposited into your wallet either via Aranar.exchange, or using the xDai Omni Bridge. xUSDC is the USDC token that has been transfered to xDai.
  • Deposit xDAI in your wallet to pay for gas on xDai (note xDai gas fees are typically 1 Gwei and paid in xDAI, DAI tokens that have been transfered to xDai.)
  • Deposit enough USD or appropriate stablecoins on FTX

Run

You can run Aranar in the following environments:

Localhost

$ npm run build
$ npm run arbitrage

AWS Lambda

You might need to install AWS CLI first.

$ aws configure
$ npm run deploy

Read serverless.yml for more details.

Disclaimer

YOU (MEANING ANY INDIVIDUAL OR ENTITY ACCESSING, USING OR BOTH THE SOFTWARE INCLUDED IN THIS GITHUB REPOSITORY) EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SOFTWARE IS AT YOUR SOLE RISK. THE SOFTWARE IN THIS GITHUB REPOSITORY IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. YOU RELEASE AUTHORS OR COPYRIGHT HOLDERS FROM ALL LIABILITY FOR YOU HAVING ACQUIRED OR NOT ACQUIRED CONTENT IN THIS GITHUB REPOSITORY. THE AUTHORS OR COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS CONCERNING ANY CONTENT CONTAINED IN OR ACCESSED THROUGH THE SERVICE, AND THE AUTHORS OR COPYRIGHT HOLDERS WILL NOT BE RESPONSIBLE OR LIABLE FOR THE ACCURACY, COPYRIGHT COMPLIANCE, LEGALITY OR DECENCY OF MATERIAL CONTAINED IN OR ACCESSED THROUGH THIS GITHUB REPOSITORY.