-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor(subgraphs/exchange): fix build:fuse execution errors #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { | |
BIG_DECIMAL_ZERO, | ||
FACTORY_ADDRESS, | ||
WHITELIST, | ||
JOE_USDT_PAIR_ADDRESS, | ||
VOLT_FUSD_PAIR_ADDRESS, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. opted on using this pair since its the most liquid, regardless I think this reference is not used |
||
WFUSE_STABLE_PAIRS, | ||
WFUSE_ADDRESS, | ||
USDT_ADDRESS, | ||
|
@@ -30,43 +30,43 @@ export function getJoePrice(block: ethereum.Block = null): BigDecimal { | |
} | ||
|
||
/* | ||
* JOE price is the weighted average of JOE/AVAX * AVAX and JOE/USDT. | ||
* VOLT price is the weighted average of VOLT/WFUSE * WFUSE and VOLT/USDC. | ||
* | ||
*/ | ||
export function getWavgJoePrice(block: ethereum.Block = null): BigDecimal { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function was changed because build:fuse command failed reading a reference here; think this method is not called regardless. |
||
// get JOE/USDT | ||
const usdt_pair = Pair.load(JOE_USDT_PAIR_ADDRESS.toString()) | ||
const usdt_price = usdt_pair | ||
? usdt_pair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? usdt_pair.token1Price | ||
: usdt_pair.token0Price | ||
// get VOLT/USDC | ||
const fusdPair = Pair.load(VOLT_FUSD_PAIR_ADDRESS.toString()) | ||
const fusdPrice = fusdPair | ||
? fusdPair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? fusdPair.token1Price | ||
: fusdPair.token0Price | ||
: BIG_DECIMAL_ZERO | ||
const usdt_weight = usdt_pair | ||
? usdt_pair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? usdt_pair.reserve0 | ||
: usdt_pair.reserve1 | ||
const fusdWeight = fusdPair | ||
? fusdPair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? fusdPair.reserve0 | ||
: fusdPair.reserve1 | ||
: BIG_DECIMAL_ZERO | ||
|
||
// get JOE/AVAX | ||
const joe_wavax_address = factoryContract.getPair(VOLT_TOKEN_ADDRESS, WFUSE_ADDRESS) | ||
const avax_pair = Pair.load(joe_wavax_address.toString()) | ||
const avax_rate = avax_pair | ||
? avax_pair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? avax_pair.token1Price | ||
: avax_pair.token0Price | ||
// get VOLT/WFUSE | ||
const voltWfuseAddress = factoryContract.getPair(VOLT_TOKEN_ADDRESS, WFUSE_ADDRESS) | ||
const wfusePair = Pair.load(voltWfuseAddress.toString()) | ||
const wfuseRate = wfusePair | ||
? wfusePair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? wfusePair.token1Price | ||
: wfusePair.token0Price | ||
: BIG_DECIMAL_ZERO | ||
const avax_weight = avax_pair | ||
? avax_pair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? avax_pair.reserve0 | ||
: avax_pair.reserve1 | ||
const wfuseWeight = wfusePair | ||
? wfusePair.token0 == VOLT_TOKEN_ADDRESS.toHexString() | ||
? wfusePair.reserve0 | ||
: wfusePair.reserve1 | ||
: BIG_DECIMAL_ZERO | ||
const avax_price = avax_rate.times(getAvaxPrice()) | ||
const wfusePrice = wfuseRate.times(getAvaxPrice()) | ||
|
||
// weighted avg | ||
const sumprod = usdt_price.times(usdt_weight).plus(avax_price.times(avax_weight)) | ||
const sumweights = usdt_weight.plus(avax_weight) | ||
const wavg = sumprod.div(sumweights) | ||
return wavg | ||
const sumprod = fusdPrice.times(fusdWeight).plus(wfusePrice.times(wfuseWeight)) | ||
const sumweights = fusdWeight.plus(wfuseWeight) | ||
const weightedAverage = sumprod.div(sumweights) | ||
return weightedAverage | ||
} | ||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,11 @@ | |
"@typescript-eslint/types" "4.27.0" | ||
eslint-visitor-keys "^2.0.0" | ||
|
||
"@voltage-finance/core@^1.0.1": | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/@voltage-finance/core/-/core-1.0.1.tgz#c345e0030c61994128181623762fd02354ea2018" | ||
integrity sha512-C51OVjoi7SLqkeowmxhqkw/wCcFpzk2j7Mi1kd5QkovjUhpo4TK1FEWEOz3h+r+UmefYjRxhzAFhraQkUABiPg== | ||
|
||
[email protected]: | ||
version "1.3.2" | ||
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REMINDER: this should be changed back before merge