fix pool exit values (#392)

* fix pool exit values

* fix lint
This commit is contained in:
mihaisc 2022-03-29 05:59:32 -07:00 committed by GitHub
parent 9837a71a27
commit 17821115f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 6 deletions

View File

@ -60,6 +60,11 @@ clone this repository and run
```sh
docker-compose up
```
OR
```sh
docker-compose --env-file .env up | grep -a -E --color 'WARN.*|$'
```
This will start IPFS, Postgres and Graph Node in Docker and create persistent
data directories for IPFS and Postgres in `./data/ipfs` and `./data/postgres`. You

View File

@ -231,13 +231,13 @@ type PoolTransaction @entity {
"base tokens transfered"
baseToken: Token
"number of base tokens transfered, if value is negative it means it was removed"
"number of base tokens transfered, for type SWAP if value is negative it means it was removed"
baseTokenValue: BigDecimal
"datatokens transfered"
datatoken: Token
"number of datatokens transfered, if value is negative it means it was removed"
"number of datatokens transfered, for type SWAP if value is negative it means it was removed"
datatokenValue: BigDecimal
}

View File

@ -87,12 +87,12 @@ export function handleExit(event: LOG_EXIT): void {
)
if (token.isDatatoken) {
poolTx.datatoken = token.id
poolTx.datatokenValue = ammount.neg()
poolTx.datatokenValue = ammount
pool.datatokenLiquidity = pool.datatokenLiquidity.minus(ammount)
} else {
poolTx.baseToken = token.id
poolTx.baseTokenValue = ammount.neg()
poolTx.baseTokenValue = ammount
pool.baseTokenLiquidity = pool.baseTokenLiquidity.minus(ammount)
removeLiquidity(token.id, ammount)

View File

@ -17,16 +17,27 @@ export function getPoolShareId(
return `${poolAddress}-${userAddress}`
}
export function getPoolTransactionId(
txHash: string,
userAddress: string
): string {
return `${txHash}-${userAddress}`
}
export function getPoolTransaction(
event: ethereum.Event,
userAddress: string,
type: string
): PoolTransaction {
let poolTx = PoolTransaction.load(event.transaction.hash.toHex())
const txId = getPoolTransactionId(
event.transaction.hash.toHexString(),
userAddress
)
let poolTx = PoolTransaction.load(txId)
// create pool transaction and fill basic fields
if (poolTx === null) {
poolTx = new PoolTransaction(event.transaction.hash.toHex())
poolTx = new PoolTransaction(txId)
poolTx.user = userAddress
poolTx.pool = event.address.toHex()