Skip to content

Commit

Permalink
Merge branch 'master' into trader-joe-indexing-err
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-chauhan committed Dec 5, 2023
2 parents 8ea8d92 + 2ab2d26 commit 925a3ee
Show file tree
Hide file tree
Showing 165 changed files with 47,390 additions and 16,196 deletions.
318 changes: 191 additions & 127 deletions deployment/deployment.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions schema-bridge.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum Network {
HARMONY
PALM
CURIO
XDAI
UNKNOWN_NETWORK
}

Expand Down
2 changes: 1 addition & 1 deletion subgraphs/_reference_/src/sdk/protocols/lending/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { INT_ONE, INT_ZERO } from "./constants";
* - Making position snapshots
*
* Schema Version: 3.1.1
* SDK Version: 1.0.7
* SDK Version: 1.0.8
* Author(s):
* - @melotik
* - @dhruv-chauhan
Expand Down
6 changes: 4 additions & 2 deletions subgraphs/_reference_/src/sdk/protocols/lending/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { PositionManager } from "./position";
* need to think about all of the detailed storage changes that occur.
*
* Schema Version: 3.1.1
* SDK Version: 1.0.7
* SDK Version: 1.0.8
* Author(s):
* - @melotik
* - @dhruv-chauhan
Expand Down Expand Up @@ -888,14 +888,16 @@ export class DataManager {
newVariableBorrowBalance: BigInt | null = null,
newStableBorrowBalance: BigInt | null = null,
newReserveBalance: BigInt | null = null,
exchangeRate: BigDecimal | null = null
exchangeRate: BigDecimal | null = null,
outputTokenSupply: BigInt | null = null
): void {
const mantissaFactorBD = exponentToBigDecimal(
this.inputToken.getDecimals()
);
this.inputToken.updatePrice(inputTokenPriceUSD);
this.market.inputTokenPriceUSD = inputTokenPriceUSD;
this.market.inputTokenBalance = newInputTokenBalance;
this.market.outputTokenSupply = outputTokenSupply;
if (newVariableBorrowBalance) {
this.market.variableBorrowedTokenBalance = newVariableBorrowBalance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { PositionSide } from "./constants";
* make changes to a given position.
*
* Schema Version: 3.1.1
* SDK Version: 1.0.7
* SDK Version: 1.0.8
* Author(s):
* - @melotik
* - @dhruv-chauhan
Expand Down
9 changes: 8 additions & 1 deletion subgraphs/_reference_/src/sdk/protocols/lending/snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
* need to think about all of the detailed storage changes that occur.
*
* Schema Version: 3.1.1
* SDK Version: 1.0.7
* SDK Version: 1.0.8
* Author(s):
* - @melotik
* - @dhruv-chauhan
Expand Down Expand Up @@ -456,6 +456,7 @@ export class SnapshotManager {
this.marketHourlySnapshot.hourlyDepositUSD.plus(amountUSD);
this.financialSnapshot.dailyDepositUSD =
this.financialSnapshot.dailyDepositUSD.plus(amountUSD);
this.marketDailySnapshot.dailyDepositCount += INT_ONE;
this.usageDailySnapshot.dailyDepositCount += INT_ONE;
this.usageHourlySnapshot.hourlyDepositCount += INT_ONE;
} else if (transactionType == TransactionType.WITHDRAW) {
Expand All @@ -467,6 +468,7 @@ export class SnapshotManager {
this.marketHourlySnapshot.hourlyWithdrawUSD.plus(amountUSD);
this.financialSnapshot.dailyWithdrawUSD =
this.financialSnapshot.dailyWithdrawUSD.plus(amountUSD);
this.marketDailySnapshot.dailyWithdrawCount += INT_ONE;
this.usageDailySnapshot.dailyWithdrawCount += INT_ONE;
this.usageHourlySnapshot.hourlyWithdrawCount += INT_ONE;
} else if (transactionType == TransactionType.BORROW) {
Expand All @@ -478,6 +480,7 @@ export class SnapshotManager {
this.marketHourlySnapshot.hourlyBorrowUSD.plus(amountUSD);
this.financialSnapshot.dailyBorrowUSD =
this.financialSnapshot.dailyBorrowUSD.plus(amountUSD);
this.marketDailySnapshot.dailyBorrowCount += INT_ONE;
this.usageDailySnapshot.dailyBorrowCount += INT_ONE;
this.usageHourlySnapshot.hourlyBorrowCount += INT_ONE;
} else if (transactionType == TransactionType.REPAY) {
Expand All @@ -489,6 +492,7 @@ export class SnapshotManager {
this.marketHourlySnapshot.hourlyRepayUSD.plus(amountUSD);
this.financialSnapshot.dailyRepayUSD =
this.financialSnapshot.dailyRepayUSD.plus(amountUSD);
this.marketDailySnapshot.dailyRepayCount += INT_ONE;
this.usageDailySnapshot.dailyRepayCount += INT_ONE;
this.usageHourlySnapshot.hourlyRepayCount += INT_ONE;
} else if (transactionType == TransactionType.LIQUIDATE) {
Expand All @@ -500,6 +504,7 @@ export class SnapshotManager {
this.marketHourlySnapshot.hourlyLiquidateUSD.plus(amountUSD);
this.financialSnapshot.dailyLiquidateUSD =
this.financialSnapshot.dailyLiquidateUSD.plus(amountUSD);
this.marketDailySnapshot.dailyLiquidateCount += INT_ONE;
this.usageDailySnapshot.dailyLiquidateCount += INT_ONE;
this.usageHourlySnapshot.hourlyLiquidateCount += INT_ONE;
} else if (transactionType == TransactionType.TRANSFER) {
Expand All @@ -511,6 +516,7 @@ export class SnapshotManager {
this.marketHourlySnapshot.hourlyTransferUSD.plus(amountUSD);
this.financialSnapshot.dailyTransferUSD =
this.financialSnapshot.dailyTransferUSD.plus(amountUSD);
this.marketDailySnapshot.dailyTransferCount += INT_ONE;
this.usageDailySnapshot.dailyTransferCount += INT_ONE;
} else if (transactionType == TransactionType.FLASHLOAN) {
this.marketDailySnapshot.dailyFlashloanUSD =
Expand All @@ -521,6 +527,7 @@ export class SnapshotManager {
this.marketHourlySnapshot.hourlyFlashloanUSD.plus(amountUSD);
this.financialSnapshot.dailyFlashloanUSD =
this.financialSnapshot.dailyFlashloanUSD.plus(amountUSD);
this.marketDailySnapshot.dailyFlashloanCount += INT_ONE;
this.usageDailySnapshot.dailyFlashloanCount += INT_ONE;
} else {
log.error("[updateTransactionData] Invalid transaction type: {}", [
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/_reference_/src/sdk/protocols/lending/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
* use in mappings and get info about the token.
*
* Schema Version: 3.1.1
* SDK Version: 1.0.7
* SDK Version: 1.0.8
* Author(s):
* - @melotik
* - @dhruv-chauhan
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Perpetual SDK `1.1.7`
# Perpetual SDK `1.1.8`

The perpetual SDK follows the `1.3.3` Derivatives Perpetual Futures schema.

Expand Down
15 changes: 10 additions & 5 deletions subgraphs/_reference_/src/sdk/protocols/perpfutures/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
* - Making position snapshots
*
* Schema Version: 1.3.3
* SDK Version: 1.1.7
* SDK Version: 1.1.8
* Author(s):
* - @harsh9200
* - @dhruv-chauhan
Expand Down Expand Up @@ -156,7 +156,10 @@ export class Account {
return true;
}

private trackActivity(activityType: ActivityType): void {
private trackActivity(
activityType: ActivityType,
liquidator: Address | null = null
): void {
const days = getUnixDays(this.event.block);
const hours = getUnixHours(this.event.block);

Expand All @@ -168,8 +171,10 @@ export class Account {
hourly: this.isActiveByActivityID(Bytes.fromUTF8(generalHourlyID)),
};

const typeHourlyID = `${this.account.id.toHexString()}-hourly-${hours}-${activityType}`;
const typeDailyID = `${this.account.id.toHexString()}-daily-${days}-${activityType}`;
let accountId = this.account.id.toHexString();
if (liquidator) accountId = liquidator.toHexString();
const typeHourlyID = `${accountId}-hourly-${hours}-${activityType}`;
const typeDailyID = `${accountId}-daily-${days}-${activityType}`;

const typeActivity: AccountWasActive = {
daily: this.isActiveByActivityID(Bytes.fromUTF8(typeDailyID)),
Expand Down Expand Up @@ -640,7 +645,7 @@ export class Account {
entity!.liquidateCount += 1;
entity!.save();

this.trackActivity(ActivityType.LIQUIDATOR);
this.trackActivity(ActivityType.LIQUIDATOR, liquidator);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
* initialize new pools in the protocol.
*
* Schema Version: 1.3.3
* SDK Version: 1.1.7
* SDK Version: 1.1.8
* Author(s):
* - @harsh9200
* - @dhruv-chauhan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
* make all of the storage changes that occur in the pool daily and hourly snapshots.
*
* Schema Version: 1.3.3
* SDK Version: 1.1.7
* SDK Version: 1.1.8
* Author(s):
* - @harsh9200
* - @dhruv-chauhan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
* its corresponding snapshots.
*
* Schema Version: 1.3.3
* SDK Version: 1.1.7
* SDK Version: 1.1.8
* Author(s):
* - @harsh9200
* - @dhruv-chauhan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DerivPerpProtocol as PerpetualSchema } from "../../../../generated/sche
* make all of the storage changes that occur in a protocol.
*
* Schema Version: 1.3.3
* SDK Version: 1.1.7
* SDK Version: 1.1.8
* Author(s):
* - @harsh9200
* - @dhruv-chauhan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
* daily and hourly snapshots.
*
* Schema Version: 1.3.3
* SDK Version: 1.1.7
* SDK Version: 1.1.8
* Author(s):
* - @harsh9200
* - @dhruv-chauhan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Token, RewardToken } from "../../../../generated/schema";
* use in mappings and get info about the token.
*
* Schema Version: 1.3.3
* SDK Version: 1.1.7
* SDK Version: 1.1.8
* Author(s):
* - @harsh9200
* - @dhruv-chauhan
Expand Down
2 changes: 2 additions & 0 deletions subgraphs/aave-forks/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# .prettierrc or .prettierrc.yaml
trailingComma: "es5"
Loading

0 comments on commit 925a3ee

Please sign in to comment.