-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: validate vault and reserve metrics data
- Loading branch information
1 parent
0df995d
commit 04c2250
Showing
6 changed files
with
388 additions
and
151 deletions.
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
.github/workflows/vaults-and-reserve-metrics-testing.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Vaults and Reserve Indexing | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Start A3P container | ||
run: docker compose --profile ci up -d a3p | ||
|
||
- name: Wait for A3P container to be ready | ||
run: | | ||
timeout 300 bash -c ' | ||
TARGET_HEIGHT=1111 | ||
SLEEP=10 | ||
echo "Waiting for the Agoric service to be fully ready..." | ||
echo "Target block height: $TARGET_HEIGHT" | ||
while true; do | ||
response=$(curl --silent http://localhost:26657/abci_info); | ||
height=$(echo $response | jq -r ".result.response.last_block_height | tonumber"); | ||
if [ "$height" -ge $TARGET_HEIGHT ]; then | ||
echo "Service is ready! Last block height: $height"; | ||
break; | ||
else | ||
echo "Waiting for last block height to reach $TARGET_HEIGHT. Current height: $height"; | ||
fi; | ||
sleep $SLEEP; | ||
done | ||
' | ||
- run: corepack enable | ||
shell: bash | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Start subql indexer | ||
env: | ||
AGORIC_NET: ci | ||
run: yarn dev | ||
|
||
- name: Print initial logs of all containers | ||
run: | | ||
echo "Fetching initial logs for all containers..." | ||
containers=$(docker ps --format '{{.ID}}') | ||
for container in $containers; do | ||
echo "Fetching initial logs for container $container..." | ||
docker logs $container | ||
done | ||
- name: Set Execute Permission for All Scripts | ||
run: chmod +x ./scripts/*.mjs | ||
|
||
- name: Wait for GraphQL server | ||
run: sleep 120 | ||
|
||
- name: Test Vaults | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: vaults | ||
blockHeight: 742 | ||
apiUrl: 'http://localhost:3000/' | ||
|
||
- name: Test VaultStatesDailies | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: vaultStatesDailies | ||
blockHeight: 742 | ||
apiUrl: 'http://localhost:3000/' | ||
|
||
- name: Test VaultManagerGovernance | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: vaultManagerGovernances | ||
blockHeight: 1212 | ||
apiUrl: 'http://localhost:3000/' | ||
|
||
- name: Test VaultManagerMetrics | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: vaultManagerMetrics | ||
blockHeight: 1212 | ||
apiUrl: 'http://localhost:3000/' | ||
|
||
- name: Test VaultManagerMetricsDaily | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: vaultManagerMetricsDailies | ||
blockHeight: 1212 | ||
apiUrl: 'http://localhost:3000/' | ||
|
||
- name: Test ReserveMetrics | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: reserveMetrics | ||
blockHeight: 1212 | ||
apiUrl: 'http://localhost:3000/' | ||
|
||
- name: Test ReserveAllocationMetrics | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: reserveAllocationMetrics | ||
blockHeight: 1212 | ||
apiUrl: 'http://localhost:3000/' | ||
|
||
- name: Test ReserveAllocationMetricsDaily | ||
run: ./scripts/validateData.mjs | ||
env: | ||
entity: reserveAllocationMetricsDailies | ||
blockHeight: 1212 | ||
apiUrl: 'http://localhost:3000/' |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
const buildFilter = (filters) => { | ||
const filterStrings = Object.entries(filters).map(([key, value]) => { | ||
return `${key}: {equalTo: "${value}"}`; | ||
}); | ||
return `(filter: {${filterStrings.join(', ')}})`; | ||
}; | ||
|
||
export const getQuery = (entity, filters) => { | ||
const filterString = buildFilter(filters); | ||
|
||
const queries = { | ||
vaults: `query { | ||
vaults ${filterString} { | ||
nodes { | ||
balance | ||
lockedValue | ||
coin | ||
denom | ||
debt | ||
state | ||
} | ||
} | ||
}`, | ||
vaultStatesDailies: `query { | ||
vaultStatesDailies ${filterString} { | ||
nodes { | ||
active | ||
closed | ||
liquidating | ||
liquidated | ||
} | ||
} | ||
}`, | ||
vaultManagerGovernances: `query { | ||
vaultManagerGovernances ${filterString} { | ||
nodes { | ||
id | ||
debtLimit | ||
interestRateDenominator | ||
interestRateNumerator | ||
liquidationMarginDenominator | ||
liquidationMarginNumerator | ||
liquidationPaddingDenominator | ||
liquidationPaddingNumerator | ||
liquidationPenaltyDenominator | ||
liquidationPenaltyNumerator | ||
mintFeeDenominator | ||
mintFeeNumerator | ||
} | ||
} | ||
}`, | ||
vaultManagerMetrics: `query { | ||
vaultManagerMetrics ${filterString} { | ||
nodes { | ||
id | ||
liquidatingCollateralBrand | ||
liquidatingCollateralValue | ||
liquidatingDebtBrand | ||
liquidatingDebtValue | ||
lockedQuoteDenominator | ||
lockedQuoteNumerator | ||
numActiveVaults | ||
numLiquidatingVaults | ||
numLiquidationsAborted | ||
numLiquidationsCompleted | ||
retainedCollateral | ||
totalCollateral | ||
totalCollateralSold | ||
totalDebt | ||
totalOverageReceived | ||
totalProceedsReceived | ||
totalShortfallReceived | ||
} | ||
} | ||
}`, | ||
vaultManagerMetricsDailies: `query { | ||
vaultManagerMetricsDailies ${filterString} { | ||
nodes { | ||
path | ||
liquidatingCollateralBrand | ||
liquidatingDebtBrand | ||
liquidatingCollateralValueLast | ||
liquidatingDebtValueLast | ||
lockedQuoteDenominatorLast | ||
lockedQuoteNumeratorLast | ||
numActiveVaultsLast | ||
numLiquidatingVaultsLast | ||
numLiquidationsAbortedLast | ||
numLiquidationsCompletedLast | ||
retainedCollateralLast | ||
totalCollateralLast | ||
totalCollateralSoldLast | ||
totalDebtLast | ||
totalOverageReceivedLast | ||
totalProceedsReceivedLast | ||
totalShortfallReceivedLast | ||
metricsCount | ||
} | ||
} | ||
}`, | ||
reserveMetrics: `query { | ||
reserveMetrics ${filterString} { | ||
nodes { | ||
id | ||
shortfallBalance | ||
totalFeeBurned | ||
totalFeeMinted | ||
} | ||
} | ||
}`, | ||
reserveAllocationMetrics: `query { | ||
reserveAllocationMetrics ${filterString} { | ||
nodes { | ||
id | ||
denom | ||
key | ||
value | ||
} | ||
} | ||
}`, | ||
reserveAllocationMetricsDailies: `query { | ||
reserveAllocationMetricsDailies ${filterString} { | ||
nodes { | ||
denom | ||
key | ||
valueLast | ||
metricsCount | ||
} | ||
} | ||
}`, | ||
}; | ||
|
||
return queries[entity]; | ||
}; | ||
|
||
export const expectations = { | ||
vaults: { | ||
balance: 788000000, | ||
lockedValue: 788000000, | ||
coin: 'ATOM', | ||
denom: 'ATOM', | ||
debt: 4745610000, | ||
state: 'active', | ||
}, | ||
vaultStatesDailies: { | ||
active: 1, | ||
closed: 0, | ||
liquidating: 0, | ||
liquidated: 0, | ||
}, | ||
vaultManagerGovernances: { | ||
id: 'published.vaultFactory.managers.manager1.governance', | ||
debtLimit: '1000000000', | ||
interestRateDenominator: '100', | ||
interestRateNumerator: '1', | ||
liquidationMarginDenominator: '100', | ||
liquidationMarginNumerator: '150', | ||
liquidationPaddingDenominator: '100', | ||
liquidationPaddingNumerator: '25', | ||
liquidationPenaltyDenominator: '100', | ||
liquidationPenaltyNumerator: '1', | ||
mintFeeDenominator: '10000', | ||
mintFeeNumerator: '50', | ||
}, | ||
vaultManagerMetrics: { | ||
liquidatingCollateralBrand: 'stATOM', | ||
liquidatingCollateralValue: '0', | ||
liquidatingDebtBrand: 'IST', | ||
liquidatingDebtValue: '0', | ||
lockedQuoteDenominator: '0', | ||
lockedQuoteNumerator: '0', | ||
numActiveVaults: '0', | ||
numLiquidatingVaults: '0', | ||
numLiquidationsAborted: '0', | ||
numLiquidationsCompleted: '0', | ||
retainedCollateral: '0', | ||
totalCollateral: '0', | ||
totalCollateralSold: '0', | ||
totalDebt: '0', | ||
totalOverageReceived: '0', | ||
totalProceedsReceived: '0', | ||
totalShortfallReceived: '0', | ||
}, | ||
vaultManagerMetricsDailies: { | ||
path: 'published.vaultFactory.managers.manager1.metrics', | ||
liquidatingCollateralBrand: 'stATOM', | ||
liquidatingDebtBrand: 'IST', | ||
liquidatingCollateralValueLast: '0', | ||
liquidatingDebtValueLast: '0', | ||
lockedQuoteDenominatorLast: '0', | ||
lockedQuoteNumeratorLast: '0', | ||
numActiveVaultsLast: '0', | ||
numLiquidatingVaultsLast: '0', | ||
numLiquidationsAbortedLast: '0', | ||
numLiquidationsCompletedLast: '0', | ||
retainedCollateralLast: '0', | ||
totalCollateralLast: '0', | ||
totalCollateralSoldLast: '0', | ||
totalDebtLast: '0', | ||
totalOverageReceivedLast: '0', | ||
totalProceedsReceivedLast: '0', | ||
totalShortfallReceivedLast: '0', | ||
metricsCount: '1', | ||
}, | ||
reserveMetrics: { | ||
id: 'published.reserve.metrics', | ||
shortfallBalance: '0', | ||
totalFeeBurned: '0', | ||
totalFeeMinted: '0', | ||
}, | ||
reserveAllocationMetrics: { | ||
id: 'IST', | ||
denom: 'IST', | ||
key: 'Fee', | ||
value: '187909157', | ||
}, | ||
reserveAllocationMetricsDailies: { | ||
denom: 'IST', | ||
key: 'Fee', | ||
valueLast: '187909157', | ||
metricsCount: '1', | ||
}, | ||
}; |
Oops, something went wrong.