@moonwell-fi/moonwell-sdk
Version:
TypeScript Interface for Moonwell
20 lines • 721 B
JavaScript
import { getEnvironmentFromArgs } from "../../../common/index.js";
import { getUserPositionData } from "./common.js";
export async function getUserPosition(client, args) {
let { marketAddress, userAddress } = args;
const environment = getEnvironmentFromArgs(client, args);
if (!environment) {
return undefined;
}
if (!marketAddress) {
const { market } = args;
marketAddress = environment.markets[market].address;
}
const userPosition = await getUserPositionData({
environment,
account: userAddress,
markets: [marketAddress],
});
return userPosition?.length > 0 ? userPosition[0] : undefined;
}
//# sourceMappingURL=getUserPosition.js.map