Skip to main content

Across

Across is the fastest, cheapest and most secure cross-chain bridge. It is a system that uses UMA contracts to quickly move tokens across chains. This contains various utilities to support applications on across.

How to use

Get suggested fees from online API

Use across official API to get suggested fees.

>>> import across
>>> a = across.AcrossAPI()
>>> a.suggested_fees("0x7f5c764cbc14f9669b88837ca1490cca17c31607", 10, 1000000000)
{'slowFeePct': '43038790000000000', 'instantFeePct': '5197246000000000'}

Fee Calculator

Calculates lp fee percentages when doing a transfer.

from across.fee_calculator import (
    calculate_apy_from_utilization,
    calculate_realized_lp_fee_pct,
)
from across.utils import toBNWei

rate_model = {
    "UBar": toBNWei("0.65"),
    "R0": toBNWei("0.00"),
    "R1": toBNWei("0.08"),
    "R2": toBNWei("1.00"),
}

interval = { "utilA": 0, "utilB": toBNWei(0.01), "apy": 615384615384600, "wpy": 11830749673498 }
apy_fee_pct = calculate_apy_from_utilization(rate_model, interval["utilA"], interval["utilB"])
assert apy_fee_pct == interval["apy"]

realized_lp_fee_pct = calculate_realized_lp_fee_pct(rate_model, interval["utilA"], interval["utilB"])
assert realized_lp_fee_pct == interval["wpy"]

LP Fee Calculator

Get lp fee calculations by timestamp.

from across import LpFeeCalculator
from web3 import Web3

provider = Web3.WebsocketProvider("{YOUR-PROVIDER-ADDRESS}")
calculator = LpFeeCalculator(provider)
token_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # WETH on mainnet
bridge_pool_address = "0x7355Efc63Ae731f584380a9838292c7046c1e433" # WETH BridgePool on mainnet
amount = "1000000000000000000" # 1 ETH
timestamp = 1645000000 # timestamp in seconds
percent = calculator.get_lp_fee_pct(
    token_address, bridge_pool_address, amount, timestamp
)
print(percent)

How to build and test

Install poetry and install the dependencies:

pip3 install poetry

poetry install

# test
python -m unittest

# local install and test
pip3 install twine
python3 -m twine upload --repository testpypi dist/*
pip3 install --index-url https://test.pypi.org/simple/ --no-deps across

Metadata

Release files for across-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for across-py 0.1.0
File Size Uploaded Provenance
across-py-0.1.0.tar.gz 10.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for across-py 0.1.0
File Interpreter ABI Platform
across_py-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / across-py-0.1.0.tar.gz

Download URL across-py-0.1.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
320cb3d17e57189afd523e16e2b9dbf4d94417f522504a60267b9d3e2f2a5bbe
BLAKE2b-256 checksum
How to use checksums
90a7591b171589978f59be3e009f44a0360222fbfeb5d671ebac0dbcaaf07485
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.5

Release files / across_py-0.1.0-py3-none-any.whl

Download URL across_py-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3558bff88d91061256f13198ff6d4a1c2e3b6f281835bce5ec7a25dfc7525d0
BLAKE2b-256 checksum
How to use checksums
bb9cdd378d441126bbb1befaaa8665ef37e81037a06414aeeed27d09569ff561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.5

Security for across-py 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page