-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#minor); yearn v2; fix log index (#2269)
- Loading branch information
Showing
23 changed files
with
2,184 additions
and
2,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 34 additions & 33 deletions
67
subgraphs/yearn-v2/src/Prices/calculations/CalculationsCurve.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
import * as utils from "../common/utils"; | ||
import * as constants from "../common/constants"; | ||
import { CustomPriceType } from "../common/types"; | ||
import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; | ||
import { CalculationsCurve as CalculationsCurveContract } from "../../../generated/templates/Vault/CalculationsCurve"; | ||
|
||
export function getCalculationsCurveContract( | ||
network: string | ||
): CalculationsCurveContract { | ||
return CalculationsCurveContract.bind( | ||
constants.CURVE_CALCULATIONS_ADDRESS_MAP.get(network)! | ||
); | ||
} | ||
|
||
export function getTokenPriceFromCalculationCurve( | ||
tokenAddr: Address, | ||
network: string | ||
): CustomPriceType { | ||
const calculationCurveContract = getCalculationsCurveContract(network); | ||
|
||
if (!calculationCurveContract) { | ||
return new CustomPriceType(); | ||
} | ||
|
||
let tokenPrice: BigDecimal = utils | ||
.readValue<BigInt>( | ||
calculationCurveContract.try_getCurvePriceUsdc(tokenAddr), | ||
constants.BIGINT_ZERO | ||
) | ||
.toBigDecimal(); | ||
|
||
return CustomPriceType.initialize(tokenPrice, 6); | ||
} | ||
import * as utils from "../common/utils"; | ||
import * as constants from "../common/constants"; | ||
import { CustomPriceType } from "../common/types"; | ||
import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; | ||
import { CalculationsCurve as CalculationsCurveContract } from "../../../generated/templates/Vault/CalculationsCurve"; | ||
|
||
export function getCalculationsCurveContract( | ||
network: string | ||
): CalculationsCurveContract { | ||
return CalculationsCurveContract.bind( | ||
constants.CURVE_CALCULATIONS_ADDRESS_MAP.get(network)! | ||
); | ||
} | ||
|
||
export function getTokenPriceFromCalculationCurve( | ||
tokenAddr: Address, | ||
network: string | ||
): CustomPriceType { | ||
const calculationCurveContract = getCalculationsCurveContract(network); | ||
|
||
if (!calculationCurveContract) { | ||
return new CustomPriceType(); | ||
} | ||
|
||
const tokenPrice: BigDecimal = utils | ||
.readValue<BigInt>( | ||
calculationCurveContract.try_getCurvePriceUsdc(tokenAddr), | ||
constants.BIGINT_ZERO | ||
) | ||
.toBigDecimal(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers | ||
return CustomPriceType.initialize(tokenPrice, 6); | ||
} |
65 changes: 33 additions & 32 deletions
65
subgraphs/yearn-v2/src/Prices/calculations/CalculationsSushiswap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
import * as utils from "../common/utils"; | ||
import * as constants from "../common/constants"; | ||
import { CustomPriceType } from "../common/types"; | ||
import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts"; | ||
import { CalculationsSushiSwap as CalculationsSushiContract } from "../../../generated/templates/Vault/CalculationsSushiSwap"; | ||
|
||
export function getSushiSwapContract( | ||
network: string | ||
): CalculationsSushiContract { | ||
return CalculationsSushiContract.bind( | ||
constants.SUSHISWAP_CALCULATIONS_ADDRESS_MAP.get(network)! | ||
); | ||
} | ||
|
||
export function getTokenPriceFromSushiSwap( | ||
tokenAddr: Address, | ||
network: string | ||
): CustomPriceType { | ||
const curveContract = getSushiSwapContract(network); | ||
if (!curveContract) { | ||
return new CustomPriceType(); | ||
} | ||
|
||
let tokenPrice: BigDecimal = utils | ||
.readValue<BigInt>( | ||
curveContract.try_getPriceUsdc(tokenAddr), | ||
constants.BIGINT_ZERO | ||
) | ||
.toBigDecimal(); | ||
|
||
return CustomPriceType.initialize(tokenPrice, 6); | ||
} | ||
import * as utils from "../common/utils"; | ||
import * as constants from "../common/constants"; | ||
import { CustomPriceType } from "../common/types"; | ||
import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts"; | ||
import { CalculationsSushiSwap as CalculationsSushiContract } from "../../../generated/templates/Vault/CalculationsSushiSwap"; | ||
|
||
export function getSushiSwapContract( | ||
network: string | ||
): CalculationsSushiContract { | ||
return CalculationsSushiContract.bind( | ||
constants.SUSHISWAP_CALCULATIONS_ADDRESS_MAP.get(network)! | ||
); | ||
} | ||
|
||
export function getTokenPriceFromSushiSwap( | ||
tokenAddr: Address, | ||
network: string | ||
): CustomPriceType { | ||
const curveContract = getSushiSwapContract(network); | ||
if (!curveContract) { | ||
return new CustomPriceType(); | ||
} | ||
|
||
const tokenPrice: BigDecimal = utils | ||
.readValue<BigInt>( | ||
curveContract.try_getPriceUsdc(tokenAddr), | ||
constants.BIGINT_ZERO | ||
) | ||
.toBigDecimal(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers | ||
return CustomPriceType.initialize(tokenPrice, 6); | ||
} |
Oops, something went wrong.