-
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
Showing
10 changed files
with
1,276 additions
and
160 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,52 @@ | ||
- kind: ethereum/contract | ||
name: {id} | ||
network: {chain} | ||
source: | ||
address: "{address}" | ||
abi: BondFacet | ||
startBlock: {startBlock} | ||
mapping: | ||
kind: ethereum/events | ||
apiVersion: 0.0.5 | ||
language: wasm/assemblyscript | ||
entities: | ||
- BondFacet | ||
abis: | ||
- name: BondFacet | ||
file: {root}/abi/BondFacet.json | ||
eventHandlers: | ||
- event: BondInitialized(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256) | ||
handler: handleBondInitialized | ||
- event: BondParametersEdited(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256) | ||
handler: handleBondParametersEdited | ||
- event: CouponsComputed(uint256,uint256[],uint256[],uint256[],uint256[],uint256[]) | ||
handler: handleCouponsComputed | ||
- event: BondIssued(uint256,uint256,uint256) | ||
handler: handleBondIssued | ||
- event: BondsWithdrawn(string,uint256,address,uint256) | ||
handler: handleBondsWithdrawn | ||
- event: BalloonRateSet(uint256,uint256,uint256) | ||
handler: handleBalloonRateSet | ||
- event: GracePeriodSet(uint256,uint256) | ||
handler: handleGracePeriodSet | ||
- event: CapitalAmortizationFreePeriodSet(uint256,uint256) | ||
handler: handleCapitalAmortizationFreePeriodSet | ||
- event: InvestorsCountChanged(uint256,uint256) | ||
handler: handleInvestorsCountChanged | ||
- event: CampaignStartAndEndDateSet(uint256,uint256,uint256) | ||
handler: handleCampaignStartAndEndDateSet | ||
- event: CampaignPaused(uint256) | ||
handler: handleCampaignPaused | ||
- event: CampaignUnpaused(uint256) | ||
handler: handleCampaignUnpaused | ||
- event: MinAndMaxAmountSet(uint256,uint256,uint256,uint256) | ||
handler: handleMinAndMaxAmountSet | ||
- event: IssueDateSet(uint256,uint256) | ||
handler: handleIssueDateSet | ||
- event: BondTransferred(string,uint256,address,address,uint256) | ||
handler: handleBondTransferred | ||
- event: ReservedAmountChanged(uint256,uint256) | ||
handler: handleReservedAmountChanged | ||
- event: CouponStatusChanged(uint256,uint256) | ||
handler: handleCouponStatusChanged | ||
file: {file} |
Empty file.
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,8 @@ | ||
import { Address, Bytes } from '@graphprotocol/graph-ts'; | ||
import { Account } from '../../generated/schema'; | ||
|
||
export function fetchAccount(address: Address): Account { | ||
const account = new Account(Bytes.fromHexString(address.toHex())); | ||
account.save(); | ||
return account; | ||
} |
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,137 @@ | ||
import { Address, BigDecimal, BigInt } from '@graphprotocol/graph-ts'; | ||
import { Bond, BondFacet, CouponList, Holder, Transfer } from '../../generated/schema'; | ||
import { fetchAccount } from './account'; | ||
|
||
export function fetchBondFacet(address: Address, facetOffset: string): BondFacet { | ||
const account = fetchAccount(address); | ||
const contractId = account.id.toHex().concat('/').concat(facetOffset); | ||
//let contract = BondFacet.load(account.id.toHex()); | ||
let contract = BondFacet.load(contractId); | ||
|
||
if (contract == null) { | ||
//contract = new BondFacet(account.id.toHex()); | ||
contract = new BondFacet(contractId); | ||
account.asBondFacet = contractId; | ||
//account.asBondFacet = contract.id; | ||
//contract.asAccount = account.id.toHex(); | ||
|
||
contract.save(); | ||
account.save(); | ||
} | ||
|
||
return contract as BondFacet; | ||
} | ||
|
||
export function fetchCouponList(contract: BondFacet, bondId: string): CouponList { | ||
let couponList = CouponList.load(bondId); | ||
if (couponList == null) { | ||
couponList = new CouponList(bondId); | ||
couponList.contract = contract.id; | ||
couponList.remainingCapital = []; | ||
couponList.capitalRepayment = []; | ||
couponList.grossInterestRate = []; | ||
couponList.netInterestRate = []; | ||
couponList.grossInterest = []; | ||
couponList.netInterest = []; | ||
couponList.stepUp = []; | ||
couponList.stepDown = []; | ||
couponList.fee = []; | ||
couponList.capitalAndInterest = []; | ||
couponList.couponDate = []; | ||
couponList.newCouponDate = []; | ||
couponList.feeAmount = []; | ||
couponList.status = []; | ||
couponList.totalToBeRepaid = BigDecimal.fromString('0'); | ||
couponList.totalAmountRepaid = BigDecimal.fromString('0'); | ||
couponList.capitalRepaid = BigDecimal.fromString('0'); | ||
couponList.interestRepaid = BigDecimal.fromString('0'); | ||
couponList.interestTotal = BigDecimal.fromString('0'); | ||
couponList.save(); | ||
} | ||
return couponList as CouponList; | ||
} | ||
|
||
export function fetchHolder(contract: BondFacet, account: Address, bondId: string): Holder { | ||
const holderId = account.toString().concat('/').concat(bondId); | ||
let holder = Holder.load(holderId); | ||
|
||
if (holder == null) { | ||
holder = new Holder(holderId); | ||
holder.contract = contract.id; | ||
holder.account = account; | ||
holder.amount = BigInt.fromString('0'); | ||
holder.bondId = bondId; | ||
holder.dateOfOwnership = BigInt.fromString('0'); | ||
holder.save(); | ||
} | ||
return holder; | ||
} | ||
|
||
export function fetchTransfer(contract: BondFacet, transferId: string): Transfer { | ||
//const transferId = bondId.concat('/').concat(from).concat('/').concat(to).concat('/').concat(timestamp); | ||
let transfer = Transfer.load(transferId); | ||
if (transfer == null) { | ||
transfer = new Transfer(transferId); | ||
transfer.bondTransferId = transferId; | ||
transfer.contract = contract.id; | ||
transfer.bondId = ''; | ||
transfer.transferDate = BigInt.fromString('0'); | ||
transfer.amount = BigInt.fromString('0'); | ||
transfer.save(); | ||
} | ||
return transfer; | ||
} | ||
|
||
export function fetchBond(contract: BondFacet, bondId: string): Bond { | ||
let bond = Bond.load(bondId); | ||
if (bond == null) { | ||
bond = new Bond(bondId); | ||
bond.contract = contract.id; | ||
bond.coupure = BigInt.fromString('0'); | ||
bond.grossInterestRate = BigDecimal.fromString('0'); | ||
bond.netReturn = BigDecimal.fromString('0'); | ||
bond.withholdingTaxRate = BigDecimal.fromString('0'); | ||
bond.periodicInterestRate = BigDecimal.fromString('0'); | ||
bond.holders = []; | ||
bond.holdersAmount = []; | ||
bond.reservationsByAddresses = []; | ||
bond.reservedAmountByAddresses = []; | ||
bond.reservedAmount = BigInt.fromString('0'); | ||
bond.periodicity = ''; | ||
bond.methodOfRepayment = ''; | ||
bond.duration = BigInt.fromString('0'); | ||
bond.gracePeriod = BigInt.fromString('0'); | ||
bond.balloonPercentage = BigDecimal.fromString('0'); | ||
bond.capitalAmortizationFreePeriod = BigInt.fromString('0'); | ||
bond.costEmittent = BigDecimal.fromString('0'); | ||
bond.investorsCount = BigInt.fromString('0'); | ||
bond.revocationsCount = BigInt.fromString('0'); | ||
bond.campaignStartDate = BigInt.fromString('0'); | ||
bond.campaignEndDate = BigInt.fromString('0'); | ||
bond.paused = false; | ||
bond.maxSupply = BigDecimal.fromString('0'); | ||
bond.maxAmountPerInvestor = BigDecimal.fromString('0'); | ||
bond.campaignStartDate = BigInt.fromString('0'); | ||
bond.campaignEndDate = BigInt.fromString('0'); | ||
bond.maxAmount = BigInt.fromString('0'); | ||
bond.minAmount = BigInt.fromString('0'); | ||
bond.issueDate = BigInt.fromString('0'); | ||
bond.formOfFinancing = ''; | ||
bond.status = ''; | ||
bond.withdrawRef = ''; | ||
bond.cancelRef = ''; | ||
bond.terminated = false; | ||
bond.isReplacementBond = false; | ||
//bond.hashLockCancel =Bytes.fromHexString(''); | ||
//bond.hashLockWithdraw = Bytes.fromHexString(''); | ||
|
||
bond.withdrawStartTime = BigInt.fromString('0'); | ||
bond.withdrawEndTime = BigInt.fromString('0'); | ||
bond.cancelStartTime = BigInt.fromString('0'); | ||
bond.cancelEndTime = BigInt.fromString('0'); | ||
bond.issuedAmount = BigInt.fromString('0'); | ||
bond.totalAmountOfAssignedBonds = BigInt.fromString('0'); | ||
bond.save(); | ||
} | ||
return bond as Bond; | ||
} |
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,19 @@ | ||
{ | ||
"name": "solidity-token-diamond-bond", | ||
"version": "7.0.0", | ||
"description": "Solidity Token Diamond Bond", | ||
"scripts": {}, | ||
"keywords": [ | ||
"solidity", | ||
"subgraph" | ||
], | ||
"author": "SettleMint <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@amxx/graphprotocol-utils": "1.1.0", | ||
"@graphprotocol/graph-cli": "0.71.0", | ||
"@graphprotocol/graph-ts": "0.35.1", | ||
"@openzeppelin/contracts": "5.0.2", | ||
"@openzeppelin/subgraphs": "0.1.8-5" | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", | ||
"include": [ | ||
"datasources", | ||
"fetch" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.