Skip to content

Commit

Permalink
Maple syrup apr (#696)
Browse files Browse the repository at this point in the history
* mapleSyrupAPR

Adding syrupUSDC apr handler to backend.

Pool: https://balancer.fi/pools/ethereum/v2/0xd7f6a3c844d431f083e576a9972e56192a6635f30000000000000000000006b4

Token: https://etherscan.io/token/0x80ac24aa929eaf5013f6436cda2a7ba190f5cc0b

* stakewise APRs

* syrup USDC APR

* changeset

---------

Co-authored-by: gmbronco <[email protected]>
  • Loading branch information
Zen-Maxi and gmbronco authored Aug 2, 2024
1 parent 116ae79 commit e102809
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-adults-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

stakewise gnosis and maple syrup APRs
5 changes: 4 additions & 1 deletion config/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ export default <NetworkData>{
},
},
},
stakewise: '0xf7d4e7273e5015c96728a6b02f31c505ee184603',
stakewise: {
url: 'https://mainnet-graph.stakewise.io/subgraphs/name/stakewise/stakewise',
token: '0xf7d4e7273e5015c96728a6b02f31c505ee184603',
},
etherfi: '0x35751007a407ca6feffe80b3cb397736d2cf4dbe',
defaultHandlers: {
wstETH: {
Expand Down
4 changes: 4 additions & 0 deletions config/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export default <NetworkData>{
multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
avgBlockSpeed: 1,
ybAprConfig: {
stakewise: {
url: 'https://gnosis-graph.stakewise.io/subgraphs/name/stakewise/stakewise',
token: '0xf490c80aae5f2616d3e3bda2483e30c4cb21d1a0',
},
defaultHandlers: {
wstETH: {
tokenAddress: '0x6c76971f98945ae98dd7d4dfca8711ebea946ea6',
Expand Down
10 changes: 9 additions & 1 deletion config/mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BigNumber } from 'ethers';
import { env } from '../app/env';
import { syncReliquaryStakingForPools } from '../modules/actions/pool/staking';
import { DeploymentEnv, NetworkData } from '../modules/network/network-config-types';

const underlyingTokens = {
Expand Down Expand Up @@ -236,8 +237,15 @@ export default <NetworkData>{
},
},
},
stakewise: '0xf1c9acdc66974dfb6decb12aa385b9cd01190e38',
stakewise: {
url: 'https://mainnet-graph.stakewise.io/subgraphs/name/stakewise/stakewise',
token: '0xf1c9acdc66974dfb6decb12aa385b9cd01190e38',
},
etherfi: '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee',
maple: {
url: 'https://api.maple.finance/v2/graphql',
token: '0x80ac24aa929eaf5013f6436cda2a7ba190f5cc0b',
},
sveth: true,
defaultHandlers: {
uniETH: {
Expand Down
9 changes: 8 additions & 1 deletion modules/network/apr-config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ export interface YbAprConfig {
tetu?: TetuAprConfig;
tranchess?: TranchessAprConfig;
yearn?: YearnAprConfig;
stakewise?: string;
stakewise?: {
url: string;
token: string;
};
maple?: {
url: string;
token: string;
};
etherfi?: string;
sveth?: boolean;
defaultHandlers?: DefaultHandlerAprConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { YbAprConfig } from '../../../../../network/apr-config-types';

const query = `{
syrupGlobals {
apy
}
}`;

const requestQuery = {
query,
};

interface Response {
data: {
syrupGlobals: {
apy: string;
};
};
}

export class Maple {
constructor(private config: YbAprConfig['maple']) {}

async getAprs() {
const response = await fetch(this.config!.url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestQuery),
});

const {
data: {
syrupGlobals: { apy },
},
} = (await response.json()) as Response;

const apr = parseFloat(apy) / 1e28;

return {
[this.config!.token]: { apr, isIbYield: true },
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const url = 'https://mainnet-graph.stakewise.io/subgraphs/name/stakewise/stakewise';
import { YbAprConfig } from '../../../../../network/apr-config-types';

const query = `
{
Expand All @@ -21,10 +21,10 @@ interface Response {
}

export class Stakewise {
constructor(private tokenAddress: string) {}
constructor(private config: YbAprConfig['stakewise']) {}

async getAprs() {
const response = await fetch(url, {
const response = await fetch(this.config!.url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -38,11 +38,10 @@ export class Stakewise {
},
} = (await response.json()) as Response;

const apr = Number(apy) / 100;

return {
[this.tokenAddress]: {
apr: Number(apy) / 100,
isIbYield: true,
},
[this.config!.token]: { apr, isIbYield: true },
};
}
}

0 comments on commit e102809

Please sign in to comment.