Skip to content

Commit

Permalink
Tinlake support (#104)
Browse files Browse the repository at this point in the history
* feat: add evmBlockHandler

* fix: update eth startblock

* fix: set tinlake pools to inactive so they're not pulled into the regular pool updates

* feat: update evmHandlers and start blocks

* feat: update snapshotter to use generic object instead of substrateBlocks

* feat: add shelf abi

* feat: add currency to tinlake pools

* feat: make nft data nullable in schema

* feat: add pile abi

* feat: add more loan tracking

* feat: track tinlake loan repayments

* fix: update with all migrated contracts

* fix: remove frozen lockfile in order to add abab package

* fix: trim abis

* fix: address PR optimizations and clean up

* fix: update loan fetching and clean up

* chore: more clean up

* feat: multi-chain timekeeping
Co-authored-by: Adam Stox <[email protected]>

* fix: contract abi references
Co-authored-by: Adam Stox <[email protected]>

* chore: clean up snapshotting logic

* fix: update tests

* fix: make snapshotters async

* fix: move handleEvmBlock to its own file and rename to handleEthBlock

* fix: build

---------

Co-authored-by: Filippo Fontana <[email protected]>
  • Loading branch information
AStox and filo87 authored Feb 8, 2024
1 parent 9e7de9f commit 5b9e2c0
Show file tree
Hide file tree
Showing 19 changed files with 639 additions and 216 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/subql_deploy_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
run: yarn install --frozen-lockfile
- name: Codegen
run: |
cp chains-evm/_root.yaml project-centrifuge.yaml
cp chains-evm/_root.yaml project-ethereum.yaml
cp chains-evm/_root.yaml project-celo.yaml
yq ". *=d load(\"chains-cfg/centrifuge.yaml\")" chains-cfg/_root.yaml > project-centrifuge.yaml || true
yq ". *=d load(\"chains-evm/eth/centrifuge.yaml\")" chains-evm/_root.yaml > project-ethereum.yaml || true
yq ". *=d load(\"chains-evm/celo/centrifuge.yaml\")" chains-evm/_root.yaml > project-celo.yaml || true
yarn codegen
- name: SubQL CLI Version
run: yarn subql --version
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Test'
on:
pull_request:
branches:
branches:
- main

# This allows a subsequently queued workflow run to interrupt previous runs
Expand Down Expand Up @@ -29,9 +29,9 @@ jobs:
run: yarn install --frozen-lockfile
- name: Codegen
run: |
cp chains-evm/_root.yaml project-centrifuge.yaml
cp chains-evm/_root.yaml project-ethereum.yaml
cp chains-evm/_root.yaml project-celo.yaml
yq ". *=d load(\"chains-cfg/centrifuge.yaml\")" chains-cfg/_root.yaml > project-centrifuge.yaml || true
yq ". *=d load(\"chains-evm/eth/centrifuge.yaml\")" chains-evm/_root.yaml > project-ethereum.yaml || true
yq ". *=d load(\"chains-evm/celo/centrifuge.yaml\")" chains-evm/_root.yaml > project-celo.yaml || true
yarn codegen
- name: Build
run: yarn build
Expand Down
29 changes: 29 additions & 0 deletions abi/navfeed.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"constant": true,
"inputs": [],
"name": "currentNAV",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }],
"name": "nftID",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"name": "maturityDate",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
35 changes: 35 additions & 0 deletions abi/pile.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"constant": true,
"inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }],
"name": "debt",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"name": "loanRates",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"name": "rates",
"outputs": [
{ "internalType": "uint256", "name": "pie", "type": "uint256" },
{ "internalType": "uint256", "name": "chi", "type": "uint256" },
{ "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" },
{ "internalType": "uint48", "name": "lastUpdated", "type": "uint48" },
{ "internalType": "uint256", "name": "fixedRate", "type": "uint256" }
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
11 changes: 11 additions & 0 deletions abi/reserve.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"constant": true,
"inputs": [],
"name": "totalBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
23 changes: 23 additions & 0 deletions abi/shelf.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"constant": true,
"inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }],
"name": "token",
"outputs": [
{ "internalType": "address", "name": "registry", "type": "address" },
{ "internalType": "uint256", "name": "nft", "type": "uint256" }
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "internalType": "uint256", "name": "loan", "type": "uint256" }],
"name": "nftLocked",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
2 changes: 1 addition & 1 deletion chains-evm/_root.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ templates:
kind: ethereum/LogHandler
filter:
topics:
- Transfer(address indexed from, address indexed to, uint256 value)
- Transfer(address indexed from, address indexed to, uint256 value)
30 changes: 25 additions & 5 deletions chains-evm/eth/centrifuge.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
network:
chainId: '1' # Ethereum Mainnet
endpoint: "https://mainnet.infura.io/v3/a4ba76cd4be643618572e7467a444e3a"
dictionary: "https://gx.api.subquery.network/sq/subquery/eth-dictionary"
endpoint: 'https://mainnet.infura.io/v3/a4ba76cd4be643618572e7467a444e3a'
dictionary: 'https://gx.api.subquery.network/sq/subquery/eth-dictionary'
bypassBlocks:
- "18721040-18735450"
- "18735460-18747630"
- "18747640-18763940"
- '18721040-18735450'
- '18735460-18747630'
- '18747640-18763940'
dataSources:
- kind: ethereum/Runtime
startBlock: 18721030
options:
address: '0x78E9e622A57f70F1E0Ec652A4931E4e278e58142'
- kind: ethereum/Runtime
startBlock: 11063000
options:
abi: navFeed
assets:
navFeed:
file: './abi/navfeed.abi.json'
reserve:
file: './abi/reserve.abi.json'
shelf:
file: './abi/shelf.abi.json'
pile:
file: './abi/pile.abi.json'
mapping:
file: './dist/index.js'
handlers:
- handler: handleEthBlock
kind: ethereum/BlockHandler
filter:
modulo: 3600
4 changes: 2 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ type Loan @entity {
id: ID! # poolId - loanId
createdAt: Date!

collateralNftClassId: BigInt!
collateralNftItemId: BigInt!
collateralNftClassId: BigInt
collateralNftItemId: BigInt

metadata: String

Expand Down
Loading

0 comments on commit 5b9e2c0

Please sign in to comment.