Skip to content

Commit

Permalink
nit: fix formatting (#2608)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-chauhan authored Aug 19, 2024
1 parent 6cf74e0 commit 44bdd58
Show file tree
Hide file tree
Showing 40 changed files with 233 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getNetworkConfigurations(deploy: i32): Configurations {
default: {
log.critical(
"No configurations found for deployment protocol/network",
[]
[],
);
return new CoinbaseWrappedStakedEthMainnetConfigurations();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
} from "../../../../../src/common/constants";
import { Network } from "../../../../../src/sdk/util/constants";

export class CoinbaseWrappedStakedEthMainnetConfigurations implements Configurations {
export class CoinbaseWrappedStakedEthMainnetConfigurations
implements Configurations
{
getNetwork(): string {
return Network.MAINNET;
}
Expand Down
14 changes: 7 additions & 7 deletions subgraphs/coinbase-wrapped-staked-eth/src/mappings/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const conf = new ProtocolConfig(
NetworkConfigs.getLSTAddress().toHexString(),
NetworkConfigs.getProtocolName(),
NetworkConfigs.getProtocolSlug(),
Versions
Versions,
);

class Pricer implements TokenPricer {
Expand All @@ -32,7 +32,7 @@ class Pricer implements TokenPricer {
const pricedTokenChanged = pricedToken.changed;

returnedPrice = getUsdPricePerToken(pricedTokenAddr).usdPrice.times(
pricedTokenMultiplier
pricedTokenMultiplier,
);
if (pricedTokenChanged) {
log.debug(
Expand All @@ -42,7 +42,7 @@ class Pricer implements TokenPricer {
pricedTokenAddr.toHexString(),
pricedTokenMultiplier.toString(),
returnedPrice.toString(),
]
],
);
}

Expand All @@ -59,7 +59,7 @@ class Pricer implements TokenPricer {
const pricedTokenChanged = pricedToken.changed;

returnedPrice = getUsdPrice(pricedTokenAddr, _amount).times(
pricedTokenMultiplier
pricedTokenMultiplier,
);
if (pricedTokenChanged) {
log.debug(
Expand All @@ -70,7 +70,7 @@ class Pricer implements TokenPricer {
pricedTokenMultiplier.toString(),
_amount.toString(),
returnedPrice.toString(),
]
],
);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ export function handleMint(event: Mint): void {
conf,
new Pricer(),
new TokenInit(),
event
event,
);
const token = sdk.Tokens.getOrCreateToken(event.address);

Expand Down Expand Up @@ -162,7 +162,7 @@ export function handleBurn(event: Burn): void {
conf,
new Pricer(),
new TokenInit(),
event
event,
);
const token = sdk.Tokens.getOrCreateToken(event.address);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CalculationsCurve as CalculationsCurveContract } from "../../../generat

export function getCalculationsCurveContract(
contract: OracleContract,
block: ethereum.Block | null = null
block: ethereum.Block | null = null,
): CalculationsCurveContract | null {
if (
(block && contract.startBlock.gt(block.number)) ||
Expand All @@ -19,7 +19,7 @@ export function getCalculationsCurveContract(

export function getTokenPriceUSDC(
tokenAddr: Address,
block: ethereum.Block | null = null
block: ethereum.Block | null = null,
): CustomPriceType {
const config = utils.getConfig();

Expand All @@ -28,20 +28,20 @@ export function getTokenPriceUSDC(

const calculationCurveContract = getCalculationsCurveContract(
config.curveCalculations(),
block
block,
);
if (!calculationCurveContract) return new CustomPriceType();

const tokenPrice: BigDecimal = utils
.readValue<BigInt>(
calculationCurveContract.try_getCurvePriceUsdc(tokenAddr),
constants.BIGINT_ZERO
constants.BIGINT_ZERO,
)
.toBigDecimal();

return CustomPriceType.initialize(
tokenPrice,
constants.DEFAULT_USDC_DECIMALS,
constants.OracleType.CURVE_CALCULATIONS
constants.OracleType.CURVE_CALCULATIONS,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CalculationsSushiSwap as CalculationsSushiContract } from "../../../gen

export function getSushiSwapContract(
contract: OracleContract,
block: ethereum.Block | null = null
block: ethereum.Block | null = null,
): CalculationsSushiContract | null {
if (
(block && contract.startBlock.gt(block.number)) ||
Expand All @@ -19,7 +19,7 @@ export function getSushiSwapContract(

export function getTokenPriceUSDC(
tokenAddr: Address,
block: ethereum.Block | null = null
block: ethereum.Block | null = null,
): CustomPriceType {
const config = utils.getConfig();

Expand All @@ -28,20 +28,20 @@ export function getTokenPriceUSDC(

const calculationSushiContract = getSushiSwapContract(
config.sushiCalculations(),
block
block,
);
if (!calculationSushiContract) return new CustomPriceType();

const tokenPrice: BigDecimal = utils
.readValue<BigInt>(
calculationSushiContract.try_getPriceUsdc(tokenAddr),
constants.BIGINT_ZERO
constants.BIGINT_ZERO,
)
.toBigDecimal();

return CustomPriceType.initialize(
tokenPrice,
constants.DEFAULT_USDC_DECIMALS,
constants.OracleType.SUSHI_CALCULATIONS
constants.OracleType.SUSHI_CALCULATIONS,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export namespace OracleType {
}

export const CHAIN_LINK_USD_ADDRESS = Address.fromString(
"0x0000000000000000000000000000000000000348"
"0x0000000000000000000000000000000000000348",
);

export const PRICE_LIB_VERSION = "1.3.2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class OracleContract {

constructor(
contractAddress: string = constants.NULL.TYPE_STRING,
startBlock: i32 = -1
startBlock: i32 = -1,
) {
this._contractAddress = contractAddress;
this._contractStartBlock = startBlock;
Expand Down Expand Up @@ -48,7 +48,7 @@ export class CustomPriceType {
_usdPrice: BigDecimal,
_decimals: i32 = 0,
_oracleType: string = "",
_liquidity: BigDecimal | null = null
_liquidity: BigDecimal | null = null,
): CustomPriceType {
const result = new CustomPriceType();
result._usdPrice = new Wrapped(_usdPrice);
Expand All @@ -65,7 +65,7 @@ export class CustomPriceType {

get usdPrice(): BigDecimal {
return changetype<Wrapped<BigDecimal>>(this._usdPrice).inner.div(
constants.BIGINT_TEN.pow(this.decimals as u8).toBigDecimal()
constants.BIGINT_TEN.pow(this.decimals as u8).toBigDecimal(),
);
}

Expand Down Expand Up @@ -142,6 +142,6 @@ export interface Configurations {

getOracleOverride(
tokenAddr: Address | null,
block: ethereum.Block | null
block: ethereum.Block | null,
): OracleConfig | null;
}
14 changes: 7 additions & 7 deletions subgraphs/coinbase-wrapped-staked-eth/src/prices/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export function isNullAddress(tokenAddr: Address): boolean {

export function bigIntToBigDecimal(
quantity: BigInt,
decimals: i32 = constants.DEFAULT_DECIMALS.toI32()
decimals: i32 = constants.DEFAULT_DECIMALS.toI32(),
): BigDecimal {
return quantity.divDecimal(
constants.BIGINT_TEN.pow(decimals as u8).toBigDecimal()
constants.BIGINT_TEN.pow(decimals as u8).toBigDecimal(),
);
}

export function readValue<T>(
callResult: ethereum.CallResult<T>,
defaultValue: T
defaultValue: T,
): T {
return callResult.reverted ? defaultValue : callResult.value;
}
Expand All @@ -57,7 +57,7 @@ export function getTokenDecimals(tokenAddr: Address): BigInt {

const decimals = readValue<BigInt>(
tokenContract.try_decimals(),
constants.DEFAULT_DECIMALS
constants.DEFAULT_DECIMALS,
);

return decimals;
Expand All @@ -68,7 +68,7 @@ export function getTokenSupply(tokenAddr: Address): BigInt {

const totalSupply = readValue<BigInt>(
tokenContract.try_totalSupply(),
constants.BIGINT_ONE
constants.BIGINT_ONE,
);

return totalSupply;
Expand Down Expand Up @@ -137,7 +137,7 @@ function pairwiseDiffOfPrices(prices: CustomPriceType[]): BigDecimal[] {

export function kClosestPrices(
k: i32,
prices: CustomPriceType[]
prices: CustomPriceType[],
): CustomPriceType[] {
// sort by USD prices
const pricesSorted = sortByPrices(prices);
Expand Down Expand Up @@ -176,6 +176,6 @@ export function averagePrice(prices: CustomPriceType[]): CustomPriceType {

return CustomPriceType.initialize(
summationUSDPrice.div(new BigDecimal(BigInt.fromI32(prices.length as i32))),
constants.DEFAULT_USDC_DECIMALS
constants.DEFAULT_USDC_DECIMALS,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export const NETWORK_STRING = "arbitrum-one";

export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract(
"0x043518ab266485dc085a1db095b8d9c2fc78e9b9",
2396321
2396321,
);
export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(
"0xb56c2f0b653b2e0b10c9b928c8580ac5df02c7c7",
7740843
7740843,
);
export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract(
"0x5ea7e501c9a23f4a76dc7d33a11d995b13a1dd25",
2396120
2396120,
);
export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract();

Expand All @@ -29,7 +29,7 @@ export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract();

export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(
"0x3268c3bda100ef0ff3c2d044f23eab62c80d78d2",
11707234
11707234,
);

export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [
Expand Down Expand Up @@ -67,13 +67,13 @@ export const HARDCODED_STABLES: Address[] = [];
export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6);

export const ETH_ADDRESS = Address.fromString(
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
);
export const WETH_ADDRESS = Address.fromString(
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1"
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
);
export const USDC_ADDRESS = Address.fromString(
"0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"
"0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
);

export class config implements Configurations {
Expand Down Expand Up @@ -139,7 +139,7 @@ export class config implements Configurations {

getOracleOverride(
tokenAddr: Address | null,
block: ethereum.Block | null
block: ethereum.Block | null,
): OracleConfig | null {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ export const HARDCODED_STABLES: Address[] = [];
export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6);

export const ETH_ADDRESS = Address.fromString(
"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79" // Aurora
"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79", // Aurora
);
export const WETH_ADDRESS = Address.fromString(
"0xc9bdeed33cd01541e1eed10f90519d2c06fe3feb" // WETH
"0xc9bdeed33cd01541e1eed10f90519d2c06fe3feb", // WETH
);
export const USDC_ADDRESS = Address.fromString(
"0xb12bfca5a55806aaf64e99521918a4bf0fc40802"
"0xb12bfca5a55806aaf64e99521918a4bf0fc40802",
);

export class config implements Configurations {
Expand Down Expand Up @@ -126,7 +126,7 @@ export class config implements Configurations {

getOracleOverride(
tokenAddr: Address | null,
block: ethereum.Block | null
block: ethereum.Block | null,
): OracleConfig | null {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract();

export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract(
"0xebd36016b3ed09d4693ed4251c67bd858c3c7c9c",
11970477
11970477,
);

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -61,13 +61,13 @@ export const HARDCODED_STABLES: Address[] = [];
export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6);

export const ETH_ADDRESS = Address.fromString(
"0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab"
"0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab",
);
export const WETH_ADDRESS = Address.fromString(
"0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7"
"0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
);
export const USDC_ADDRESS = Address.fromString(
"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"
"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
);

export class config implements Configurations {
Expand Down Expand Up @@ -133,7 +133,7 @@ export class config implements Configurations {

getOracleOverride(
tokenAddr: Address | null,
block: ethereum.Block | null
block: ethereum.Block | null,
): OracleConfig | null {
return null;
}
Expand Down
Loading

0 comments on commit 44bdd58

Please sign in to comment.