-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ee6e6b
commit 2f0f44d
Showing
19 changed files
with
12,769 additions
and
0 deletions.
There are no files selected for viewing
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,222 @@ | ||
# @acala-network/acala-loan-subql | ||
|
||
## Cookbook | ||
|
||
### 1. Query user's position | ||
|
||
#### **Property** | ||
|
||
| property | desc | | ||
| ----- | ----- | | ||
| ownerId | the position's owner address | | ||
| callateralId | the position's collateral id | | ||
| depositAmount | the amount of collateral deposited in the position | | ||
| debitAmount | the amount of debit issued in the position | | ||
| updateAt | the timestamp when last update | | ||
| updateAtBlockId | the block number when last update | | ||
|
||
|
||
#### **Example** | ||
```graphql | ||
query { | ||
positions(filter:{ownerId:{equalTo:"25E8NfHMza8XaA7AQvwn1SMFMbk4nZmqmcXF2LbSCurWV2Cr"}}) { | ||
nodes { | ||
ownerId | ||
collateralId | ||
depositAmount | ||
debitAmount | ||
updateAt | ||
updateAtBlockId | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### 2. Query Collateral Information | ||
|
||
#### **Property** | ||
|
||
| property | desc | | ||
| -- | -- | | ||
| id | the name of the collateral token | | ||
| decimals | the decimals of the collateral token | | ||
| depositAmount | the total amount of collateral deposited in the kind of position | | ||
| debitAmount | the total amount of debit issued in the kind of position | | ||
| collateralParams | the params config of the kind of posiition | | ||
| collateralParams.liquidtionRatio | liquidtionRation | | ||
| collateralParams.liquidationPenalty | liquidationPenalty | | ||
| collateralParams.maximumTotalDebitValue| maximumTotalDebitValue | | ||
| collateralParams.requiredCollateralRatio | requiredfCollatearlRatio | | ||
| collateralParams.interestRatePerSec | interestRatePerSec | | ||
|
||
#### **Example** | ||
```graphql | ||
query { | ||
collaterals(filter:{id:{equalTo:"DOT"}}) { | ||
nodes { | ||
id | ||
decimals | ||
depositAmount | ||
debitAmount | ||
collateralParams { | ||
nodes { | ||
id, | ||
liquidationRatio | ||
liquidationPenalty | ||
maximumTotalDebitValue | ||
requiredCollateralRatio | ||
interestRatePerSec | ||
updateAt | ||
updateAtBlockId | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### 3. Query Collateral Params History | ||
|
||
#### **Property** | ||
| property | desc | | ||
| -- | -- | | ||
| liquidtionRatio | liquidtionRation | | ||
| liquidationPenalty | liquidationPenalty | | ||
| maximumTotalDebitValue| maximumTotalDebitValue | | ||
| requiredCollateralRatio | requiredfCollatearlRatio | | ||
| interestRatePerSec | interestRatePerSec | | ||
| startAt | when the params start to use | | ||
| startAtBlockId | which block height the params start to use | | ||
| endAt | when the params end to use | | ||
| endAtBlockId | which block height the params end to use (not include) | | ||
|
||
|
||
#### **Example** | ||
```graphql | ||
query { | ||
collateralParamsHistories(filter:{collateralId:{equalTo:"DOT"}}) { | ||
nodes { | ||
id, | ||
liquidationRatio | ||
liquidationPenalty | ||
maximumTotalDebitValue | ||
requiredCollateralRatio | ||
interestRatePerSec | ||
startAt | ||
startAtBlockId | ||
endAt | ||
endAtBlockId | ||
} | ||
} | ||
} | ||
``` | ||
|
||
4. Query the UpdatePosition action | ||
|
||
#### **Property** | ||
| property | desc | | ||
| -- | -- | | ||
| collateralId | collateral | | ||
| ownerId | the owner's address | | ||
| debitAdjustment | debit changed amount | | ||
| collateralAdjustment | collateral changed amount | | ||
| debitAdjustmentUSD | debit change value (USD) | | ||
| collateralAdjustmentUSD | collateral change value (USD) | | ||
| price | the collateral price at the action | | ||
| extrinsic | the extrinsic hash | | ||
| timestamp | the time of the event | | ||
| blockId | the block id | | ||
|
||
#### **Example** | ||
```graphql | ||
query { | ||
updatePositions(filter:{collateralId:{equalTo:"DOT"}} orderBy:TIMESTAMP_DESC) { | ||
nodes { | ||
id, | ||
collateralId | ||
ownerId | ||
debitAdjustment | ||
collateralAdjustment | ||
debitAdjustmentUSD | ||
collateralAdjustmentUSD | ||
price | ||
extrinsicId | ||
timestamp | ||
blockId | ||
} | ||
} | ||
} | ||
``` | ||
|
||
4. Query the CloseByDex action | ||
|
||
#### **Property** | ||
| property | desc | | ||
| -- | -- | | ||
| collateralId | collateral | | ||
| ownerId | the owner's address | | ||
| soldAmount | the amount of sold collaterals | | ||
| refundAmount | the amount of refunded collateals | | ||
| debitVolumeUSD | the amount of cleared debits | | ||
| soldVolumeUSD | the USD vlaue of sold collaterals | | ||
| refunedVolumeUSD | the USD vlaue of refunded collaterals | | ||
| price | the collateral price at the action | | ||
| extrinsic | the extrinsic hash | | ||
| timestamp | the time of the event | | ||
| blockId | the block id | | ||
|
||
#### **Example** | ||
```graphql | ||
query { | ||
closeByDexes(filter:{collateralId:{equalTo:"DOT"}} orderBy:TIMESTAMP_DESC) { | ||
nodes { | ||
id, | ||
collateralId | ||
ownerId | ||
soldAmount | ||
debitVolumeUSD | ||
refundAmount | ||
soldVolumeUSD | ||
refundVolumeUSD | ||
price | ||
extrinsicId | ||
timestamp | ||
blockId | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
### 5. Query ConfiscatePositions Actions | ||
| property | desc | | ||
| -- | -- | | ||
| collateralId | collateral | | ||
| ownerId | the owner's address | | ||
| debitAdjustment | debit changed amount | | ||
| collateralAdjustment | collateral changed amount | | ||
| debitAdjustmentUSD | debit change value (USD) | | ||
| collateralAdjustmentUSD | collateral change value (USD) | | ||
| price | the collateral price at the action | | ||
| extrinsic | the extrinsic hash | | ||
| timestamp | the time of the event | | ||
| blockId | the block id | | ||
|
||
```graphql | ||
query { | ||
confiscatePositions(filter:{collateralId:{equalTo:"DOT"}} orderBy:TIMESTAMP_DESC) { | ||
nodes { | ||
id, | ||
collateralId | ||
ownerId | ||
collateralAdjustment | ||
debitAdjustment | ||
collateralAdjustmentUSD | ||
debitAdjustmentUSD | ||
extrinsicId | ||
timestamp | ||
blockId | ||
} | ||
} | ||
} | ||
``` |
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,51 @@ | ||
specVersion: 1.0.0 | ||
name: acala-liquid-staking | ||
version: 1.0.0 | ||
description: 'liquid protocal statistics' | ||
repository: 'https://github.com/AcalaNetwork/acala-tokens-subql' | ||
runner: | ||
node: | ||
name: "@subql/node" | ||
version: "1.21.1" | ||
query: | ||
name: "@subql/query" | ||
version: "1.1.1" | ||
schema: | ||
file: ./schema.graphql | ||
network: | ||
chainId: "0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c" | ||
dictionary: https://api.subquery.network/sq/subquery/acala-dictionary | ||
endpoint: wss://acala.polkawallet.io | ||
chaintypes: | ||
file: './dist/chain-types.js' | ||
dataSources: | ||
- kind: substrate/Runtime | ||
startBlock: 3000000 | ||
mapping: | ||
file: "./dist/index.js" | ||
handlers: | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: Minted | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: RedeemedByFastMatch | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: RedeemedByUnbond | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: CurrentEraBumped | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: LedgerBondedReset |
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,48 @@ | ||
version: '3' | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- .data/postgres:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
|
||
subquery-node: | ||
image: onfinality/subql-node:v1.21.1 | ||
depends_on: | ||
- "postgres" | ||
restart: always | ||
environment: | ||
DB_USER: postgres | ||
DB_PASS: postgres | ||
DB_DATABASE: postgres | ||
DB_HOST: postgres | ||
DB_PORT: 5432 | ||
volumes: | ||
- ./:/app | ||
command: | ||
- --subquery=/app | ||
- --db-schema=acala-loan | ||
- --schema=acala-loan | ||
|
||
graphql-engine: | ||
image: onfinality/subql-query:latest | ||
ports: | ||
- 3000:3000 | ||
depends_on: | ||
- "postgres" | ||
- "subquery-node" | ||
restart: always | ||
environment: | ||
DB_USER: postgres | ||
DB_PASS: postgres | ||
DB_DATABASE: postgres | ||
DB_HOST: postgres | ||
DB_PORT: 5432 | ||
command: | ||
- --name=acala-loans | ||
- --playground | ||
- --indexer=http://subquery-node: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
specVersion: 1.0.0 | ||
name: karura-liquid-staking | ||
version: 1.0.0 | ||
description: 'liquid protocal statistics' | ||
runner: | ||
node: | ||
name: "@subql/node" | ||
version: "1.21.1" | ||
query: | ||
name: "@subql/query" | ||
version: "1.1.1" | ||
schema: | ||
file: ./schema.graphql | ||
network: | ||
chainId: '0xbaf5aabe40646d11f0ee8abbdc64f4a4b7674925cba08e4a05ff9ebed6e2126b' | ||
dictionary: https://api.subquery.network/sq/subquery/karura-dictionary | ||
endpoint: wss://karura.api.onfinality.io/public-ws | ||
chaintypes: | ||
file: './dist/chain-types.js' | ||
dataSources: | ||
- kind: substrate/Runtime | ||
startBlock: 3800000 | ||
mapping: | ||
file: "./dist/index.js" | ||
handlers: | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: Minted | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: RedeemedByFastMatch | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: RedeemedByUnbond | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: CurrentEraBumped | ||
- handler: sync | ||
kind: substrate/EventHandler | ||
filter: | ||
module: homa | ||
method: LedgerBondedReset |
Oops, something went wrong.