Skip to content
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

Feat/bsc #11

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
26 changes: 26 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,31 @@
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 54484221
}
},
"bsc": {
"ERC20PoolFactory": {
"address": "0x86eE95085F204B525b590f21dec55e2373F6da69",
"startBlock": 43807734
},
"ERC721PoolFactory": {
"address": "0x8A4DaF211979f60339D26b9Eb1407D74fA36a52a",
"startBlock": 43807734
},
"PositionManager": {
"address": "0x2DB531409656B4E1711EE89E6cB9A4a09aC0AAD7",
"startBlock": 43807734
},
"GrantFund": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 43807734
},
"AjnaToken": {
"address": "0x35Ca6c5b02B2F0955c1a1584DD81071888C517E2",
"startBlock": 43744094
},
"BurnWrappedAjna": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 43807734
}
}
}
19 changes: 9 additions & 10 deletions src/mappings/base/base-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,28 +739,27 @@ export function _handleBucketBankruptcy(event: ethereum.Event, index: BigInt, lp
bucketBankruptcy.bucket = bucketId
bucketBankruptcy.pool = pool.id

// Create a new array to store valid lend IDs
let validLends: Bytes[] = []

// iterate through all bucket lends and set lend.lpb to zero
for (let i = 0; i < bucket.lends.length; i++) {
const lendId = bucket.lends[i]

if (lendId) {
const lend = Lend.load(lendId)
if (!lend) {
// If somehow the lend entity is not found, log an error and continue
log.warning("_handleBucketBankruptcy: lend entity with id {} not found", [lendId.toHexString()])
continue
}
if (lendId && Lend.load(lendId)) {
const lend = Lend.load(lendId)!
lend.lpb = ZERO_BD
updateBucketLends(bucket, lend)
updateAccountLends(loadOrCreateAccount(lend.lender), lend)
// remove lend from store
saveOrRemoveLend(lend)
} else {
// if lendId is null for some reason just remove it from bucket
bucket.lends.splice(i, 1)
validLends.push(lendId)
}
}

// Update bucket.lends with only valid lends
bucket.lends = validLends

// iterate through all bucket positionLends and set positionLend.lpb to zero
for (let i = 0; i < bucket.positionLends.length; i++) {
const positionLendId = bucket.positionLends[i]
Expand Down
3 changes: 3 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ poolInfoUtilsAddressTable.set('filecoin', Address.fromString('0xCF7e3DABBaD8F0F3
poolInfoUtilsAddressTable.set('rari', Address.fromString('0xe85958CD5d59755470F6217aE9ee2Aa88eD02eE5'))
poolInfoUtilsAddressTable.set('linea', Address.fromString('0x3AFcEcB6A943746eccd72eb6801E534f8887eEA1'))
poolInfoUtilsAddressTable.set('avalanche', Address.fromString('0x9e407019C07b50e8D7C2d0E2F796C4eCb0F485b3'))
poolInfoUtilsAddressTable.set('bsc', Address.fromString('0x81557781862D3e0FF7559080C2A9AE1F08Ee8421'))
export const poolInfoUtilsMulticallAddressTable = new TypedMap<string, Address>()
poolInfoUtilsMulticallAddressTable.set('mainnet', Address.fromString('0xe4e553243264f2bF7C135F1eC3a8c09078731227'))
poolInfoUtilsMulticallAddressTable.set('arbitrum-one', Address.fromString('0xCcaf0542c78A3A5e55f99630a2B126A5BAA44FC3'))
Expand All @@ -56,6 +57,7 @@ poolInfoUtilsMulticallAddressTable.set('filecoin', Address.fromString('0x82fba8E
poolInfoUtilsMulticallAddressTable.set('rari', Address.fromString('0x26694369Dc342Cc0152A9c5975e10CF7EaB6163e'))
poolInfoUtilsMulticallAddressTable.set('linea', Address.fromString('0x38d55d1f2100dB1423C4907Aa907D47B4670d5EF'))
poolInfoUtilsMulticallAddressTable.set('avalanche', Address.fromString('0xD2b45DD650141a42fF948EC5B99D9E8DF6799B8f'))
poolInfoUtilsMulticallAddressTable.set('bsc', Address.fromString('0x56A08a72197f86625B0Ec64cA675b2b0568AD613'))
export const positionManagerAddressTable = new TypedMap<string, Address>()
positionManagerAddressTable.set('mainnet', Address.fromString('0x87B0F458d8F1ACD28A83A748bFFbE24bD6B701B1'))
positionManagerAddressTable.set('arbitrum-one', Address.fromString('0x9A0BE971530Ed2B53597AC9155AC050ca1Bab7A3'))
Expand All @@ -70,6 +72,7 @@ positionManagerAddressTable.set('filecoin', Address.fromString('0x0cEfA3be6496B8
positionManagerAddressTable.set('rari', Address.fromString('0xBb4a65d74893C14060eDe747361D952f4F47DB6f'))
positionManagerAddressTable.set('linea', Address.fromString('0x083BDB49dBA6f5A225a20893e043220526DeCf54'))
positionManagerAddressTable.set('avalanche', Address.fromString('0x0bf183a32614b3Cd11C0268441D96047D05967e0'))
positionManagerAddressTable.set('bsc', Address.fromString('0x2DB531409656B4E1711EE89E6cB9A4a09aC0AAD7'))

// GrantFund constants
export const CHALLENGE_PERIOD_LENGTH = BigInt.fromI32(50400)
Expand Down