Skip to content

Commit

Permalink
feat: v3.1 upgrade (#585)
Browse files Browse the repository at this point in the history
* feat: updated ui pool data provider

* fix: tests

* fix: tests

* fix: types

* fix: temp disable coverage

* fix: types

* fix: types

* fix: revert

* fix: borrow usage ratio calcs

* fix: types

* feat: handle  v3 and v3.1 providers

* fix: testing

* fix: build

* feat: legacy version

* fix: tests, comment
  • Loading branch information
grothem committed Jul 26, 2024
1 parent ecc96db commit c65037e
Show file tree
Hide file tree
Showing 16 changed files with 2,097 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/contract-helpers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
} from './permissions-manager/types/PermissionManagerTypes';
export * from './v3-UiIncentiveDataProvider-contract';
export * from './v3-UiPoolDataProvider-contract';
export * from './v3-UiPoolDataProvider-legacy-contract';
export * from './wallet-balance-provider';
export * from './cl-feed-registry';
// export * from './uiStakeDataProvider-contract';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export const reservesMock: ReservesData = {
_hex: '0x0',
_isBigNumber: true,
}),
virtualAccActive: false,
virtualUnderlyingBalance: BigNumber.from({
_hex: '0x0',
_isBigNumber: true,
}),
},
{
underlyingAsset: '0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11',
Expand Down Expand Up @@ -296,6 +301,11 @@ export const reservesMock: ReservesData = {
_hex: '0x0',
_isBigNumber: true,
}),
virtualAccActive: false,
virtualUnderlyingBalance: BigNumber.from({
_hex: '0x0',
_isBigNumber: true,
}),
},
],
1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class UiPoolDataProvider implements UiPoolDataProviderInterface {
private readonly _contract: UiPoolDataProviderContract;

private readonly chainId: number;

/**
* Constructor
* @param context The ui pool data provider context
Expand Down Expand Up @@ -190,6 +191,9 @@ export class UiPoolDataProvider implements UiPoolDataProviderInterface {
debtCeilingDecimals: reserveRaw.debtCeilingDecimals.toNumber(),
isSiloedBorrowing: reserveRaw.isSiloedBorrowing,
flashLoanEnabled: reserveRaw.flashLoanEnabled,
virtualAccActive: reserveRaw.virtualAccActive,
virtualUnderlyingBalance:
reserveRaw.virtualUnderlyingBalance.toString(),
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export class IUiPoolDataProviderV3 extends BaseContract {
string,
string,
boolean,
boolean?,
BigNumber?,
] & {
underlyingAsset: string;
name: string;
Expand Down Expand Up @@ -212,6 +214,8 @@ export class IUiPoolDataProviderV3 extends BaseContract {
eModePriceSource: string;
eModeLabel: string;
borrowableInIsolation: boolean;
virtualAccActive?: boolean;
virtualUnderlyingBalance?: BigNumber;
})[],
[BigNumber, BigNumber, BigNumber, number] & {
marketReferenceCurrencyUnit: BigNumber;
Expand Down Expand Up @@ -315,6 +319,8 @@ export class IUiPoolDataProviderV3 extends BaseContract {
string,
string,
boolean,
boolean,
BigNumber,
] & {
underlyingAsset: string;
name: string;
Expand Down Expand Up @@ -370,6 +376,8 @@ export class IUiPoolDataProviderV3 extends BaseContract {
eModePriceSource: string;
eModeLabel: string;
borrowableInIsolation: boolean;
virtualAccActive: boolean;
virtualUnderlyingBalance: BigNumber;
})[],
[BigNumber, BigNumber, BigNumber, number] & {
marketReferenceCurrencyUnit: BigNumber;
Expand Down Expand Up @@ -473,6 +481,8 @@ export class IUiPoolDataProviderV3 extends BaseContract {
string,
string,
boolean,
boolean,
BigNumber,
] & {
underlyingAsset: string;
name: string;
Expand Down Expand Up @@ -528,6 +538,8 @@ export class IUiPoolDataProviderV3 extends BaseContract {
eModePriceSource: string;
eModeLabel: string;
borrowableInIsolation: boolean;
virtualAccActive: boolean;
virtualUnderlyingBalance: BigNumber;
})[],
[BigNumber, BigNumber, BigNumber, number] & {
marketReferenceCurrencyUnit: BigNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ const _abi = [
name: 'borrowableInIsolation',
type: 'bool',
},
{
internalType: 'bool',
name: 'virtualAccActive',
type: 'bool',
},
{
internalType: 'uint128',
name: 'virtualUnderlyingBalance',
type: 'uint128',
},
],
internalType: 'struct IUiPoolDataProviderV3.AggregatedReserveData[]',
name: '',
Expand Down Expand Up @@ -412,7 +422,33 @@ const _abi = [
stateMutability: 'view',
type: 'function',
},
];
{
inputs: [],
name: 'marketReferenceCurrencyPriceInUsdProxyAggregator',
outputs: [
{
internalType: 'contract IEACAggregatorProxy',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'networkBaseTokenPriceInUsdProxyAggregator',
outputs: [
{
internalType: 'contract IEACAggregatorProxy',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
] as const;

export class IUiPoolDataProviderV3__factory {
static readonly abi = _abi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface ReservesData {
eModeLabel: string;
borrowableInIsolation: boolean;
flashLoanEnabled: boolean;
virtualAccActive: boolean;
virtualUnderlyingBalance: BigNumber;
}>;
1: {
marketReferenceCurrencyUnit: BigNumber;
Expand Down Expand Up @@ -141,6 +143,8 @@ export interface ReserveDataHumanized {
eModeLabel: string;
borrowableInIsolation: boolean;
flashLoanEnabled: boolean;
virtualAccActive: boolean;
virtualUnderlyingBalance: string;
}

export interface ReservesDataHumanized {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ describe('UiPoolDataProvider', () => {
debtCeilingDecimals: 0,
borrowableInIsolation: false,
flashLoanEnabled: false,
virtualAccActive: false,
virtualUnderlyingBalance: '0',
},
{
id: '137-0xa478c2975ab1ea89e8196811f51a7b7ade33eb11-0x88757f2f99175387ab4c6a4b3067c77a695b0349',
Expand Down Expand Up @@ -257,6 +259,8 @@ describe('UiPoolDataProvider', () => {
debtCeilingDecimals: 0,
borrowableInIsolation: false,
flashLoanEnabled: false,
virtualAccActive: false,
virtualUnderlyingBalance: '0',
},
],
baseCurrencyData: {
Expand Down
Loading

0 comments on commit c65037e

Please sign in to comment.