2022-09-23 14:54:27 +02:00
|
|
|
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
Implementing first pass of veAllocate schema, handlers, and test cove… (#490)
* Implementing first pass of veAllocate schema, handlers, and test coverage.
* Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come.
* Created documentation. Moving tests away from subgraph and into df-py.
* Expanding documentation to be thorough and cover more of the work involved.
* use barge artifacts
* use proper contracts in ci
* use barge artifacts folder
* fix replace
* use npm contracts dep
* use latest contracts for barge
* fix some lint
* Fix linter errors
* Update schema
* Finished basic integration of setAllocation event and verified queries/schema is working as intended.
* Fixing amount getter.
* Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors.
* Fixing import.
* Use .zero()
* Improve readability
* Add allocated to schema
* Update abi
* Update event handlers in the template
* Update veREADME
* Remove `AllocationRemoved` handler
* Hooking data for tx, firstContact, lastUpdate, block
* Update event abi
* Add chainId and nftAddress to schema
* Update `handleAllocationSet`
* Update abi
* Update readme
* Set initial values
* Fix math
* Missing event param
* set initial value of `lastContact`
* veOcean template
* VeOcean entity
* Handler functions - wip
* rename file
* Delegation schema
* veDelegate mapping file
* Rename
* Update template
* Update schema
* Update replaces
* Add handler for delegation
* Update schema
* getveDelegation
* Update naming
* Add deposit entity
* Update template
* Make delegation an array
* Add `handleDelegation`
* Add `handleDeposit` for veOCEAN
* Add `getveOCEAN` util function
* Add `getDeposit` util function
* Add `handleBurnBoost`
* Add `handleExtendBoost`
* Add `handleTransferBoost`
* Set default veOCEAN
* Remove unused import
* Rename Deposit to VeDeposit
* Include block number
* Remove `allocatedTotal`
* Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not..
* bump contracts to v1.1.1
* bump contracts
* bump to contracts 1.1.2
* fix script for networks without ve
* add veAllocation.sol's AllocationSetMultiple
* copy artfacts from barge for npm quickstart:barge
* fix using barge artifacts
* temp debug
* use barge artifacts
* use contracts 1.1.3
* use same approach for 'development'
* bump ocean-contracts
Co-authored-by: alexcos20 <alex.coseru@gmail.com>
Co-authored-by: mihaisc <mihai@oceanprotocol.com>
Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
|
|
|
import { Deposit, Supply, Withdraw } from '../@types/veOCEAN/veOCEAN'
|
|
|
|
import { weiToDecimal } from './utils/generic'
|
|
|
|
import { getDeposit, getveOCEAN } from './utils/veUtils'
|
|
|
|
|
|
|
|
export function handleDeposit(event: Deposit): void {
|
|
|
|
const provider = event.params.provider
|
|
|
|
const value = event.params.value
|
|
|
|
const locktime = event.params.locktime
|
|
|
|
const type = event.params.type
|
|
|
|
const ts = event.params.ts
|
|
|
|
|
2022-09-23 14:54:27 +02:00
|
|
|
const veOCEAN = getveOCEAN(provider.toHex())
|
Implementing first pass of veAllocate schema, handlers, and test cove… (#490)
* Implementing first pass of veAllocate schema, handlers, and test coverage.
* Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come.
* Created documentation. Moving tests away from subgraph and into df-py.
* Expanding documentation to be thorough and cover more of the work involved.
* use barge artifacts
* use proper contracts in ci
* use barge artifacts folder
* fix replace
* use npm contracts dep
* use latest contracts for barge
* fix some lint
* Fix linter errors
* Update schema
* Finished basic integration of setAllocation event and verified queries/schema is working as intended.
* Fixing amount getter.
* Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors.
* Fixing import.
* Use .zero()
* Improve readability
* Add allocated to schema
* Update abi
* Update event handlers in the template
* Update veREADME
* Remove `AllocationRemoved` handler
* Hooking data for tx, firstContact, lastUpdate, block
* Update event abi
* Add chainId and nftAddress to schema
* Update `handleAllocationSet`
* Update abi
* Update readme
* Set initial values
* Fix math
* Missing event param
* set initial value of `lastContact`
* veOcean template
* VeOcean entity
* Handler functions - wip
* rename file
* Delegation schema
* veDelegate mapping file
* Rename
* Update template
* Update schema
* Update replaces
* Add handler for delegation
* Update schema
* getveDelegation
* Update naming
* Add deposit entity
* Update template
* Make delegation an array
* Add `handleDelegation`
* Add `handleDeposit` for veOCEAN
* Add `getveOCEAN` util function
* Add `getDeposit` util function
* Add `handleBurnBoost`
* Add `handleExtendBoost`
* Add `handleTransferBoost`
* Set default veOCEAN
* Remove unused import
* Rename Deposit to VeDeposit
* Include block number
* Remove `allocatedTotal`
* Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not..
* bump contracts to v1.1.1
* bump contracts
* bump to contracts 1.1.2
* fix script for networks without ve
* add veAllocation.sol's AllocationSetMultiple
* copy artfacts from barge for npm quickstart:barge
* fix using barge artifacts
* temp debug
* use barge artifacts
* use contracts 1.1.3
* use same approach for 'development'
* bump ocean-contracts
Co-authored-by: alexcos20 <alex.coseru@gmail.com>
Co-authored-by: mihaisc <mihai@oceanprotocol.com>
Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
|
|
|
// Create new Deposit entity
|
2023-01-25 11:18:23 +01:00
|
|
|
const deposit = getDeposit(
|
|
|
|
provider.toHex() +
|
|
|
|
'-' +
|
|
|
|
event.transaction.hash.toHex() +
|
|
|
|
'-' +
|
|
|
|
event.logIndex.toString()
|
|
|
|
)
|
Implementing first pass of veAllocate schema, handlers, and test cove… (#490)
* Implementing first pass of veAllocate schema, handlers, and test coverage.
* Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come.
* Created documentation. Moving tests away from subgraph and into df-py.
* Expanding documentation to be thorough and cover more of the work involved.
* use barge artifacts
* use proper contracts in ci
* use barge artifacts folder
* fix replace
* use npm contracts dep
* use latest contracts for barge
* fix some lint
* Fix linter errors
* Update schema
* Finished basic integration of setAllocation event and verified queries/schema is working as intended.
* Fixing amount getter.
* Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors.
* Fixing import.
* Use .zero()
* Improve readability
* Add allocated to schema
* Update abi
* Update event handlers in the template
* Update veREADME
* Remove `AllocationRemoved` handler
* Hooking data for tx, firstContact, lastUpdate, block
* Update event abi
* Add chainId and nftAddress to schema
* Update `handleAllocationSet`
* Update abi
* Update readme
* Set initial values
* Fix math
* Missing event param
* set initial value of `lastContact`
* veOcean template
* VeOcean entity
* Handler functions - wip
* rename file
* Delegation schema
* veDelegate mapping file
* Rename
* Update template
* Update schema
* Update replaces
* Add handler for delegation
* Update schema
* getveDelegation
* Update naming
* Add deposit entity
* Update template
* Make delegation an array
* Add `handleDelegation`
* Add `handleDeposit` for veOCEAN
* Add `getveOCEAN` util function
* Add `getDeposit` util function
* Add `handleBurnBoost`
* Add `handleExtendBoost`
* Add `handleTransferBoost`
* Set default veOCEAN
* Remove unused import
* Rename Deposit to VeDeposit
* Include block number
* Remove `allocatedTotal`
* Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not..
* bump contracts to v1.1.1
* bump contracts
* bump to contracts 1.1.2
* fix script for networks without ve
* add veAllocation.sol's AllocationSetMultiple
* copy artfacts from barge for npm quickstart:barge
* fix using barge artifacts
* temp debug
* use barge artifacts
* use contracts 1.1.3
* use same approach for 'development'
* bump ocean-contracts
Co-authored-by: alexcos20 <alex.coseru@gmail.com>
Co-authored-by: mihaisc <mihai@oceanprotocol.com>
Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
|
|
|
deposit.provider = provider.toHex()
|
|
|
|
deposit.value = weiToDecimal(value.toBigDecimal(), 18)
|
|
|
|
deposit.unlockTime = locktime
|
|
|
|
deposit.type = type
|
|
|
|
deposit.timestamp = ts
|
2022-09-07 12:30:53 +02:00
|
|
|
deposit.block = event.block.number.toI32()
|
|
|
|
deposit.tx = event.transaction.hash.toHex()
|
2022-09-23 14:54:27 +02:00
|
|
|
deposit.sender = event.transaction.from.toHex()
|
|
|
|
deposit.veOcean = veOCEAN.id
|
Implementing first pass of veAllocate schema, handlers, and test cove… (#490)
* Implementing first pass of veAllocate schema, handlers, and test coverage.
* Fixed compiling issues, wrote compiling & testing outline inside of veAllocate.test. More to come.
* Created documentation. Moving tests away from subgraph and into df-py.
* Expanding documentation to be thorough and cover more of the work involved.
* use barge artifacts
* use proper contracts in ci
* use barge artifacts folder
* fix replace
* use npm contracts dep
* use latest contracts for barge
* fix some lint
* Fix linter errors
* Update schema
* Finished basic integration of setAllocation event and verified queries/schema is working as intended.
* Fixing amount getter.
* Fixed remaining implementation, verified SimpleSubgraph.test is working, and fixed lint errors.
* Fixing import.
* Use .zero()
* Improve readability
* Add allocated to schema
* Update abi
* Update event handlers in the template
* Update veREADME
* Remove `AllocationRemoved` handler
* Hooking data for tx, firstContact, lastUpdate, block
* Update event abi
* Add chainId and nftAddress to schema
* Update `handleAllocationSet`
* Update abi
* Update readme
* Set initial values
* Fix math
* Missing event param
* set initial value of `lastContact`
* veOcean template
* VeOcean entity
* Handler functions - wip
* rename file
* Delegation schema
* veDelegate mapping file
* Rename
* Update template
* Update schema
* Update replaces
* Add handler for delegation
* Update schema
* getveDelegation
* Update naming
* Add deposit entity
* Update template
* Make delegation an array
* Add `handleDelegation`
* Add `handleDeposit` for veOCEAN
* Add `getveOCEAN` util function
* Add `getDeposit` util function
* Add `handleBurnBoost`
* Add `handleExtendBoost`
* Add `handleTransferBoost`
* Set default veOCEAN
* Remove unused import
* Rename Deposit to VeDeposit
* Include block number
* Remove `allocatedTotal`
* Updating schema and fixing errors due to naming changes. Let's keep the user current allocation, maybe we need to create a feature to more easily let them know whether they are fully allocated, or not..
* bump contracts to v1.1.1
* bump contracts
* bump to contracts 1.1.2
* fix script for networks without ve
* add veAllocation.sol's AllocationSetMultiple
* copy artfacts from barge for npm quickstart:barge
* fix using barge artifacts
* temp debug
* use barge artifacts
* use contracts 1.1.3
* use same approach for 'development'
* bump ocean-contracts
Co-authored-by: alexcos20 <alex.coseru@gmail.com>
Co-authored-by: mihaisc <mihai@oceanprotocol.com>
Co-authored-by: trizin <25263018+trizin@users.noreply.github.com>
2022-09-05 14:07:31 +02:00
|
|
|
deposit.save()
|
|
|
|
// --------------------------------------------
|
|
|
|
|
|
|
|
const lockedAmount = weiToDecimal(value.toBigDecimal(), 18)
|
|
|
|
veOCEAN.unlockTime = locktime
|
|
|
|
veOCEAN.lockedAmount = veOCEAN.lockedAmount.plus(lockedAmount)
|
|
|
|
veOCEAN.block = event.block.number.toI32()
|
|
|
|
veOCEAN.save()
|
|
|
|
}
|
|
|
|
export function handleSupply(event: Supply): void {}
|
2022-09-23 14:54:27 +02:00
|
|
|
export function handleWithdraw(event: Withdraw): void {
|
|
|
|
const provider = event.params.provider
|
|
|
|
const value = event.params.value
|
|
|
|
const ts = event.params.ts
|
|
|
|
|
|
|
|
const veOCEAN = getveOCEAN(provider.toHex())
|
|
|
|
// Create new Deposit entity
|
2023-01-25 11:18:23 +01:00
|
|
|
const deposit = getDeposit(
|
|
|
|
provider.toHex() +
|
|
|
|
'-' +
|
|
|
|
event.transaction.hash.toHex() +
|
|
|
|
'-' +
|
|
|
|
event.logIndex.toString()
|
|
|
|
)
|
2022-09-23 14:54:27 +02:00
|
|
|
deposit.provider = provider.toHex()
|
|
|
|
deposit.value = weiToDecimal(value.toBigDecimal(), 18).neg()
|
|
|
|
deposit.unlockTime = BigInt.zero()
|
|
|
|
deposit.type = BigInt.fromI32(4)
|
|
|
|
deposit.timestamp = ts
|
|
|
|
deposit.block = event.block.number.toI32()
|
|
|
|
deposit.tx = event.transaction.hash.toHex()
|
|
|
|
deposit.sender = event.transaction.from.toHex()
|
|
|
|
deposit.veOcean = veOCEAN.id
|
|
|
|
deposit.save()
|
|
|
|
// --------------------------------------------
|
|
|
|
|
|
|
|
veOCEAN.lockedAmount = BigDecimal.zero()
|
|
|
|
veOCEAN.unlockTime = BigInt.zero()
|
|
|
|
veOCEAN.block = event.block.number.toI32()
|
|
|
|
veOCEAN.save()
|
|
|
|
}
|