본문으로 건너뛰기

메인터이너 SDK

Maintainer SDK는 마진 풀을 관리하고, 금리를 구성하며, 어떤 DeepBook 풀이 margin lending에 액세스할 수 있는지 제어하기 위한 administrative 함수를 제공한다. 이 함수들은 적절한 capability를 가진 maintainer로 제한된다.

maintainer 함수

DeepBook Margin SDK는 풀 administration과 configuration을 위한 다음 함수를 제공한다.

createMarginPool

특정 자산에 대한 새 마진 풀을 생성하려면 createMarginPool을 사용한다. maintainer capability가 필요하다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 자산 타입을 식별하는 String이다.
  • poolConfig: protocol configuration을 나타내는 TransactionArgument이다.

newProtocolConfig

마진 풀 setting과 interest 파라미터를 결합한 새 protocol configuration 객체를 생성하려면 newProtocolConfig를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 자산 타입을 식별하는 String이다.
  • marginPoolConfig: 풀 setting을 포함하는 MarginPoolConfigParams 객체이다.
  • interestConfig: 금리 파라미터를 포함하는 InterestConfigParams 객체이다.

newMarginPoolConfig

마진 풀 configuration 객체를 생성하려면 newMarginPoolConfig를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 자산 타입을 식별하는 String이다.
  • marginPoolConfig: 다음을 포함하는 MarginPoolConfigParams 객체이다:
    • supplyCap: 허용되는 최대 supply를 나타내는 Number이다
    • maxUtilizationRate: 최대 이용률을 나타내는 Number이다(예: 80%는 0.8이다)
    • referralSpread: protocol spread percentage를 나타내는 Number이다
    • minBorrow: 최소 차입 amount를 나타내는 Number이다

newInterestConfig

interest configuration 객체를 생성하려면 newInterestConfig를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • interestConfig: 다음을 포함하는 InterestConfigParams 객체이다:
    • baseRate: base 금리를 나타내는 Number이다
    • baseSlope: kink 이전의 금리 slope를 나타내는 Number이다
    • optimalUtilization: kink point를 나타내는 Number이다(예: 0.8)
    • excessSlope: kink 이후의 금리 slope를 나타내는 Number이다

enableDeepbookPoolForLoan, disableDeepbookPoolForLoan

이 함수들을 사용해 어떤 DeepBook 풀이 마진 풀에서 차입할 수 있는지 제어한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • deepbookPoolKey: DeepBook 풀을 식별하는 String이다.
  • coinKey: 마진 풀 자산을 식별하는 String이다.
  • marginPoolCap: 마진 풀 capability ID를 나타내는 String이다.

updateInterestParams

마진 풀의 금리 파라미터를 업데이트하려면 updateInterestParams를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 마진 풀 자산을 식별하는 String이다.
  • marginPoolCap: 마진 풀 capability ID를 나타내는 String이다.
  • interestConfig: 새 interest 파라미터를 포함하는 InterestConfigParams 객체이다.

updateMarginPoolConfig

마진 풀의 configuration setting을 업데이트하려면 updateMarginPoolConfig를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 마진 풀 자산을 식별하는 String이다.
  • marginPoolCap: 마진 풀 capability ID를 나타내는 String이다.
  • marginPoolConfig: 새 풀 setting을 포함하는 MarginPoolConfigParams 객체이다.

withdrawMaintainerFees

마진 풀에서 누적된 maintainer fee를 인출하려면 withdrawMaintainerFees를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 마진 풀 자산을 식별하는 String이다.
  • marginPoolCap: 마진 풀 capability ID를 나타내는 String이다.

withdrawProtocolFees

마진 풀에서 누적된 프로토콜 수수료를 인출하려면 withdrawProtocolFees를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 마진 풀 자산을 식별하는 String이다.

adminWithdrawDefaultReferralFees

마진 풀에서 기본값 리퍼럴 수수료를 인출하려면 adminWithdrawDefaultReferralFees를 사용한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.

매개변수

  • coinKey: 마진 풀 자산을 식별하는 String이다.

예시

다음 예시는 일반적인 maintainer operation을 시연한다.

마진 풀 생성

// Example: Create a USDC margin pool
createUsdcMarginPool = (tx: Transaction) => {
const coinKey = 'USDC';

// Create pool configuration
const poolConfig = tx.add(
this.maintainerContract.newProtocolConfig(
coinKey,
{
supplyCap: 10_000_000, // 10M USDC
maxUtilizationRate: 0.8, // 80%
referralSpread: 0.1, // 10% protocol spread
minBorrow: 100, // 100 USDC minimum
},
{
baseRate: 0.02, // 2% base rate
baseSlope: 0.1, // 10% slope before kink
optimalUtilization: 0.8, // 80% kink point
excessSlope: 1.0, // 100% slope after kink
},
),
);

// Create the pool
tx.add(this.maintainerContract.createMarginPool(coinKey, poolConfig));
};

borrowing용 DeepBook 풀 enable

// Example: Allow SUI/USDC pool to borrow from USDC margin pool
enablePoolForBorrowing = (tx: Transaction) => {
const deepbookPoolKey = 'SUI_DBUSDC';
const coinKey = 'USDC';
const marginPoolCapId = '0x...'; // Margin pool cap ID

tx.add(
this.maintainerContract.enableDeepbookPoolForLoan(deepbookPoolKey, coinKey, marginPoolCapId),
);
};

금리 파라미터 update

// Example: Update USDC margin pool interest rates
updateInterestRates = (tx: Transaction) => {
const coinKey = 'USDC';
const marginPoolCapId = '0x...';

tx.add(
this.maintainerContract.updateInterestParams(coinKey, marginPoolCapId, {
baseRate: 0.03, // Increase to 3% base rate
baseSlope: 0.12, // Increase slope
optimalUtilization: 0.75, // Lower kink to 75%
excessSlope: 1.5, // Steeper excess slope
}),
);
};

마진 풀 configuration update

// Example: Update USDC margin pool limits
updatePoolConfig = (tx: Transaction) => {
const coinKey = 'USDC';
const marginPoolCapId = '0x...';

tx.add(
this.maintainerContract.updateMarginPoolConfig(coinKey, marginPoolCapId, {
supplyCap: 20_000_000, // Increase to 20M USDC
maxUtilizationRate: 0.85, // Allow 85% utilization
referralSpread: 0.12, // Increase protocol spread
minBorrow: 50, // Lower minimum to 50 USDC
}),
);
};

풀 setup workflow 완료

// Example: Complete workflow for setting up a new margin pool
setupNewMarginPool = (tx: Transaction) => {
const coinKey = 'SUI';

// Step 1: Create protocol config
const poolConfig = tx.add(
this.maintainerContract.newProtocolConfig(
coinKey,
{
supplyCap: 1_000_000, // 1M SUI
maxUtilizationRate: 0.75,
referralSpread: 0.1,
minBorrow: 10,
},
{
baseRate: 0.01,
baseSlope: 0.08,
optimalUtilization: 0.8,
excessSlope: 0.8,
},
),
);

// Step 2: Create the margin pool
tx.add(this.maintainerContract.createMarginPool(coinKey, poolConfig));

// Step 3: Enable specific DeepBook pools for borrowing
const marginPoolCapId = '0x...'; // Get from pool creation event
tx.add(this.maintainerContract.enableDeepbookPoolForLoan('SUI_DBUSDC', coinKey, marginPoolCapId));
tx.add(this.maintainerContract.enableDeepbookPoolForLoan('SUI_USDT', coinKey, marginPoolCapId));
};