forked from DefiLlama/dimension-adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cacheInCloud option to FetchGetLogsOptions
- Loading branch information
Showing
12 changed files
with
174 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,18 @@ | ||
import { ETHER_ADDRESS } from "@defillama/sdk/build/general"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
import { comptrollerABI, CTokenABI } from "./_abi"; | ||
import * as sdk from "@defillama/sdk"; | ||
|
||
const getAllMarkets = async ( | ||
unitroller: string, | ||
chain: CHAIN | ||
): Promise<string[]> => { | ||
return ( | ||
await sdk.api2.abi.call({ | ||
target: unitroller, | ||
abi: comptrollerABI.getAllMarkets, | ||
chain: chain, | ||
}) | ||
); | ||
}; | ||
const getAllMarketsMulti = async ( | ||
unitrollers: string[], | ||
chain: CHAIN | ||
): Promise<string[]> => { | ||
const getAllMarkets = async (unitroller: string, api: sdk.ChainApi,): Promise<string[]> => { | ||
return (api.call({ target: unitroller, abi: comptrollerABI.getAllMarkets, })); | ||
} | ||
|
||
return ( | ||
await sdk.api2.abi.multiCall({ | ||
calls: unitrollers.map((unitroller: string) => ({target:unitroller})), | ||
abi: comptrollerABI.getAllMarkets, | ||
chain: chain, | ||
}) | ||
).flat(); | ||
}; | ||
const getAllMarketsMulti = async (unitrollers: string[], api: sdk.ChainApi,): Promise<string[]> => { | ||
return (await api.multiCall({ calls: unitrollers, abi: comptrollerABI.getAllMarkets, })).flat(); | ||
} | ||
|
||
const getMarketDetails = async (markets: string[], chain: CHAIN) => { | ||
const getMarketDetails = async (markets: string[], api: sdk.ChainApi,) => { | ||
const underlyings = await api.multiCall({ calls: markets, abi: CTokenABI.underlying, permitFailure: true, }); | ||
const reserveFactors = await api.multiCall({ calls: markets, abi: CTokenABI.reserveFactorMantissa, }); | ||
return { underlyings, reserveFactors, }; | ||
} | ||
|
||
const underlyings = await sdk.api2.abi.multiCall({ | ||
calls: markets.map((market: string) => ({ | ||
target: market, | ||
})), | ||
abi: CTokenABI.underlying, | ||
chain: chain, | ||
permitFailure: true, | ||
}); | ||
|
||
const reserveFactors = await sdk.api2.abi.multiCall({ | ||
calls: markets.map((market: string) => ({ | ||
target: market, | ||
})), | ||
abi: CTokenABI.reserveFactorMantissa, | ||
chain: chain, | ||
}); | ||
|
||
return { | ||
underlyings: underlyings, | ||
reserveFactors: reserveFactors, | ||
}; | ||
}; | ||
|
||
|
||
|
||
export { getAllMarkets, getMarketDetails,getAllMarketsMulti }; | ||
export { getAllMarkets, getMarketDetails, getAllMarketsMulti }; |
Oops, something went wrong.