Skip to content

Commit

Permalink
staking setup
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-converter committed Dec 16, 2020
1 parent 94cc1b8 commit 512f1f8
Show file tree
Hide file tree
Showing 8 changed files with 1,949 additions and 12 deletions.
1,816 changes: 1,816 additions & 0 deletions abis/WiseToken.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions config/mainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"network": "mainnet",
"liquidityTransformerAddress": "0xfef0d2f3a79b4338d8418003dd9df89281242063",
"startBlock": 11010573
"liquidityTransformer": {
"address": "0xfef0d2f3a79b4338d8418003dd9df89281242063",
"startBlock": 11010573
},
"wiseToken": {
"address": "0xDb4de4303295c0E7559449aB4d121bFB4EE235AE",
"startBlock": 11010573
}
}
11 changes: 8 additions & 3 deletions config/ropsten.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"network": "ropsten",
"liquidityTransformerAddress": "0xfafbFc24695178F74f158f70BD7EA6162d836A18",
"wiseAddress": "0x2306c52A206b2e847892496c29895217950d20e4",
"startBlock": 8653977
"liquidityTransformer": {
"address": "0xfafbFc24695178F74f158f70BD7EA6162d836A18",
"startBlock": 8653977
},
"wiseToken": {
"address": "0xDb4de4303295c0E7559449aB4d121bFB4EE235AE",
"startBlock": 9251234
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "wise",
"license": "UNLICENSED",
"scripts": {
"clean": "del-cli ./generated ./build && npm run prepare:mainnet",
"codegen": "graph codegen",
"clean": "del-cli ./generated ./build",
"codegen": "npm run prepare:mainnet && graph codegen",
"codegen:ropsten": "npm run prepare:ropsten && graph codegen",
"build": "graph build",
"make": "npm run clean && npm run codegen && npm run build",
"make:ropsten": "npm run clean && npm run codegen:ropsten && npm run build",
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml",
"prepare:ropsten": "mustache config/ropsten.json subgraph.template.yaml > subgraph.yaml",
"deploy:mainnet": "npm run prepare:mainnet && graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ wise-foundation/wise",
Expand Down
4 changes: 4 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ type Global @entity {
referrerCount: BigInt!
cmReferrerCount: BigInt!
reservationCount: BigInt!
}

type Stake @entity {
id: ID!
}
2 changes: 1 addition & 1 deletion src/mapping.ts → src/mapping-liquidityTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
WiseReservation,
GeneratedStaticSupply,
GeneratedRandomSupply,
} from "../generated/WiseLiquidityTransformer/LiquidityTransformer"
} from "../generated/LiquidityTransformer/LiquidityTransformer"
import {
User,
Reservation,
Expand Down
84 changes: 84 additions & 0 deletions src/mapping-wiseToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { BigInt, ethereum } from "@graphprotocol/graph-ts"
import {
StakeStart
} from "../generated/WiseToken/WiseToken"
import {
Stake
} from "../generated/schema"

export function handleStakeStart (event: StakeStart): void {
let stake = new Stake(event.params.stakeID.toHexString())
stake.save()
}

/*
// Entities can be loaded from the store using a string ID this ID
// needs to be unique across all entities of the same type
let entity = ExampleEntity.load(event.transaction.from.toHex())
// Entities only exist after they have been saved to the store
// `null` checks allow to create entities on demand
if (entity == null) {
entity = new ExampleEntity(event.transaction.from.toHex())
// Entity fields can be set using simple assignments
entity.count = BigInt.fromI32(0)
}
// BigInt and BigDecimal math are supported
entity.count = entity.count + BigInt.fromI32(1)
// Entity fields can be set based on event parameters
entity.investmentDay = event.params.investmentDay
entity.randomSupply = event.params.randomSupply
// Entities can be written to the store with `.save()`
entity.save()
// Note: If a handler doesn't require existing field values, it is faster
// _not_ to load the entity from the store. Instead, create it fresh with
// `new Entity(...)`, set the fields that should be updated and save the
// entity back to the store. Fields that were not set or unset remain
// unchanged, allowing for partial updates to be applied.
// It is also possible to access smart contracts from mappings. For
// example, the contract that has emitted the event can be connected to
// with:
//
// let contract = Contract.bind(event.address)
//
// The following functions can then be called on this contract to access
// state variables and other data:
//
// - contract.REFUND_SPONSOR(...)
// - contract.TOKEN_DEFINER(...)
// - contract.UNISWAP_PAIR(...)
// - contract.UNISWAP_ROUTER(...)
// - contract.WISE_CONTRACT(...)
// - contract._currentWiseDay(...)
// - contract.dailyTotalInvestment(...)
// - contract.dailyTotalSupply(...)
// - contract.fundedDays(...)
// - contract.g(...)
// - contract.investmentsOnAllDays(...)
// - contract.investorAccountCount(...)
// - contract.investorAccounts(...)
// - contract.investorBalances(...)
// - contract.investorTotalBalance(...)
// - contract.investorsOnAllDays(...)
// - contract.investorsOnDay(...)
// - contract.myInvestmentAmount(...)
// - contract.myInvestmentAmountAllDays(...)
// - contract.myTotalInvestmentAmount(...)
// - contract.payoutInvestorAddress(...)
// - contract.payoutReferralAddress(...)
// - contract.referralAccountCount(...)
// - contract.referralAccounts(...)
// - contract.referralAmount(...)
// - contract.referralTokens(...)
// - contract.requestRefund(...)
// - contract.supplyOnAllDays(...)
// - contract.uniqueInvestorCount(...)
// - contract.uniqueInvestors(...)
}
*/
28 changes: 24 additions & 4 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,32 @@ schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: WiseLiquidityTransformer
name: WiseToken
network: {{ network }}
source:
address: '{{ liquidityTransformerAddress }}'
address: '{{ wiseToken.address }}'
abi: WiseToken
startBlock: {{ wiseToken.startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
entities:
- Stake
abis:
- name: WiseToken
file: ./abis/WiseToken.json
eventHandlers:
- event: StakeStart(indexed bytes16,indexed address,indexed address,uint256,uint256,uint256,uint256,uint256,uint256)
handler: handleStakeStart
file: ./src/mapping-wiseToken.ts
- kind: ethereum/contract
name: LiquidityTransformer
network: {{ network }}
source:
address: '{{ liquidityTransformer.address }}'
abi: LiquidityTransformer
startBlock: {{ startBlock }}
startBlock: {{ liquidityTransformer.startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.4
Expand All @@ -32,4 +52,4 @@ dataSources:
handler: handleGeneratedStaticSupply
- event: GeneratedRandomSupply(indexed uint256,uint256)
handler: handleGeneratedRandomSupply
file: ./src/mapping.ts
file: ./src/mapping-liquidityTransformer.ts

0 comments on commit 512f1f8

Please sign in to comment.