Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Jul 24, 2024
1 parent e6a0e94 commit e421003
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/protocol/beefy/loader/investment/import-investments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,11 @@ function fetchBeefyBridgedVaultShareRateIfNeeded<TInput extends { target: { prod
ctx,
emitError: options.emitError,
getBlockDate: (item) => item.blockDatetime,
formatOutput: (item, shareRateBlockNumber) => ({ ...item, shareRateBlockNumber }),
formatOutput: (item, shareRateBlockNumberOnOriginChain) => ({ ...item, shareRateBlockNumberOnOriginChain }),
}),

Rx.tap((item) => logger.trace({ msg: "loading share rate", data: { chain: ctx.chain, transferData: item } })),

// then we can fetch the share rate in the context of the origin chain
fetchBeefyTransferData$({
ctx,
Expand All @@ -460,24 +462,25 @@ function fetchBeefyBridgedVaultShareRateIfNeeded<TInput extends { target: { prod
contractAddress: item.target.transfer.tokenAddress,
ownerAddress: item.target.transfer.ownerAddress,
};
const blockNumber = item.shareRateBlockNumber;

if (isBeefyBridgedVault(item.target.product)) {
const vault = item.target.product.productData.vault.bridged_version_of;
return {
shareRateParams: {
vaultAddress: vault.contract_address,
underlyingDecimals: vault.want_decimals,
vaultDecimals: vault.token_decimals,
},
balance,
blockNumber,
fetchShareRate: true, // we don't have a share rate on the same chain for bridged vaults
fetchBalance: false,
};
const blockNumber = item.shareRateBlockNumberOnOriginChain;

if (!isBeefyBridgedVault(item.target.product)) {
logger.error({ msg: "Unsupported product type", data: { product: item.target.product } });
throw new ProgrammerError("Unsupported product type");
}
logger.error({ msg: "Unsupported product type", data: { product: item.target.product } });
throw new ProgrammerError("Unsupported product type");

const vault = item.target.product.productData.vault.bridged_version_of;
return {
shareRateParams: {
vaultAddress: vault.contract_address,
underlyingDecimals: vault.want_decimals,
vaultDecimals: vault.token_decimals,
},
balance,
blockNumber,
fetchShareRate: true, // we don't have a share rate on the same chain for bridged vaults
fetchBalance: false,
};
},
formatOutput: (item, { blockDatetime, shareRate }) => ({
...item,
Expand Down
2 changes: 2 additions & 0 deletions src/protocol/common/connector/block-from-datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ function fetchBlockFromDatetimeUsingExplorerAPI$<TObj, TErr extends ErrorEmitter
blockNumber = parseInt(blockNumber);
}

logger.trace({ msg: "Block number found", data: { timestamp, blockNumber, params } });

return [options.formatOutput(obj, blockNumber)];
} catch (error) {
logger.error({ msg: "Error while fetching contract creation block", data: { params, error: error } });
Expand Down

0 comments on commit e421003

Please sign in to comment.