diff --git a/networks.json b/networks.json index 189b05c..4931e33 100644 --- a/networks.json +++ b/networks.json @@ -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 + } } } diff --git a/src/mappings/base/base-pool.ts b/src/mappings/base/base-pool.ts index 4ea2120..d6c8ba4 100644 --- a/src/mappings/base/base-pool.ts +++ b/src/mappings/base/base-pool.ts @@ -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] diff --git a/src/utils/constants.ts b/src/utils/constants.ts index d00d2f1..8b515ee 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -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() poolInfoUtilsMulticallAddressTable.set('mainnet', Address.fromString('0xe4e553243264f2bF7C135F1eC3a8c09078731227')) poolInfoUtilsMulticallAddressTable.set('arbitrum-one', Address.fromString('0xCcaf0542c78A3A5e55f99630a2B126A5BAA44FC3')) @@ -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() positionManagerAddressTable.set('mainnet', Address.fromString('0x87B0F458d8F1ACD28A83A748bFFbE24bD6B701B1')) positionManagerAddressTable.set('arbitrum-one', Address.fromString('0x9A0BE971530Ed2B53597AC9155AC050ca1Bab7A3')) @@ -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)