Skip to content

Commit 1782111

Browse files
authored
fix pool exit values (#392)
* fix pool exit values * fix lint
1 parent 9837a71 commit 1782111

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

docker/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ clone this repository and run
6060
```sh
6161
docker-compose up
6262
```
63+
OR
64+
65+
```sh
66+
docker-compose --env-file .env up | grep -a -E --color 'WARN.*|$'
67+
```
6368

6469
This will start IPFS, Postgres and Graph Node in Docker and create persistent
6570
data directories for IPFS and Postgres in `./data/ipfs` and `./data/postgres`. You

schema.graphql

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ type PoolTransaction @entity {
231231
"base tokens transfered"
232232
baseToken: Token
233233

234-
"number of base tokens transfered, if value is negative it means it was removed"
234+
"number of base tokens transfered, for type SWAP if value is negative it means it was removed"
235235
baseTokenValue: BigDecimal
236236

237237
"datatokens transfered"
238238
datatoken: Token
239239

240-
"number of datatokens transfered, if value is negative it means it was removed"
240+
"number of datatokens transfered, for type SWAP if value is negative it means it was removed"
241241
datatokenValue: BigDecimal
242242
}
243243

src/mappings/pool.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ export function handleExit(event: LOG_EXIT): void {
8787
)
8888
if (token.isDatatoken) {
8989
poolTx.datatoken = token.id
90-
poolTx.datatokenValue = ammount.neg()
90+
poolTx.datatokenValue = ammount
9191

9292
pool.datatokenLiquidity = pool.datatokenLiquidity.minus(ammount)
9393
} else {
9494
poolTx.baseToken = token.id
95-
poolTx.baseTokenValue = ammount.neg()
95+
poolTx.baseTokenValue = ammount
9696

9797
pool.baseTokenLiquidity = pool.baseTokenLiquidity.minus(ammount)
9898
removeLiquidity(token.id, ammount)

src/mappings/utils/poolUtils.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,27 @@ export function getPoolShareId(
1717
return `${poolAddress}-${userAddress}`
1818
}
1919

20+
export function getPoolTransactionId(
21+
txHash: string,
22+
userAddress: string
23+
): string {
24+
return `${txHash}-${userAddress}`
25+
}
26+
2027
export function getPoolTransaction(
2128
event: ethereum.Event,
2229
userAddress: string,
2330
type: string
2431
): PoolTransaction {
25-
let poolTx = PoolTransaction.load(event.transaction.hash.toHex())
32+
const txId = getPoolTransactionId(
33+
event.transaction.hash.toHexString(),
34+
userAddress
35+
)
36+
let poolTx = PoolTransaction.load(txId)
2637

2738
// create pool transaction and fill basic fields
2839
if (poolTx === null) {
29-
poolTx = new PoolTransaction(event.transaction.hash.toHex())
40+
poolTx = new PoolTransaction(txId)
3041

3142
poolTx.user = userAddress
3243
poolTx.pool = event.address.toHex()

0 commit comments

Comments
 (0)