2022-09-23 14:54:27 +02:00
|
|
|
import { BigDecimal, ethereum, BigInt, Address } 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 {
|
|
|
|
VeAllocateUser,
|
|
|
|
VeAllocateId,
|
|
|
|
VeAllocation,
|
|
|
|
VeAllocationUpdate,
|
|
|
|
VeDelegation,
|
|
|
|
VeOCEAN,
|
2022-09-23 14:54:27 +02:00
|
|
|
VeDeposit,
|
|
|
|
VeFeeDistributor
|
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
|
|
|
} from '../../@types/schema'
|
2022-09-23 14:54:27 +02:00
|
|
|
import { veFeeDistributor as VeFeeDistributorContract } from '../../@types/veFeeDistributor/veFeeDistributor'
|
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 { veAllocationUpdateType } from './constants'
|
2022-09-23 14:54:27 +02:00
|
|
|
import { getToken } from './tokenUtils'
|
|
|
|
|
|
|
|
export function getveOCEAN(id: string): VeOCEAN {
|
|
|
|
let ve = VeOCEAN.load(id)
|
|
|
|
|
|
|
|
if (ve === null) {
|
|
|
|
ve = new VeOCEAN(id)
|
|
|
|
ve.unlockTime = BigInt.zero()
|
|
|
|
ve.lockedAmount = BigDecimal.zero()
|
|
|
|
ve.block = 0
|
|
|
|
ve.save()
|
|
|
|
}
|
|
|
|
|
|
|
|
return ve
|
|
|
|
}
|
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
|
|
|
|
|
|
|
export function getveAllocateUser(
|
|
|
|
event: ethereum.Event,
|
|
|
|
sender: string
|
|
|
|
): VeAllocateUser {
|
|
|
|
let allocateUser = VeAllocateUser.load(sender)
|
|
|
|
if (allocateUser === null) {
|
|
|
|
allocateUser = new VeAllocateUser(sender)
|
|
|
|
allocateUser.allocatedTotal = BigDecimal.zero()
|
|
|
|
|
|
|
|
allocateUser.firstContact = event.block.timestamp.toI32()
|
|
|
|
allocateUser.tx = event.transaction.hash.toHex()
|
|
|
|
allocateUser.block = event.block.number.toI32()
|
|
|
|
allocateUser.lastContact = 0
|
2022-09-23 14:54:27 +02:00
|
|
|
const veOcean = getveOCEAN(sender)
|
|
|
|
allocateUser.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
|
|
|
|
|
|
|
allocateUser.save()
|
|
|
|
}
|
|
|
|
|
|
|
|
return allocateUser
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getveAllocateId(
|
|
|
|
event: ethereum.Event,
|
|
|
|
id: string
|
|
|
|
): VeAllocateId {
|
|
|
|
let allocateId = VeAllocateId.load(id)
|
|
|
|
if (allocateId === null) {
|
|
|
|
allocateId = new VeAllocateId(id)
|
|
|
|
allocateId.allocatedTotal = BigDecimal.zero()
|
|
|
|
|
|
|
|
allocateId.firstContact = event.block.timestamp.toI32()
|
|
|
|
allocateId.tx = event.transaction.hash.toHex()
|
|
|
|
allocateId.block = event.block.number.toI32()
|
|
|
|
allocateId.lastContact = 0
|
|
|
|
|
|
|
|
allocateId.save()
|
|
|
|
}
|
|
|
|
|
|
|
|
return allocateId
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getveAllocation(
|
|
|
|
event: ethereum.Event,
|
|
|
|
sender: string,
|
|
|
|
id: string
|
|
|
|
): VeAllocation {
|
|
|
|
let veAllocation = VeAllocation.load(sender + '-' + id)
|
|
|
|
if (veAllocation === null) {
|
|
|
|
veAllocation = new VeAllocation(sender + '-' + id)
|
|
|
|
veAllocation.allocationUser = getveAllocateUser(event, sender).id
|
|
|
|
veAllocation.allocationId = getveAllocateId(event, id).id
|
|
|
|
veAllocation.allocated = BigDecimal.zero()
|
|
|
|
veAllocation.chainId = BigInt.zero()
|
|
|
|
veAllocation.nftAddress = ''
|
|
|
|
|
|
|
|
veAllocation.firstContact = event.block.timestamp.toI32()
|
|
|
|
veAllocation.tx = event.transaction.hash.toHex()
|
|
|
|
veAllocation.block = event.block.number.toI32()
|
|
|
|
veAllocation.lastContact = 0
|
|
|
|
|
|
|
|
veAllocation.save()
|
|
|
|
}
|
|
|
|
|
|
|
|
return veAllocation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pass veAllocation being updated
|
|
|
|
export function writeveAllocationUpdate(
|
|
|
|
event: ethereum.Event,
|
|
|
|
veAllocationId: string,
|
|
|
|
allocationType: string,
|
|
|
|
amount: BigDecimal
|
|
|
|
): VeAllocationUpdate {
|
|
|
|
const tx = event.transaction.hash.toHex()
|
|
|
|
let allocationUpdate = VeAllocationUpdate.load(tx + '-' + veAllocationId)
|
|
|
|
if (allocationUpdate === null) {
|
|
|
|
allocationUpdate = new VeAllocationUpdate(tx + '-' + veAllocationId)
|
|
|
|
allocationUpdate.veAllocation = veAllocationId
|
|
|
|
allocationUpdate.type = allocationType
|
|
|
|
allocationUpdate.allocatedTotal = amount
|
|
|
|
|
|
|
|
allocationUpdate.timestamp = event.block.timestamp.toI32()
|
|
|
|
allocationUpdate.tx = event.transaction.hash.toHex()
|
|
|
|
allocationUpdate.block = event.block.number.toI32()
|
|
|
|
|
|
|
|
allocationUpdate.save()
|
|
|
|
}
|
|
|
|
|
|
|
|
return allocationUpdate
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getveDelegation(id: string): VeDelegation {
|
|
|
|
let veDelegation = VeDelegation.load(id)
|
|
|
|
|
|
|
|
if (veDelegation === null) {
|
|
|
|
veDelegation = new VeDelegation(id)
|
|
|
|
veDelegation.cancelTime = BigInt.zero()
|
|
|
|
veDelegation.expireTime = BigInt.zero()
|
|
|
|
veDelegation.tokenId = BigInt.zero()
|
|
|
|
veDelegation.amount = BigInt.zero()
|
|
|
|
veDelegation.receiver = ''
|
|
|
|
veDelegation.delegator = ''
|
|
|
|
veDelegation.block = 0
|
|
|
|
veDelegation.save()
|
|
|
|
}
|
|
|
|
return veDelegation
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getDeposit(id: string): VeDeposit {
|
|
|
|
let deposit = VeDeposit.load(id)
|
|
|
|
|
|
|
|
if (deposit === null) {
|
|
|
|
deposit = new VeDeposit(id)
|
|
|
|
deposit.provider = ''
|
2022-09-23 14:54:27 +02:00
|
|
|
deposit.sender = ''
|
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.value = BigDecimal.zero()
|
|
|
|
deposit.unlockTime = BigInt.zero()
|
|
|
|
deposit.type = BigInt.zero()
|
|
|
|
deposit.timestamp = BigInt.zero()
|
2022-09-07 12:30:53 +02:00
|
|
|
deposit.tx = ''
|
|
|
|
deposit.block = 0
|
2022-09-23 14:54:27 +02:00
|
|
|
// do not save it
|
|
|
|
// deposit.save()
|
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
|
|
|
}
|
|
|
|
return deposit
|
|
|
|
}
|
|
|
|
|
|
|
|
export function handleOneAllocation(
|
|
|
|
eventSender: string,
|
|
|
|
nftAddress: string,
|
|
|
|
chainId: BigInt,
|
|
|
|
allocationAmount: BigDecimal,
|
|
|
|
event: ethereum.Event
|
|
|
|
): void {
|
|
|
|
const eventId = nftAddress + '-' + chainId.toString()
|
|
|
|
|
|
|
|
const allocateUser = getveAllocateUser(event, eventSender)
|
|
|
|
const allocateId = getveAllocateId(event, eventId)
|
|
|
|
const veAllocation = getveAllocation(event, eventSender, eventId)
|
|
|
|
|
|
|
|
// Update user allocation
|
|
|
|
const newUserAllocation = allocateUser.allocatedTotal.minus(
|
|
|
|
veAllocation.allocated
|
|
|
|
)
|
|
|
|
allocateUser.allocatedTotal = newUserAllocation.plus(allocationAmount)
|
|
|
|
|
|
|
|
// Update id allocation
|
|
|
|
const newIdAllocation = allocateId.allocatedTotal.minus(
|
|
|
|
veAllocation.allocated
|
|
|
|
)
|
|
|
|
allocateId.allocatedTotal = newIdAllocation.plus(allocationAmount)
|
|
|
|
|
|
|
|
veAllocation.allocated = allocationAmount
|
|
|
|
veAllocation.chainId = chainId
|
|
|
|
veAllocation.nftAddress = nftAddress
|
|
|
|
|
|
|
|
allocateUser.lastContact = event.block.timestamp.toI32()
|
|
|
|
allocateId.lastContact = event.block.timestamp.toI32()
|
|
|
|
veAllocation.lastContact = event.block.timestamp.toI32()
|
|
|
|
|
|
|
|
// register allocation update event
|
|
|
|
writeveAllocationUpdate(
|
|
|
|
event,
|
|
|
|
veAllocation.id,
|
|
|
|
veAllocationUpdateType.SET,
|
|
|
|
allocationAmount
|
|
|
|
)
|
|
|
|
|
|
|
|
// save entities
|
|
|
|
allocateUser.save()
|
|
|
|
allocateId.save()
|
|
|
|
veAllocation.save()
|
|
|
|
}
|
2022-09-23 14:54:27 +02:00
|
|
|
|
|
|
|
export function getVeFeeDistributor(id: Address): VeFeeDistributor {
|
|
|
|
let distributor = VeFeeDistributor.load(id.toHexString())
|
|
|
|
|
|
|
|
if (distributor === null) {
|
|
|
|
distributor = new VeFeeDistributor(id.toHexString())
|
|
|
|
const contract = VeFeeDistributorContract.bind(id)
|
|
|
|
const tokenAddress = contract.try_token()
|
|
|
|
const token = getToken(tokenAddress.value, false)
|
|
|
|
distributor.token = token.id
|
|
|
|
distributor.save()
|
|
|
|
}
|
|
|
|
return distributor
|
|
|
|
}
|