Skip to content

Commit 512f1f8

Browse files
staking setup
1 parent 94cc1b8 commit 512f1f8

File tree

8 files changed

+1949
-12
lines changed

8 files changed

+1949
-12
lines changed

abis/WiseToken.json

Lines changed: 1816 additions & 0 deletions
Large diffs are not rendered by default.

config/mainnet.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"network": "mainnet",
3-
"liquidityTransformerAddress": "0xfef0d2f3a79b4338d8418003dd9df89281242063",
4-
"startBlock": 11010573
3+
"liquidityTransformer": {
4+
"address": "0xfef0d2f3a79b4338d8418003dd9df89281242063",
5+
"startBlock": 11010573
6+
},
7+
"wiseToken": {
8+
"address": "0xDb4de4303295c0E7559449aB4d121bFB4EE235AE",
9+
"startBlock": 11010573
10+
}
511
}

config/ropsten.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"network": "ropsten",
3-
"liquidityTransformerAddress": "0xfafbFc24695178F74f158f70BD7EA6162d836A18",
4-
"wiseAddress": "0x2306c52A206b2e847892496c29895217950d20e4",
5-
"startBlock": 8653977
3+
"liquidityTransformer": {
4+
"address": "0xfafbFc24695178F74f158f70BD7EA6162d836A18",
5+
"startBlock": 8653977
6+
},
7+
"wiseToken": {
8+
"address": "0xDb4de4303295c0E7559449aB4d121bFB4EE235AE",
9+
"startBlock": 9251234
10+
}
611
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
"name": "wise",
33
"license": "UNLICENSED",
44
"scripts": {
5-
"clean": "del-cli ./generated ./build && npm run prepare:mainnet",
6-
"codegen": "graph codegen",
5+
"clean": "del-cli ./generated ./build",
6+
"codegen": "npm run prepare:mainnet && graph codegen",
7+
"codegen:ropsten": "npm run prepare:ropsten && graph codegen",
78
"build": "graph build",
89
"make": "npm run clean && npm run codegen && npm run build",
10+
"make:ropsten": "npm run clean && npm run codegen:ropsten && npm run build",
911
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml",
1012
"prepare:ropsten": "mustache config/ropsten.json subgraph.template.yaml > subgraph.yaml",
1113
"deploy:mainnet": "npm run prepare:mainnet && graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ wise-foundation/wise",

schema.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,8 @@ type Global @entity {
7878
referrerCount: BigInt!
7979
cmReferrerCount: BigInt!
8080
reservationCount: BigInt!
81+
}
82+
83+
type Stake @entity {
84+
id: ID!
8185
}

src/mapping.ts renamed to src/mapping-liquidityTransformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
WiseReservation,
55
GeneratedStaticSupply,
66
GeneratedRandomSupply,
7-
} from "../generated/WiseLiquidityTransformer/LiquidityTransformer"
7+
} from "../generated/LiquidityTransformer/LiquidityTransformer"
88
import {
99
User,
1010
Reservation,

src/mapping-wiseToken.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { BigInt, ethereum } from "@graphprotocol/graph-ts"
2+
import {
3+
StakeStart
4+
} from "../generated/WiseToken/WiseToken"
5+
import {
6+
Stake
7+
} from "../generated/schema"
8+
9+
export function handleStakeStart (event: StakeStart): void {
10+
let stake = new Stake(event.params.stakeID.toHexString())
11+
stake.save()
12+
}
13+
14+
/*
15+
// Entities can be loaded from the store using a string ID this ID
16+
// needs to be unique across all entities of the same type
17+
let entity = ExampleEntity.load(event.transaction.from.toHex())
18+
19+
// Entities only exist after they have been saved to the store
20+
// `null` checks allow to create entities on demand
21+
if (entity == null) {
22+
entity = new ExampleEntity(event.transaction.from.toHex())
23+
24+
// Entity fields can be set using simple assignments
25+
entity.count = BigInt.fromI32(0)
26+
}
27+
28+
// BigInt and BigDecimal math are supported
29+
entity.count = entity.count + BigInt.fromI32(1)
30+
31+
// Entity fields can be set based on event parameters
32+
entity.investmentDay = event.params.investmentDay
33+
entity.randomSupply = event.params.randomSupply
34+
35+
// Entities can be written to the store with `.save()`
36+
entity.save()
37+
38+
// Note: If a handler doesn't require existing field values, it is faster
39+
// _not_ to load the entity from the store. Instead, create it fresh with
40+
// `new Entity(...)`, set the fields that should be updated and save the
41+
// entity back to the store. Fields that were not set or unset remain
42+
// unchanged, allowing for partial updates to be applied.
43+
44+
// It is also possible to access smart contracts from mappings. For
45+
// example, the contract that has emitted the event can be connected to
46+
// with:
47+
//
48+
// let contract = Contract.bind(event.address)
49+
//
50+
// The following functions can then be called on this contract to access
51+
// state variables and other data:
52+
//
53+
// - contract.REFUND_SPONSOR(...)
54+
// - contract.TOKEN_DEFINER(...)
55+
// - contract.UNISWAP_PAIR(...)
56+
// - contract.UNISWAP_ROUTER(...)
57+
// - contract.WISE_CONTRACT(...)
58+
// - contract._currentWiseDay(...)
59+
// - contract.dailyTotalInvestment(...)
60+
// - contract.dailyTotalSupply(...)
61+
// - contract.fundedDays(...)
62+
// - contract.g(...)
63+
// - contract.investmentsOnAllDays(...)
64+
// - contract.investorAccountCount(...)
65+
// - contract.investorAccounts(...)
66+
// - contract.investorBalances(...)
67+
// - contract.investorTotalBalance(...)
68+
// - contract.investorsOnAllDays(...)
69+
// - contract.investorsOnDay(...)
70+
// - contract.myInvestmentAmount(...)
71+
// - contract.myInvestmentAmountAllDays(...)
72+
// - contract.myTotalInvestmentAmount(...)
73+
// - contract.payoutInvestorAddress(...)
74+
// - contract.payoutReferralAddress(...)
75+
// - contract.referralAccountCount(...)
76+
// - contract.referralAccounts(...)
77+
// - contract.referralAmount(...)
78+
// - contract.referralTokens(...)
79+
// - contract.requestRefund(...)
80+
// - contract.supplyOnAllDays(...)
81+
// - contract.uniqueInvestorCount(...)
82+
// - contract.uniqueInvestors(...)
83+
}
84+
*/

subgraph.template.yaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,32 @@ schema:
33
file: ./schema.graphql
44
dataSources:
55
- kind: ethereum/contract
6-
name: WiseLiquidityTransformer
6+
name: WiseToken
77
network: {{ network }}
88
source:
9-
address: '{{ liquidityTransformerAddress }}'
9+
address: '{{ wiseToken.address }}'
10+
abi: WiseToken
11+
startBlock: {{ wiseToken.startBlock }}
12+
mapping:
13+
kind: ethereum/events
14+
apiVersion: 0.0.4
15+
language: wasm/assemblyscript
16+
entities:
17+
- Stake
18+
abis:
19+
- name: WiseToken
20+
file: ./abis/WiseToken.json
21+
eventHandlers:
22+
- event: StakeStart(indexed bytes16,indexed address,indexed address,uint256,uint256,uint256,uint256,uint256,uint256)
23+
handler: handleStakeStart
24+
file: ./src/mapping-wiseToken.ts
25+
- kind: ethereum/contract
26+
name: LiquidityTransformer
27+
network: {{ network }}
28+
source:
29+
address: '{{ liquidityTransformer.address }}'
1030
abi: LiquidityTransformer
11-
startBlock: {{ startBlock }}
31+
startBlock: {{ liquidityTransformer.startBlock }}
1232
mapping:
1333
kind: ethereum/events
1434
apiVersion: 0.0.4
@@ -32,4 +52,4 @@ dataSources:
3252
handler: handleGeneratedStaticSupply
3353
- event: GeneratedRandomSupply(indexed uint256,uint256)
3454
handler: handleGeneratedRandomSupply
35-
file: ./src/mapping.ts
55+
file: ./src/mapping-liquidityTransformer.ts

0 commit comments

Comments
 (0)