Skip to content

Commit

Permalink
sUSDs - base (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco authored Feb 3, 2025
1 parent 6be0e76 commit 84247db
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-actors-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

sUSDs - base
4 changes: 4 additions & 0 deletions config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export default <NetworkData>{
},
},
ybAprConfig: {
susds: {
oracle: '0x65d946e533748a998b1f0e430803e39a6388f7a1',
token: '0x5875eee11cf8398102fdad704c9e96607675467a',
},
morpho: {
tokens: {},
},
Expand Down
1 change: 1 addition & 0 deletions modules/pool/lib/apr-data-sources/yb-apr-handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const sourceToHandler = {
sftmx: sources.SftmxAprHandler,
sts: sources.StsAprHandler,
silo: sources.SiloAprHandler,
susds: sources.SUSDSAprHandler,
};

export class YbAprHandlers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export * from './teth';
export * from './morpho-apr-handler';
export * from './morpho-token-apr-handler';
export * from './usdl-apr-handler';
export * from './susds-apr-handler';
// These need a refactor, because they depend on the network context
export * from './sftmx-apr-handler';
export * from './sts-apr-handler';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { AprHandler } from '../types';
import config from '../../../../../../config';
import { createPublicClient, http, parseAbiItem } from 'viem';
import { base } from 'viem/chains';

const client = createPublicClient({
chain: base,
transport: http(config.BASE.rpcUrl),
});

const ssrOracle = '0x65d946e533748a998b1f0e430803e39a6388f7a1';

export class SUSDSAprHandler implements AprHandler {
group = 'MAKER';
private oracle: string;
private token: string;

constructor({ oracle, token }: { oracle: string; token: string }) {
this.oracle = oracle;
this.token = token;
}

async getAprs() {
const aprs: { [p: string]: { apr: number; isIbYield: boolean; group: string } } = {};
try {
const apr = await client.readContract({
abi: [parseAbiItem('function getAPR() view returns (uint256)')],
address: this.oracle as `0x${string}`,
functionName: 'getAPR',
});

const tokenApr = Number(apr) * 10 ** -27;

aprs[this.token] = {
apr: tokenApr,
isIbYield: false,
group: this.group,
};
} catch (error) {
console.error(`sUSDS APR Failed for token ${this.token}: `, error);
}
return aprs;
}
}

0 comments on commit 84247db

Please sign in to comment.