Skip to content

Add update redeemable positions command#630

Merged
cyc60 merged 60 commits intov5-releasefrom
redeemable-positions
Feb 16, 2026
Merged

Add update redeemable positions command#630
cyc60 merged 60 commits intov5-releasefrom
redeemable-positions

Conversation

@cyc60
Copy link
Copy Markdown
Contributor

@cyc60 cyc60 commented Jan 8, 2026

No description provided.

Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings January 8, 2026 21:41
@cyc60 cyc60 marked this pull request as draft January 8, 2026 21:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new command to update redeemable positions for users who have minted osToken shares. The command fetches allocator data from the graph, filters out leverage positions, calculates kept tokens (both in wallets and locked in protocols), determines redeemable amounts, and uploads the results to IPFS.

Key Changes:

  • Introduces the update_redeemable_positions command with supporting graph queries and API client
  • Adds ERC20 contract wrapper and OS_TOKEN_CONTRACT_ADDRESS configuration for each network
  • Expands IPFS configuration to support multiple upload clients (local, Infura, Pinata)

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/commands/internal/update_redeemable_positions.py Main command implementation to fetch, calculate, and upload redeemable positions
src/redeem/typings.py Data classes for Allocator and RedeemablePosition entities
src/redeem/graph.py Graph queries to fetch allocators and leverage position proxies
src/redeem/api_client.py API client to fetch locked osToken data from external protocol
src/common/contracts.py ERC20 contract wrapper for token balance queries
src/common/clients.py IPFS upload client builder supporting multiple providers
src/config/settings.py IPFS upload settings and increased graph timeout/page size defaults
src/config/networks.py OS_TOKEN_CONTRACT_ADDRESS added for each network
src/main.py Command registration in CLI
src/reward_splitter/graph.py Added pagination parameters to existing graph queries
src/common/abi/Erc20Token.json ERC20 ABI definition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cyc60 added 2 commits January 9, 2026 01:36
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings January 12, 2026 11:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 16 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +47 to +55
async def _fetch_json(self, url: str, params: dict | None = None) -> dict | list:
async with aiohttp.ClientSession() as session:
async with session.get(
url=url,
params=params,
headers={'user-agent': DEFAULT_USER_AGENT},
) as response:
response.raise_for_status()
return await response.json()
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new aiohttp.ClientSession for each request is inefficient. Create the session once in init or use a session pool to reuse connections across multiple API calls.

Copilot uses AI. Check for mistakes.
cyc60 added 2 commits January 12, 2026 22:30
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings January 12, 2026 20:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 16 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cyc60 added 4 commits January 13, 2026 14:08
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings January 13, 2026 15:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cyc60 added 2 commits January 13, 2026 18:12
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings January 13, 2026 16:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cyc60 added 2 commits January 13, 2026 19:55
Signed-off-by: cyc60 <avsysoev60@gmail.com>

# Conflicts:
#	poetry.lock
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings January 13, 2026 16:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 18 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cyc60 and others added 2 commits January 13, 2026 21:23
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings January 19, 2026 07:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 18 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 26 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36'
)
SUPPORTED_CHAINS = {'eth', 'arb'}
API_SLEEP_TIMEOUT = 1
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API_SLEEP_TIMEOUT is a hardcoded constant. Consider making this configurable via settings to allow different timeout values for different environments or when rate limits change.

Suggested change
API_SLEEP_TIMEOUT = 1
API_SLEEP_TIMEOUT = getattr(settings, 'API_SLEEP_TIMEOUT', 1)

Copilot uses AI. Check for mistakes.
)
allocators = _reduce_boosted_amount(allocators, boost_ostoken_shares)

# filter zero positions. Filter before kept shares calculation to reduce api calls
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable min_os_token_position_amount_gwei is already in Gwei units based on its name and CLI parameter, so converting it using Web3.to_wei(..., 'gwei') is correct. However, this could be made clearer by renaming the parameter to explicitly indicate it's in Gwei or adding a comment explaining the conversion.

Suggested change
# filter zero positions. Filter before kept shares calculation to reduce api calls
# filter zero positions. Filter before kept shares calculation to reduce api calls
# NOTE: min_os_token_position_amount_gwei is already specified in Gwei (e.g. via CLI),
# so we intentionally convert it from Gwei to Wei here for on-chain comparisons.

Copilot uses AI. Check for mistakes.
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Copilot AI review requested due to automatic review settings February 4, 2026 10:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 26 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.ipfs_local_password: str | None = decouple_config('IPFS_LOCAL_PASSWORD', default=None)

# infura
self.ipfs_infura_client_endpoint: str = '/dns/ipfs.infura.io/tcp/5001/https'
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Infura IPFS endpoint is hardcoded rather than being configurable via environment variable. Consider making this configurable like the local endpoint to allow flexibility for different environments or alternative IPFS gateways.

Suggested change
self.ipfs_infura_client_endpoint: str = '/dns/ipfs.infura.io/tcp/5001/https'
self.ipfs_infura_client_endpoint: str = decouple_config(
'IPFS_INFURA_CLIENT_ENDPOINT',
default='/dns/ipfs.infura.io/tcp/5001/https',
)

Copilot uses AI. Check for mistakes.
@cyc60 cyc60 changed the base branch from master to v5-release February 4, 2026 14:38
tmp_allocators: defaultdict[str, dict[str, Wei]] = defaultdict(dict)
allocators: list[Allocator] = []
for item in response:
if int(item['mintedOsTokenShares']) > 0:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request will be much faster if you add this filter to the query: 141k vs 2.6k entries

cyc60 added 11 commits February 5, 2026 21:16
Signed-off-by: cyc60 <avsysoev60@gmail.com>

# Conflicts:
#	poetry.lock
#	pyproject.toml
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>

# Conflicts:
#	poetry.lock
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>
Signed-off-by: cyc60 <avsysoev60@gmail.com>

# Conflicts:
#	src/common/contracts.py
cyc60 and others added 2 commits February 11, 2026 14:47
Signed-off-by: cyc60 <avsysoev60@gmail.com>
@cyc60 cyc60 merged commit 6222549 into v5-release Feb 16, 2026
5 checks passed
@cyc60 cyc60 deleted the redeemable-positions branch February 16, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants