Skip to content

Commit 7383ca1

Browse files
committed
feat: enhance multi-asset ARM functionality
- Added new fields to the Arm and ArmDailyStat types in the GraphQL schema for asset decimals and rates in various currencies. - Introduced a new migration script to create necessary database tables for exchange rates, native balances, and campaign data. - Implemented the multi-asset ARM ABI, including functions and events for managing assets, market updates, and liquidity operations. - Organized ABI functions and events into separate files for better maintainability and clarity. This update expands the capabilities of the multi-asset ARM, allowing for more detailed asset management and improved data handling.
1 parent 92174d0 commit 7383ca1

18 files changed

Lines changed: 4120 additions & 111 deletions

File tree

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema.graphql

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ type Arm @entity {
766766
# alignment key for every asset* array on ArmState / ArmDailyStat. Never reorder/remove.
767767
assets: [String!]! # asset addresses, e.g. [WETH, stETH, wstETH]
768768
assetSymbols: [String!]! # e.g. ["WETH", "stETH", "wstETH"]
769+
assetDecimals: [Int!]! # ERC20 decimals, aligned to assets
769770
assetPegged: [Boolean!]! # true = 1:1 with liquidity asset (rate 1.0); [0] is always true
770771
# IAssetAdapter address per asset (from BaseAssetAdded), used for the rate via
771772
# convertToAssets. Zero address for [0] (liquidity asset) and pre-upgrade base assets.
@@ -850,12 +851,23 @@ type ArmDailyStat @entity {
850851
rateETH: Float!
851852
rateNative: Float!
852853
rateAsset1: Float! # primary base->liquidity rate; == assetRates[1] (legacy)
853-
# Aligned to Arm.assets (append-only). [0] = liquidity asset.
854+
# Historical asset registry for this snapshot. All arrays below use the same indexes;
855+
# [0] = liquidity asset and [1+] = base assets active by the end of this day.
856+
assets: [String!]!
857+
assetSymbols: [String!]!
858+
assetDecimals: [Int!]!
854859
assetBalances: [String!]! # raw balanceOf(asset i); [0] = idle liquidity
855860
# assetTotals[0] = assets0 + outstandingAssets1 + marketAssets; [i>0] = balanceOf(asset i).
856861
assetTotals: [String!]!
857-
# asset->liquidity rate, 1e18-scaled (PRICE_SCALE). [0] = 1e18; pegged base = 1e18.
862+
# Raw-unit asset->liquidity conversion factor, 1e18-scaled. This keeps
863+
# rawBalance * assetRates / 1e18 in raw liquidity units even when decimals differ.
858864
assetRates: [String!]!
865+
# Human-unit prices, all normalized to 1e18 and aligned to assets.
866+
# assetRatesLiquidity[0] = 1e18; the other arrays start with the liquidity asset's price.
867+
assetRatesLiquidity: [String!]!
868+
assetRatesUSD: [String!]!
869+
assetRatesETH: [String!]!
870+
assetRatesNative: [String!]!
859871
# Per-asset protocol redemptions in-flight, aligned to Arm.assets. [0] = 0 (liquidity asset);
860872
# [i>0] = liquidity-denominated pendingRedeemAssets for base asset i. == sum is outstandingAssets1.
861873
outstandingAssets: [String!]!
@@ -913,9 +925,9 @@ type ArmSwap @entity {
913925
# One row per (transaction, base asset, direction), paired from the tx's ERC20 Transfer logs.
914926
# Modeled as an explicit swap: tokenIn/amountIn = what the trader supplied (ARM received);
915927
# tokenOut/amountOut = what the trader received (ARM sent). amount* are RAW token units; rate*
916-
# is each token's asset0 (liquidity) rate at the swap block, 1e18-scaled (== 1e18 for the
917-
# liquidity asset and pegged base assets). Every swap has the liquidity asset on exactly one
918-
# side (the contract forbids base<->base). Derived: asset0 value = amount x rate / 1e18;
928+
# is each token's raw-unit asset0 (liquidity) conversion factor at the swap block, 1e18-scaled.
929+
# Every swap has the liquidity asset on exactly one side (the contract forbids base<->base).
930+
# Derived: raw asset0 value = raw amount x rate / 1e18;
919931
# execution price = amountOut / amountIn; spread = valueOut / valueIn.
920932
tokenIn: String! @index
921933
tokenOut: String! @index
@@ -1603,4 +1615,4 @@ type EventWOETHPriceUpdated @entity {
16031615
address: String! @index
16041616
oldValue: BigInt!
16051617
newValue: BigInt!
1606-
}
1618+
}

0 commit comments

Comments
 (0)