Skip to content

Commit

Permalink
add etherfi, symbiotic, and other updates for lombard (#41)
Browse files Browse the repository at this point in the history
* upd lombard morpho

* add etherfi, symbiotic, and other updates for lombard
  • Loading branch information
lwedge99 authored Aug 28, 2024
1 parent 7496b5c commit a9430d4
Show file tree
Hide file tree
Showing 26 changed files with 8,811 additions and 47 deletions.
46 changes: 17 additions & 29 deletions points/curve/lombard-curve-ethereum/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,38 @@ CurveStableSwapNGProcessor.bind({
.onEventAddLiquidity(async (event, ctx) => {
const accountAddress = event.args.provider;
const accounts = [accountAddress].filter(
(account) => !isNullAddress(account)
(address) => !isProtocolAddress(address)
);
const newSnapshots = await Promise.all(
accounts.map((account) =>
processAccount(ctx, account, undefined, event.name)
)
);
await ctx.store.upsert(
newSnapshots.filter((snapshot) => snapshot != undefined) as any
);
await ctx.store.upsert(newSnapshots);
})
.onEventRemoveLiquidity(async (event, ctx) => {
const accountAddress = event.args.provider;
const accounts = [accountAddress].filter(
(account) => !isNullAddress(account)
(address) => !isProtocolAddress(address)
);
const newSnapshots = await Promise.all(
accounts.map((account) =>
processAccount(ctx, account, undefined, event.name)
)
);
await ctx.store.upsert(
newSnapshots.filter((snapshot) => snapshot != undefined) as any
);
await ctx.store.upsert(newSnapshots);
})
.onEventTransfer(async (event, ctx) => {
const accounts = [event.args.sender, event.args.receiver];

if (accounts.some(isProtocolAddress)) {
return;
}
const accounts = [event.args.sender, event.args.receiver].filter(
(address) => !isProtocolAddress(address)
);

const newSnapshots = await Promise.all(
accounts.map((account) =>
processAccount(ctx, account, undefined, event.name)
)
);
await ctx.store.upsert(
newSnapshots.filter((snapshot) => snapshot != undefined) as any
);
await ctx.store.upsert(newSnapshots);
})
.onEventTokenExchange(async (event, ctx) => {
const accountSnapshots = await ctx.store.list(AccountSnapshot, []);
Expand All @@ -79,9 +71,7 @@ CurveStableSwapNGProcessor.bind({
processAccount(ctx, snapshot.id.toString(), snapshot, event.name)
)
);
await ctx.store.upsert(
newSnapshots.filter((snapshot) => snapshot != undefined) as any
);
await ctx.store.upsert(newSnapshots);
})
.onTimeInterval(
async (_, ctx) => {
Expand All @@ -91,9 +81,7 @@ CurveStableSwapNGProcessor.bind({
processAccount(ctx, snapshot.id.toString(), snapshot, "TimeInterval")
)
);
await ctx.store.upsert(
newSnapshots.filter((snapshot) => snapshot != undefined) as any
);
await ctx.store.upsert(newSnapshots);
},
60,
4 * 60
Expand All @@ -105,9 +93,6 @@ async function processAccount(
snapshot: AccountSnapshot | undefined,
triggerEvent: string
) {
if (account.toLowerCase() == VAULT_ADDRESS.toLowerCase()) {
return;
}
if (!snapshot) {
snapshot = await ctx.store.get(AccountSnapshot, account);
}
Expand Down Expand Up @@ -174,9 +159,10 @@ async function getAccountSnapshot(
// lpBalance += await gaugeContract.balanceOf(account);
// }
const lpSupply = await ctx.contract.totalSupply();
const share = BigInt(lpBalance)
.asBigDecimal()
.div(BigInt(lpSupply).asBigDecimal());
const share =
lpSupply > 0
? BigInt(lpBalance).asBigDecimal().div(BigInt(lpSupply).asBigDecimal())
: new BigDecimal(0);

const [token0Total, token1Total] = await ctx.contract.get_balances();

Expand All @@ -194,7 +180,9 @@ async function getAccountSnapshot(

function isProtocolAddress(address: string): boolean {
return (
isNullAddress(address) || address.toLowerCase() == POOL_ADDRESS // ||
isNullAddress(address) ||
address.toLowerCase() == VAULT_ADDRESS.toLowerCase() ||
address.toLowerCase() == POOL_ADDRESS // ||
// address.toLowerCase() == GAUGE_ADDRESS
);
}
107 changes: 107 additions & 0 deletions points/etherfi/lombard-etherfi-eth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
.idea
src/types

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
Loading

0 comments on commit a9430d4

Please sign in to comment.