-
Notifications
You must be signed in to change notification settings - Fork 78
Archi distributions #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dmax10
wants to merge
40
commits into
updates
Choose a base branch
from
archi-distributions
base: updates
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Archi distributions #244
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… known archi contracts
…deployed by archi deployer
3 accounts have negative outflows
- LPs (adding / removing liquidity) for all vaults: wbtc, weth, usdc, usdt - and remove individual vault queries
- addresses are consistent with archi-GMXExecutor-fsGLP-unique-users query, which has just 3 additional addresses -- 0x02b72485ecdaabd5f9af68d9a5d2b2ca54d5339b -- 0x60a3d336c39e8fac40647142d3068780b4bc4c93 --> archi deployer -- 0x61cd1eb8434aabdd38a0abd62dc8665e958e41d1
…dd archi docs, etc
Mostly closed / liquidated positions, but must be confirmed
…positions are terminated
…ract This CreditUser was the one used by farmers to mint the 1.6M fsGLP from GMXExecutor, and it holds the records for these farmers
…late LPs distributions, update summary docs
Use the StakeFor event instead of the AddLiquidity/RemoveLiquidity
…lculates distributions in one go)
…bute the excess to wbtc/weth LPs - Cap farmer distributions based on avg fsGLP price at position open vs $1.45 incident price - Cap USDC/USDT LP distributions so fsGLP value at $1.45 doesn't exceed deposit value - Redistribute total excess (farmer + stablecoin) to WBTC/WETH LPs proportionally
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Archi Finance distribution calculations into a unified end-to-end script
Files:
ARCHI_DISTRIBUTIONS.md- Distribution results and tablesarchiDistributions.ts- Unified calculation scriptarchiUnaccountedFsGLP.ts- Investigation script for CreditAggregator balanceWhat archiDistributions.ts does:
Step 1: Verify fsGLP Holdings
Queries on-chain balances from 3 key contracts
Step 2: Extract Active Positions
CreateUserLendCreditandCreateUserBorrowedevents from CreditUser#2isTerminated()on-chain callsStep 3: Calculate Farmer Distributions
capped_fsGLP = total_fsGLP × avg_price_at_open / 1.45Step 4: Calculate Vault Borrowing
Step 5: Calculate LP Distributions
StakeForevents from BaseReward contractsLP_fsGLP = (LP_vsTokens / total_vsTokens) × vault_borrowed_fsGLPStep 6: Apply Stablecoin Capping and Redistribute Excess
capped_fsGLP = min(original_fsGLP, deposit_usd / 1.45)Outputs
CSV Files
out/archi-farmer-positions.csv- All 47 active positions with complete borrowing details, historical GLP prices, and opening datesout/archi-farmer-distributions.csv- Final distributions for 4 farmers (includes original, capped, and recovery % columns)out/archi-lp-distributions.csv- LP distributions with per-vault vsToken balances, original amounts, capped amounts, and final distributions (405 LPs)Markdown
ARCHI_DISTRIBUTIONS.md- Auto-updated with distribution tables:PREVIEW_ALL_LPS=true)Distribution Summary (Before Capping)
Not Distributed: CreditAggregator 99.81 fsGLP (1 tx initiated by archi deployer)
Distribution Summary (After Capping & Redistribution)
Capping Methodology
Farmer IL Adjustment Capping:
capped_total = total_fsGLP × (avg_GLP_price_at_open / 1.45)Stablecoin LP Capping:
capped_fsGLP = min(original_fsGLP, (vsTokens / 1e6 × $1.00) / 1.45)Excess Redistribution to Volatile LPs:
Result: Farmers and stablecoin LPs are protected from receiving more value than they deposited, while volatile asset LPs (WBTC/WETH) absorb the excess to maintain 100% distribution of available fsGLP.