Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions src/core/constants/PintoBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
TOKEN_INFOS,
PRICE_2_BLOCK,
BEANSTALK_PRICE_1,
BEANSTALK_PRICE_2
BEANSTALK_PRICE_2,
PINTO_WSTETH,
WELL_CP2
} from "./raw/PintoBaseConstants";
import { beanDecimals, PoolTokens, Token, WellFnInfo } from "./RuntimeConstants";
import { BI_10 } from "../utils/Decimals";
Expand Down Expand Up @@ -64,6 +66,8 @@ export function getTokenDecimals(token: Address): i32 {
return 18;
} else if (token == PINTO_USDC) {
return 18;
} else if (token == PINTO_WSTETH) {
return 18;
} else {
for (let i = 0; i < TOKEN_INFOS.length; ++i) {
if (TOKEN_INFOS[i].address.equals(token)) {
Expand All @@ -79,7 +83,7 @@ export function protocolHasUnripe(): boolean {
}

export function getWhitelistedWells(): Address[] {
return [PINTO_WETH, PINTO_CBETH, PINTO_CBBTC, PINTO_WSOL, PINTO_USDC];
return [PINTO_WETH, PINTO_CBETH, PINTO_CBBTC, PINTO_WSOL, PINTO_USDC, PINTO_WSTETH];
}

/// MILESTONE ///
Expand Down Expand Up @@ -129,14 +133,14 @@ export function isStable2WellFn(wellFnAddress: Address): boolean {
export function wellFnInfoForWell(wellAddress: Address): WellFnInfo {
if (wellAddress == PINTO_USDC) {
return {
address: Address.fromString("0xba51055a97b40d7f41f3f64b57469b5d45b67c87"),
address: WELL_STABLE2,
data: Bytes.fromHexString(
"0x00000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006"
)
};
} else {
return {
address: Address.fromString("0xba510c289fd067ebba41335afa11f0591940d6fe"),
address: WELL_CP2,
data: Bytes.fromHexString("0x")
};
}
Expand Down
14 changes: 14 additions & 0 deletions src/core/constants/raw/PintoBaseConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ export const PINTO_CBETH = Address.fromString("0x3e111115A82dF6190e36ADf0d552880
export const PINTO_CBBTC = Address.fromString("0x3e11226fe3d85142B734ABCe6e58918d5828d1b4");
export const PINTO_WSOL = Address.fromString("0x3e11444c7650234c748D743D8d374fcE2eE5E6C9");
export const PINTO_USDC = Address.fromString("0x3e1133aC082716DDC3114bbEFEeD8B1731eA9cb1");
export const PINTO_WSTETH = Address.fromString("0x3e1155245FF9a6a019Bc35827e801c6ED2CE91b9");

// External tokens
export const WETH = Address.fromString("0x4200000000000000000000000000000000000006");
export const CBETH = Address.fromString("0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22");
export const CBBTC = Address.fromString("0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf");
export const WSOL = Address.fromString("0x1C61629598e4a901136a81BC138E5828dc150d67");
export const USDC = Address.fromString("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");
export const WSTETH = Address.fromString("0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452");

// Contracts
export const BEANSTALK = Address.fromString("0xD1A0D188E861ed9d15773a2F3574a2e94134bA8f");
Expand Down Expand Up @@ -52,6 +54,10 @@ export const POOL_TOKENS: PoolTokens[] = [
{
pool: PINTO_WSOL,
tokens: [BEAN_ERC20, WSOL]
},
{
pool: PINTO_WSTETH,
tokens: [BEAN_ERC20, WSTETH]
}
];

Expand Down Expand Up @@ -84,6 +90,10 @@ export const TOKEN_INFOS: Token[] = [
address: USDC,
info: { name: "USDC", decimals: BigInt.fromU32(6) }
},
{
address: WSTETH,
info: { name: "wstETH", decimals: BigInt.fromU32(18) }
},
{
address: PINTO_WETH,
info: { name: "PINTOWETH LP", decimals: BigInt.fromU32(18) }
Expand All @@ -103,5 +113,9 @@ export const TOKEN_INFOS: Token[] = [
{
address: PINTO_USDC,
info: { name: "PINTOUSDC LP", decimals: BigInt.fromU32(18) }
},
{
address: PINTO_WSTETH,
info: { name: "PINTOWSTETH LP", decimals: BigInt.fromU32(18) }
}
];
5 changes: 3 additions & 2 deletions src/subgraphs/basin/src/handlers/BeanstalkHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { convert } from "../utils/Beanstalk";
import { takeWellSnapshots } from "../entities/snapshots/Well";
import { loadWell } from "../entities/Well";
import { takeBeanstalkSnapshots } from "../entities/snapshots/Beanstalk";
import { Well } from "../../generated/schema";

// Takes snapshots of beanstalk wells only and update beanstalk stats
export function handleBeanstalkSunrise(event: Sunrise): void {
Expand All @@ -18,9 +19,9 @@ export function handleBeanstalkSunrise(event: Sunrise): void {

const wells = getWhitelistedWells(v());
for (let i = 0; i < wells.length; i++) {
const well = loadWell(toAddress(wells[i]));
const well = Well.load(toAddress(wells[i]));
// Verify the well is still whitelisted
if (well.isBeanstalk) {
if (well !== null && well.isBeanstalk) {
takeWellSnapshots(well, event.block);
well.save();
}
Expand Down
4 changes: 4 additions & 0 deletions src/subgraphs/basin/src/utils/UpgradeableMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,9 @@ export const UPGRADEABLE_MAPPING: UpgradeableMapping[] = [
Address.fromString("0x7ea12704AF23867A8eAE6c6b80e06027A8120b82"),
Address.fromString("0x72df00123eBb69EF17E941243e0436AB73F71D5D")
]
},
{
proxy: PintoBase.PINTO_WSTETH,
boredWells: [Address.fromString("0x3e11AfD88f9987dF06557ee84d8a38879b0503B0")]
}
];
2 changes: 1 addition & 1 deletion src/subgraphs/basin/src/utils/constants/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as PintoBase from "../../../../../core/constants/raw/PintoBaseConstants

export function handleInitVersion(block: ethereum.Block): void {
const versionEntity = new Version("subgraph");
versionEntity.versionNumber = "1.2.6";
versionEntity.versionNumber = "1.2.7";
versionEntity.subgraphName = subgraphNameForBlockNumber(block.number);
versionEntity.protocolAddress = protocolForBlockNumber(block.number);
versionEntity.chain = chainForBlockNumber(block.number);
Expand Down
56 changes: 56 additions & 0 deletions src/subgraphs/bean/manifests/pinto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@ dataSources:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
file: ../src/handlers/TokenHandler.ts
- kind: ethereum/contract
name: PintoWstethToken
network: base
source:
address: "0x3e1155245FF9a6a019Bc35827e801c6ED2CE91b9"
abi: ERC20
startBlock: 38391612 # TODO: PINTO:wstETH deployment once known
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Bean
abis:
- name: ERC20
file: ../../../core/abis/ERC20.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
file: ../src/handlers/TokenHandler.ts
- kind: ethereum/contract
name: sPintoToken
network: base
Expand Down Expand Up @@ -438,6 +458,42 @@ dataSources:
- event: Sync(uint256[],uint256,address)
handler: handleSync
file: ../src/handlers/BeanWellHandler.ts
- kind: ethereum/contract
name: PintowstETH
network: base
source:
address: "0x3e1155245FF9a6a019Bc35827e801c6ED2CE91b9"
abi: Well
startBlock: 38391612 # TODO: PINTO:wstETH deployment once known
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Pool
abis:
- name: Well
file: ../../../core/abis/Well.json
- name: BeanstalkPrice
file: ../../../core/abis/PintostalkPrice.json
- name: ERC20
file: ../../../core/abis/ERC20.json
- name: PintoLaunch
file: ../../../core/abis/Beanstalk/Pinto-Launch.json
eventHandlers:
- event: AddLiquidity(uint256[],uint256,address)
handler: handleAddLiquidity
- event: RemoveLiquidity(uint256,uint256[],address)
handler: handleRemoveLiquidity
- event: RemoveLiquidityOneToken(uint256,address,uint256,address)
handler: handleRemoveLiquidityOneToken
- event: Swap(address,address,uint256,uint256,address)
handler: handleSwap
- event: Shift(uint256[],address,uint256,address)
handler: handleShift
- event: Sync(uint256[],uint256,address)
handler: handleSync
file: ../src/handlers/BeanWellHandler.ts
###
# PEG CROSS CHECK PER BLOCK
###
Expand Down
2 changes: 1 addition & 1 deletion src/subgraphs/bean/src/utils/constants/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as PintoBase from "../../../../../core/constants/raw/PintoBaseConstants

export function handleInitVersion(block: ethereum.Block): void {
const versionEntity = new Version("subgraph");
versionEntity.versionNumber = "1.3.2";
versionEntity.versionNumber = "1.3.3";
versionEntity.subgraphName = subgraphNameForBlockNumber(block.number);
versionEntity.protocolAddress = protocolForBlockNumber(block.number);
versionEntity.chain = chainForBlockNumber(block.number);
Expand Down
31 changes: 20 additions & 11 deletions src/subgraphs/beanstalk/src/utils/MarketPerformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,32 @@ function accumulateSeason(currentSeason: MarketPerformanceSeasonal): void {
currentSeason.cumulativeTotalPercentChange = currentSeason.totalPercentChange!;
currentSeason.save();
} else {
// This would be an issue if the number of whitelisted tokens changes.
// usdChange/percentChange would have to be removed or refactored to have a direct token mapping.
// This may be an issue if the number of whitelisted tokens decreases.
// The current implementation works for new tokens appearing only.
// However in practice I expect usdChange to have placeholder 0s for dewhitelisted tokens.
const usdChange: BigDecimal[] = [];
for (let i = 0; i < prevSeason.cumulativeUsdChange!.length; i++) {
usdChange.push(prevSeason.cumulativeUsdChange![i].plus(currentSeason.usdChange![i]));
for (let i = 0; i < currentSeason.usdChange!.length; i++) {
if (i < prevSeason.cumulativeUsdChange!.length) {
usdChange.push(prevSeason.cumulativeUsdChange![i].plus(currentSeason.usdChange![i]));
} else {
usdChange.push(currentSeason.usdChange![i]);
}
}
currentSeason.cumulativeUsdChange = usdChange;
currentSeason.cumulativeTotalUsdChange = prevSeason.cumulativeTotalUsdChange!.plus(currentSeason.totalUsdChange!);

const percentChange: BigDecimal[] = [];
for (let i = 0; i < prevSeason.cumulativePercentChange!.length; i++) {
percentChange.push(
prevSeason
.cumulativePercentChange![i].plus(ONE_BD)
.times(currentSeason.percentChange![i].plus(ONE_BD))
.minus(ONE_BD)
);
for (let i = 0; i < currentSeason.percentChange!.length; i++) {
if (i < prevSeason.cumulativePercentChange!.length) {
percentChange.push(
prevSeason
.cumulativePercentChange![i].plus(ONE_BD)
.times(currentSeason.percentChange![i].plus(ONE_BD))
.minus(ONE_BD)
);
} else {
percentChange.push(currentSeason.percentChange![i]);
}
}
currentSeason.cumulativePercentChange = percentChange.map<BigDecimal>((bd) => bd.truncate(8));
currentSeason.cumulativeTotalPercentChange = prevSeason
Expand Down
2 changes: 1 addition & 1 deletion src/subgraphs/beanstalk/src/utils/constants/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as PintoBase from "../../../../../core/constants/raw/PintoBaseConstants

export function handleInitVersion(block: ethereum.Block): void {
const versionEntity = new Version("subgraph");
versionEntity.versionNumber = "1.11.0";
versionEntity.versionNumber = "1.11.1";
versionEntity.subgraphName = subgraphNameForBlockNumber(block.number);
versionEntity.protocolAddress = protocolForBlockNumber(block.number);
versionEntity.chain = chainForBlockNumber(block.number);
Expand Down
Loading