Skip to content

Commit 2316301

Browse files
committed
removing user model
1 parent efa8d1f commit 2316301

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

schema.graphql

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,11 @@ type PriceRateProvider @entity(immutable: false) {
157157

158158
type PoolShare @entity(immutable: false) {
159159
id: ID!
160-
userAddress: User!
160+
userAddress: Bytes!
161161
poolId: Pool!
162162
balance: BigDecimal!
163163
}
164164

165-
type User @entity(immutable: true) {
166-
id: ID!
167-
}
168-
169165
type AmpUpdate @entity(immutable: true) {
170166
id: ID!
171167
poolId: Pool!
@@ -186,7 +182,7 @@ type Swap @entity(immutable: true) {
186182
tokenAmountIn: BigDecimal!
187183
tokenAmountOut: BigDecimal!
188184
poolId: Pool!
189-
userAddress: User!
185+
userAddress: Bytes!
190186
timestamp: Int!
191187
block: BigInt
192188
tx: Bytes!
@@ -203,7 +199,7 @@ type JoinExit @entity(immutable: true) {
203199
sender: Bytes!
204200
amounts: [BigDecimal!]!
205201
pool: Pool!
206-
user: User!
202+
user: Bytes!
207203
timestamp: Int!
208204
tx: Bytes!
209205
block: BigInt

src/mappings/helpers/misc.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BigDecimal, Address, BigInt, Bytes } from '@graphprotocol/graph-ts';
2-
import { Pool, PoolToken, PoolShare, PriceRateProvider, Token, User, FXOracle } from '../../types/schema';
2+
import { Pool, PoolToken, PoolShare, PriceRateProvider, Token, FXOracle } from '../../types/schema';
33
import { ERC20 } from '../../types/Vault/ERC20';
44
import { Vault } from '../../types/Vault/Vault';
55
import { ONE_BD, SWAP_IN, SWAP_OUT, VAULT_ADDRESS, ZERO_ADDRESS, ZERO_BD } from './constants';
@@ -77,12 +77,10 @@ export function getPoolShare(poolId: string, lpAddress: Address): PoolShare {
7777
}
7878

7979
export function createPoolShareEntity(poolId: string, lpAddress: Address): PoolShare {
80-
createUserEntity(lpAddress);
81-
8280
let id = getPoolShareId(getPoolAddress(poolId), lpAddress);
8381
let poolShare = new PoolShare(id);
8482

85-
poolShare.userAddress = lpAddress.toHex();
83+
poolShare.userAddress = lpAddress;
8684
poolShare.poolId = poolId;
8785
poolShare.balance = ZERO_BD;
8886
poolShare.save();
@@ -202,14 +200,6 @@ export function getTokenPriceId(
202200
.concat(block.toString());
203201
}
204202

205-
export function createUserEntity(address: Address): void {
206-
let addressHex = address.toHex();
207-
if (User.load(addressHex) == null) {
208-
let user = new User(addressHex);
209-
user.save();
210-
}
211-
}
212-
213203
export function createToken(tokenAddress: Address): Token {
214204
let erc20token = ERC20.bind(tokenAddress);
215205
let token = new Token(tokenAddress.toHexString());

src/mappings/vault.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
updateTokenBalances,
1111
bytesToAddress,
1212
getPoolShare,
13-
createUserEntity,
1413
} from './helpers/misc';
1514
import { updatePoolWeights } from './helpers/weighted';
1615
import { SWAP_IN, SWAP_OUT, VAULT_ADDRESS, ZERO, ZERO_ADDRESS, ZERO_BD } from './helpers/constants';
@@ -84,7 +83,7 @@ function handlePoolJoined(event: PoolBalanceChanged): void {
8483
join.type = 'Join';
8584
join.amounts = joinAmounts;
8685
join.pool = event.params.poolId.toHexString();
87-
join.user = event.params.liquidityProvider.toHexString();
86+
join.user = event.params.liquidityProvider;
8887
join.timestamp = blockTimestamp;
8988
join.tx = transactionHash;
9089
join.block = event.block.number;
@@ -184,7 +183,7 @@ function handlePoolExited(event: PoolBalanceChanged): void {
184183
exit.type = 'Exit';
185184
exit.amounts = exitAmounts;
186185
exit.pool = event.params.poolId.toHexString();
187-
exit.user = event.params.liquidityProvider.toHexString();
186+
exit.user = event.params.liquidityProvider;
188187
exit.timestamp = blockTimestamp;
189188
exit.tx = transactionHash;
190189
exit.block = event.block.number;
@@ -221,7 +220,6 @@ function handlePoolExited(event: PoolBalanceChanged): void {
221220
************** SWAPS ***************
222221
************************************/
223222
export function handleSwapEvent(event: SwapEvent): void {
224-
createUserEntity(event.transaction.from);
225223
let poolId = event.params.poolId;
226224

227225
let pool = Pool.load(poolId.toHexString());
@@ -338,7 +336,7 @@ export function handleSwapEvent(event: SwapEvent): void {
338336
swap.tokenAmountOut = tokenAmountOut;
339337

340338
swap.caller = event.transaction.from;
341-
swap.userAddress = event.transaction.from.toHex();
339+
swap.userAddress = event.transaction.from;
342340
swap.poolId = poolId.toHex();
343341

344342
swap.timestamp = blockTimestamp;

0 commit comments

Comments
 (0)