The IPOR Fusion SDK for Python
Project description
IPOR Fusion Python SDK
ipor_fusion
package is the official IPOR Fusion Software Development Kit (SDK) for Python. It allows Python
developers to
write software, that interacts with IPOR Fusion Plasma Vaults smart contracts deployed on Ethereum Virtual
Machine (EVM) blockchains.
ipor-fusion.py
repository is maintained by IPOR Labs AG.
Workflow | |
Social | |
Code |
Install dependencies
poetry install
Setup ARBITRUM_PROVIDER_URL environment variable
Some node providers are not supported. It's working with QuickNode but not with Alchemy.
export ARBITRUM_PROVIDER_URL="https://..."
Run tests
poetry run pytest -v -s
Run pylint
poetry run pylint --rcfile=pylintrc.toml --verbose --recursive=y .
Run black
poetry run black ./
Example of usage
ALPHA_WALLET="0x..."
uniswap_v3_swap_fuse = UniswapV3SwapFuse(ARBITRUM.PILOT.V5.UNISWAP_V3_SWAP_FUSE)
ramses_v2_new_position_fuse = RamsesV2NewPositionFuse(ARBITRUM.PILOT.V5.RAMSES_V2_NEW_POSITION_FUSE)
ramses_claim_fuse = RamsesClaimFuse(ARBITRUM.PILOT.V5.RAMSES_CLAIM_FUSE)
plasma_vault = PlasmaVault(ARBITRUM.PILOT.V5.PLASMA_VAULT)
rewards_claim_manager = RewardsClaimManager(ARBITRUM.PILOT.V5.REWARDS_CLAIM_MANAGER)
swap = uniswap_v3_swap_fuse.swap(
token_in_address=ARBITRUM.USDC,
token_out_address=ARBITRUM.USDT,
fee=100,
token_in_amount=int(500e6),
min_out_amount=0,
)
new_position = ramses_v2_new_position_fuse.new_position(
token0=ARBITRUM.USDC,
token1=ARBITRUM.USDT,
fee=50,
tick_lower=-100,
tick_upper=100,
amount0_desired=int(499e6),
amount1_desired=int(499e6),
amount0_min=0,
amount1_min=0,
deadline=int(time.time()) + 100,
ve_ram_token_id=0,
)
tx_result = plasma_vault.execute([swap, new_position])
(_, new_token_id, _, _, _, _, _, _, _, _,) = ramses_v2_new_position_fuse.extract_data_form_new_position_enter_event(
tx_result
)
claim_action = ramses_claim_fuse.claim(
token_ids=[new_token_id],
token_rewards=[[ARBITRUM.RAMSES.V2.RAM, ARBITRUM.RAMSES.V2.X_REM]],
)
# some time later ... claim RAM rewards
rewards_claim_manager.claim_rewards([claim_action])
ram_after_claim = rewards_claim_manager.balance_of(ARBITRUM.RAMSES.V2.RAM)
assert ram_after_claim > 0
# Transfer REM to ALPHA wallet
rewards_claim_manager.transfer(
ARBITRUM.RAMSES.V2.RAM, ALPHA_WALLET, ram_after_claim
)
ram_after_transfer = ram.balance_of(ALPHA_WALLET)
assert ram_after_transfer > 0
usdc_before_swap_ram = usdc.balance_of(ALPHA_WALLET)
# swap RAM -> USDC
path = [ARBITRUM.RAMSES.V2.RAM, 10000, ARBITRUM.WETH, 500, ARBITRUM.USDC]
uniswap_v3_universal_router.swap(ARBITRUM.RAMSES.V2.RAM, path, ram_after_transfer)
usdc_after_swap_ram = usdc.balance_of(ALPHA_WALLET)
rewards_in_usdc = usdc_after_swap_ram - usdc_before_swap_ram
assert rewards_in_usdc > 0
# Transfer USDC to rewards_claim_manager
usdc.transfer(to=ARBITRUM.PILOT.V5.REWARDS_CLAIM_MANAGER, amount=rewards_in_usdc)
usdc_after_transfer = usdc.balance_of(ALPHA_WALLET)
assert usdc_after_transfer == 0
# Update balance on rewards_claim_manager
rewards_claim_manager.update_balance()
rewards_claim_manager_balance_before_vesting = rewards_claim_manager.balance_of(
ARBITRUM.USDC
)
assert rewards_claim_manager_balance_before_vesting > 0
rewards_claim_manager.update_balance()
# One month later
anvil.move_time(DAY)
rewards_claim_manager.update_balance()
rewards_claim_manager_balance_after_vesting = rewards_claim_manager.balance_of(
ARBITRUM.USDC
)
assert rewards_claim_manager_balance_after_vesting == 0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ipor_fusion-0.1.1.tar.gz
(15.1 kB
view details)
Built Distribution
File details
Details for the file ipor_fusion-0.1.1.tar.gz
.
File metadata
- Download URL: ipor_fusion-0.1.1.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6db720cb056608f2988556d3c6850d9d0d55eff0d7718ebb73630b46a5bbce41 |
|
MD5 | b7c5ad366c35f804c0c3101964a56b65 |
|
BLAKE2b-256 | 47f5bed84b7895317b1f1651591d4d0ba12dc76ade69e06bb750ad541d0550d2 |
File details
Details for the file ipor_fusion-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: ipor_fusion-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 627b3c9d6c9256d3b51e62b1f9ae79a7fc2d11966879c166799ce4aede1eb54c |
|
MD5 | 40b755eedbd0f63c68e8eb6568a87b04 |
|
BLAKE2b-256 | 1304d439bf2a1802eeb3cb3f3ab9d9c32b8ce3175dcf98b9d91ba00a32968af3 |