Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use event block number as start #432

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/balancer/OceanPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,6 @@ export class OceanPool extends Pool {
fromBlock: BPFACTORY_DEPLOY_BLOCK,
toBlock: 'latest'
})

for (let i = 0; i < events.length; i++) {
if (!account || events[i].returnValues[1].toLowerCase() === account.toLowerCase())
result.push(await this.getPoolDetails(events[i].returnValues[0]))
Expand All @@ -917,7 +916,6 @@ export class OceanPool extends Pool {
fromBlock: BPFACTORY_DEPLOY_BLOCK,
toBlock: 'latest'
})

for (let i = 0; i < events.length; i++) {
const shares = await super.sharesBalance(account, events[i].returnValues[0])
if (parseFloat(shares) > 0) {
Expand Down Expand Up @@ -954,6 +952,7 @@ export class OceanPool extends Pool {
*/
public async getPoolLogs(
poolAddress: string,
startBlock = 0,
account?: string
): Promise<PoolTransaction[]> {
const results: PoolTransaction[] = []
Expand All @@ -964,7 +963,7 @@ export class OceanPool extends Pool {

events = await pool.getPastEvents('LOG_SWAP', {
filter,
fromBlock: BPFACTORY_DEPLOY_BLOCK,
fromBlock: startBlock,
toBlock: 'latest'
})

Expand All @@ -975,7 +974,7 @@ export class OceanPool extends Pool {

events = await pool.getPastEvents('LOG_JOIN', {
filter,
fromBlock: BPFACTORY_DEPLOY_BLOCK,
fromBlock: startBlock,
toBlock: 'latest'
})

Expand All @@ -986,7 +985,7 @@ export class OceanPool extends Pool {

events = await pool.getPastEvents('LOG_EXIT', {
filter,
fromBlock: BPFACTORY_DEPLOY_BLOCK,
fromBlock: startBlock,
toBlock: 'latest'
})
for (let i = 0; i < events.length; i++) {
Expand All @@ -1010,9 +1009,12 @@ export class OceanPool extends Pool {
fromBlock: BPFACTORY_DEPLOY_BLOCK,
toBlock: 'latest'
})

for (let i = 0; i < events.length; i++) {
const logs = await this.getPoolLogs(events[i].returnValues[0], account)
const logs = await this.getPoolLogs(
events[i].returnValues[0],
events[i].blockNumber,
account
)
for (let j = 0; j < logs.length; j++) results.push(logs[j])
}
return results
Expand Down