Skip to content

Commit a0822b0

Browse files
committed
Merge tag 'v13.0.0-next.21' into load-kyc-ca
2 parents 50f1eee + f75d8ee commit a0822b0

File tree

8 files changed

+38
-10
lines changed

8 files changed

+38
-10
lines changed

src/sdk/market/MarketSuite.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Address } from "viem";
22

33
import type { MarketData } from "../base/index.js";
4-
import { Construct, SDKConstruct } from "../base/index.js";
4+
import { SDKConstruct } from "../base/index.js";
55
import type { GearboxSDK } from "../GearboxSDK.js";
66
import type { MarketStateHuman } from "../types/index.js";
77
import { CreditSuite } from "./credit/index.js";
@@ -13,6 +13,7 @@ import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
1313
import type { IPriceOracleContract } from "./oracle/index.js";
1414
import { getOrCreatePriceOracle } from "./oracle/index.js";
1515
import { PoolSuite } from "./pool/index.js";
16+
import type { SecuritizeKYCFactory } from "./pool/SecuritizeKYCFactory.js";
1617

1718
export class MarketSuite extends SDKConstruct {
1819
public readonly acl: Address;
@@ -62,6 +63,10 @@ export class MarketSuite extends SDKConstruct {
6263
return this.pool.underlying;
6364
}
6465

66+
public async getKYCFactory(): Promise<SecuritizeKYCFactory | undefined> {
67+
return this.pool.getKYCFactory();
68+
}
69+
6570
override get dirty(): boolean {
6671
return (
6772
this.configurator.dirty ||

src/sdk/market/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from "./adapters/index.js";
22
export * from "./credit/index.js";
3-
export * from "./kyc/index.js";
43
export * from "./MarketRegister.js";
54
export * from "./MarketSuite.js";
65
export * from "./oracle/index.js";

src/sdk/market/kyc/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/sdk/market/pool/PoolSuite.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import createPoolQuotaKeeper from "./createPoolQuotaKeeper.js";
1111
import createRateKeeper from "./createRateKeeper.js";
1212
import { GaugeContract } from "./GaugeContract.js";
1313
import { LinearInterestRateModelContract } from "./LinearInterestRateModelContract.js";
14+
import type { SecuritizeKYCFactory } from "./SecuritizeKYCFactory.js";
1415
import { TumblerContract } from "./TumblerContract.js";
1516
import type {
1617
IInterestRateModelContract,
@@ -76,6 +77,10 @@ export class PoolSuite extends SDKConstruct {
7677
return this.pool.underlying;
7778
}
7879

80+
public async getKYCFactory(): Promise<SecuritizeKYCFactory | undefined> {
81+
return this.pool.getKYCFactory();
82+
}
83+
7984
override get dirty(): boolean {
8085
return (
8186
this.pool.dirty ||

src/sdk/market/pool/PoolV300Contract.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
formatBNvalue,
2020
percentFmt,
2121
} from "../../utils/index.js";
22+
import type { SecuritizeKYCFactory } from "./SecuritizeKYCFactory.js";
2223

2324
const abi = [...iPoolV300Abi, ...iPausableAbi] as const;
2425
type abi = typeof abi;
@@ -51,6 +52,10 @@ export class PoolV300Contract extends BaseContract<abi> {
5152
});
5253
}
5354

55+
public async getKYCFactory(): Promise<SecuritizeKYCFactory | undefined> {
56+
return undefined;
57+
}
58+
5459
public override stateHuman(raw = true): PoolStateHuman {
5560
return {
5661
...super.stateHuman(raw),

src/sdk/market/pool/PoolV310Contract.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ import type {
66

77
import { iPoolV310Abi } from "../../../abi/310/generated.js";
88
import { iPausableAbi } from "../../../abi/iPausable.js";
9-
import type {
10-
ConstructOptions,
11-
CreditManagerDebtParams,
12-
PoolState,
13-
} from "../../base/index.js";
9+
import type { CreditManagerDebtParams, PoolState } from "../../base/index.js";
1410
import { BaseContract } from "../../base/index.js";
11+
import type { GearboxSDK } from "../../GearboxSDK.js";
1512
import type { PoolStateHuman } from "../../types/index.js";
1613
import {
1714
AddressMap,
1815
formatBN,
1916
formatBNvalue,
2017
percentFmt,
2118
} from "../../utils/index.js";
19+
import { SecuritizeKYCFactory } from "./SecuritizeKYCFactory.js";
2220

2321
const abi = [...iPoolV310Abi, ...iPausableAbi] as const;
2422
type abi = typeof abi;
@@ -30,14 +28,17 @@ export interface PoolV310Contract
3028

3129
export class PoolV310Contract extends BaseContract<abi> {
3230
public readonly creditManagerDebtParams: AddressMap<CreditManagerDebtParams>;
31+
#sdk: GearboxSDK;
32+
#kycFactory?: SecuritizeKYCFactory;
3333

34-
constructor(options: ConstructOptions, data: PoolState) {
34+
constructor(sdk: GearboxSDK, data: PoolState) {
3535
const { baseParams, creditManagerDebtParams, ...rest } = data;
36-
super(options, {
36+
super(sdk, {
3737
...data.baseParams,
3838
name: `PoolV3(${data.name})`,
3939
abi,
4040
});
41+
this.#sdk = sdk;
4142
Object.assign(this, rest);
4243
this.creditManagerDebtParams = new AddressMap(
4344
creditManagerDebtParams.map(p => [p.creditManager, p]),
@@ -51,6 +52,19 @@ export class PoolV310Contract extends BaseContract<abi> {
5152
});
5253
}
5354

55+
public async getKYCFactory(): Promise<SecuritizeKYCFactory | undefined> {
56+
if (this.#kycFactory) {
57+
return this.#kycFactory;
58+
}
59+
await this.#sdk.tokensMeta.loadTokenData(this.underlying);
60+
const u = this.#sdk.tokensMeta.mustGet(this.underlying);
61+
if (this.#sdk.tokensMeta.isKYCUnderlying(u)) {
62+
this.#kycFactory = new SecuritizeKYCFactory(this.#sdk, u.kycFactory);
63+
}
64+
65+
return this.#kycFactory;
66+
}
67+
5468
public override stateHuman(raw = true): PoolStateHuman {
5569
return {
5670
...super.stateHuman(raw),
File renamed without changes.

src/sdk/market/pool/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export * from "./LinearInterestRateModelContract.js";
33
export * from "./PoolQuotaKeeperV300Contract.js";
44
export * from "./PoolSuite.js";
55
export * from "./PoolV300Contract.js";
6+
export * from "./SecuritizeKYCFactory.js";
67
export * from "./types.js";

0 commit comments

Comments
 (0)