Skip to content

Commit

Permalink
Merge pull request #149 from eq-lab/fix/int-tests
Browse files Browse the repository at this point in the history
prices and balances calls fixes
  • Loading branch information
mn13 authored Jul 31, 2024
2 parents c23e43e + 9926358 commit 2ae196f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions integration-tests/tests/pool.sut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export interface FlashLoanAsset {
borrow: boolean;
}

interface PriceFeedConfig {

interface PriceFeed {
feed: string;
feed_asset: SlenderAsset;
feed_decimals: number;
Expand All @@ -45,6 +46,13 @@ interface PriceFeedConfig {
timestamp_precision: string;
}

interface PriceFeedConfig {
feeds: PriceFeed[];
asset_decimals: number;
min_sanity_price_in_base: number;
max_sanity_price_in_base: number;
}

interface PriceData {
price: bigint;
timestamp: bigint;
Expand Down Expand Up @@ -620,7 +628,7 @@ export async function readPriceFeed(
): Promise<PriceFeedConfig> {
const xdrResponse = await client.simulateTransaction(
process.env.SLENDER_POOL,
"price_feed",
"price_feeds",
convertToScvAddress(process.env[`SLENDER_TOKEN_${asset}`])
);

Expand All @@ -635,7 +643,7 @@ export async function readPrice(
const xdrResponse = await client.simulateTransaction(
feed,
"lastprice",
convertToScvAddress(process.env[`SLENDER_TOKEN_${asset}`])
convertToScvAddress(process.env[`SLENDER_TOKEN_${asset}`]),
);

return parseScvToJs<PriceData>(xdrResponse).price;
Expand Down Expand Up @@ -818,7 +826,7 @@ async function initPoolPriceFeed(
asset_decimals: number,
max_sanity_price_in_base: bigint,
min_sanity_price_in_base: bigint,
priceFeedConfig: PriceFeedConfig
priceFeedConfig: PriceFeed
}[]
): Promise<void> {
await initContract(
Expand Down Expand Up @@ -896,9 +904,9 @@ export async function inPoolBalanceOf(
): Promise<bigint> {
const xdrResponse = await client.simulateTransaction(
process.env.SLENDER_POOL,
"balance",
"token_balance",
convertToScvAddress(process.env[`SLENDER_TOKEN_${asset}`]),
convertToScvAddress(who),
convertToScvAddress(process.env[`SLENDER_TOKEN_${asset}`])
);

return parseScvToJs(xdrResponse);
Expand Down

0 comments on commit 2ae196f

Please sign in to comment.