Skip to main content

A powerful Python SDK for developing and deploying autonomous DeFi agents. Features agent-based modeling, state machine architecture, and non-custodial execution through Safe smart accounts

Project description

Almanak SDK

PyPI version

The Almanak SDK is a powerful Python library for developing, testing, and deploying autonomous DeFi agents. Built on an intent-based architecture, it provides a comprehensive framework for creating sophisticated trading strategies with minimal boilerplate.

Features

  • Intent-Based Architecture: Express trading logic as high-level intents (Swap, LP, Borrow, etc.) - the framework handles compilation and execution
  • Gateway Security: All external access mediated through secure gRPC gateway
  • Three-Tier State Management: Automatic persistence with HOT/WARM/COLD tiers
  • Comprehensive Backtesting: PnL simulation, paper trading on Anvil forks, and parameter sweeps
  • Multi-Chain Support: Ethereum, Arbitrum, Optimism, Base, Avalanche, Polygon, BSC, Sonic, Blast, Mantle, Berachain
  • Protocol Integration: Uniswap V3, Aave V3, Morpho Blue, GMX V2, Lido, Ethena, Polymarket, Kraken, and more
  • Non-Custodial Design: Full control over your funds through Safe smart accounts

Installation

pip install almanak

Quick Start

  1. Create a New Strategy

    almanak strat new
    
  2. Start the Gateway and Test

    # Terminal 1: Start gateway
    almanak gateway
    
    # Terminal 2: Run strategy
    cd my_strategy
    almanak strat run --once
    

Writing a Strategy

Strategies use an intent-based architecture. Implement the decide() method to return an intent:

from almanak import IntentStrategy, SwapIntent, HoldIntent, MarketSnapshot

class MyStrategy(IntentStrategy):
    def decide(self, market: MarketSnapshot) -> Intent:
        eth_price = market.prices.get("ETH")
        usdc_balance = market.balances.get("USDC")

        if eth_price < 2000 and usdc_balance > 1000:
            return SwapIntent(
                token_in="USDC",
                token_out="ETH",
                amount=1000,
                slippage=0.005,
            )
        return HoldIntent(reason="Waiting for better conditions")

Supported Networks

Ethereum, Arbitrum, Optimism, Base, Avalanche, Polygon, BSC, Sonic, Plasma, Blast, Mantle, Berachain

Supported Protocols

  • DEXs: Uniswap V3, SushiSwap V3, PancakeSwap V3, TraderJoe V2, Aerodrome, Curve, Balancer
  • Lending: Aave V3, Morpho Blue, Compound V3, Spark
  • Liquid Staking: Lido, Ethena
  • Yield: Pendle
  • Perpetuals: GMX V2, Hyperliquid
  • Prediction Markets: Polymarket
  • CEX Integration: Kraken
  • Aggregators: Enso, LiFi

Documentation

For detailed documentation, visit docs.almanak.co

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

almanak-2.1.0-py3-none-win_amd64.whl (46.1 MB view details)

Uploaded Python 3Windows x86-64

almanak-2.1.0-py3-none-manylinux_2_17_x86_64.whl (44.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

almanak-2.1.0-py3-none-manylinux_2_17_aarch64.whl (43.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

almanak-2.1.0-py3-none-macosx_11_0_x86_64.whl (29.6 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

almanak-2.1.0-py3-none-macosx_11_0_arm64.whl (27.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file almanak-2.1.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: almanak-2.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 46.1 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for almanak-2.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5a245ef204516f6aa6be3ff70a7915a40958a94a453d127cb11f6e0de30dd54a
MD5 e377d641d136fff8372aa5d70eea1ba5
BLAKE2b-256 fa1594024a1c38bcee9a97763b74edbc2176d2bfb7b2bc1e1a88d9ea523a6f6e

See more details on using hashes here.

File details

Details for the file almanak-2.1.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for almanak-2.1.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 b90feec0fd30ba08a39ce5c47f1a6f75140a4f2940161c6cda1158fbbf48c48f
MD5 e9b0fedcd9a2364ae94eed4e0081ee19
BLAKE2b-256 280e0a25022e940f28a550d983af3e36d276230aec98838171044ab57d4f1dc1

See more details on using hashes here.

File details

Details for the file almanak-2.1.0-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for almanak-2.1.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 81e321f9fbc8d1f78f87da30ddf37d27bab6db4ecc9c182cb96e819970751425
MD5 19bec1d1d6f54fdbdedc7603ffa6e9d4
BLAKE2b-256 946b997b374da6dc519f73b154156c6c553905438f3414c3e3da2d8761ac7eb4

See more details on using hashes here.

File details

Details for the file almanak-2.1.0-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for almanak-2.1.0-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 1a8829497b13916e2dc3345f4bbf9be376fa5508ff42f9519783bc12e5e94933
MD5 fe5cbab68d731be4092a88344b7e45e6
BLAKE2b-256 8b59049435b84099bed765353ce7f3c2bd91e32c507c2ae3ebc792150bcd8ebb

See more details on using hashes here.

File details

Details for the file almanak-2.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for almanak-2.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5945ffe175d18448f14a4a98baa3c8257ced079454e0b576aa24c4cd54f51ba1
MD5 33e61253cf236227ed04315691a0700a
BLAKE2b-256 c12e6a2914c40e394b432ff6f83270022c47fa79d76c0ef20a7ae86ac60498c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page