k2Lending sub-class
The following readme describes all the functions and their parameters exposed by the k2Lending
class of the K2 SDK. This class exposes all the important functions from the K2 Lending protocol.
setDelegatedRecipient function
This function can be used by the recipient of LST yield to further delegate claim rights to another recipient in exchange for something else.
Input Parameters
recipient: ETH address of the new recipient
Using setDelegatedRecipient function
Return Parameter
Transaction details if the transaction was successful.
getDebtor function
This function allows anyone to get the debtor related information just by the debtor address.
Input Parameters
debtor: ETH address of the debtor
Using getDebtor function
Return Parameter
Returns data of a particular debtor.
getBorrowDuration function
Get the borrow duration set by the contract.
Using getBorrowDuration function
Return Parameter
Borrow duration in BigInt.
getDAOAddress function
Get the DAO address associated with the contract.
Using getDAOAddress function
Return Parameter
ETH address of the DAO.
getProposerRegistry function
Get the proposer registry ETH address.
Using getProposerRegistry function
Return Parameter
ETH address of the proposer registry.
getNodeOperatorInclusionList function
Get the contract that manages the node operators eligible for native delegation.
Using getNodeOperatorInclusionList function
Return Parameter
ETH address of the contract that manages the node operators eligible for native delegation.
deposit function
Deposits KETH into the pool and mints pool shares to the sender.
Input Parameters
amount: amount of kETH to be deposited
Using deposit function
Return Parameter
Transaction details if the transaction was successful.
depositFor function
Deposit kETH for another ETH address.
Input Parameters
amount: amount of kETH to be deposited
recipient: ETH address to deposit kETH for
Using depositFor function
Return Parameter
Transaction details if the transaction was successful.
withdraw function
Burns shares from the sender and returns the equivalent fraction of remaining KETH liquidity. Optionally, sends all KETH accrued by the lender.
Input Parameters
amount: amount of kETH to be withdrawn
claim: true
for claiming accrued kETH
Using withdraw function
Return Parameter
Transaction details if the transaction was successful.
claimKETHForLender function
Claims all of the accrued KETH for the lender and sends it to the lender’s address.
Input Parameters
lender: ETH address of the lender
Using claimKETHForLender function
Return Parameter
Transaction details if the transaction was successful.
nodeOperatorDeposit function
Deposit node operator in K2 lending protocol.
Input Parameters
blsPublicKey: BLS public key of the validator
payoutRecipient: ETH address of the recipient that would receive payout
blsSignature: BLS Signature associated with the BLS public key
ecdsaSignature: ECDSA signature
Using nodeOperatorDeposit function
Return Parameter
Transaction details if the transaction was successful.
batchNodeOperatorDeposit function
Batch deposit multiple node operators in K2 lending protocol.
Input Parameters
blsPublicKeys: Array of BLS public keys of the validators
payoutRecipients: Array of ETH addresses of the recipients that would receive payout
blsSignatures: Array of BLS Signatures associated with the BLS public keys
ecdsaSignatures: Array of ECDSA signatures
Using batchNodeOperatorDeposit function
Return Parameter
Transaction details if the transaction was successful.
nodeOperatorWithdraw function
Withdraw node operator from the K2 Lending protocol.
Input Parameters
nodeOperatorAddress: ETH address of the node operator
blsPublicKey: BLS public key string
Using nodeOperatorWithdraw function
Return Parameter
Transaction details if the transaction was successful.
nodeOperatorKick function
Kick node operator from the K2 Lending protocol.
Input Parameters
reporterAddress: ETH address of the reporter
blsPublicKey: BLS public key
Using nodeOperatorKick function
Return Parameter
Transaction details if the transaction was successful.
nodeOperatorClaim function
Claim ETH earned for all the BLS public keys associated with a node operator.
Input Parameters
blsPublicKeys: List of BLS public keys to claim for
Using nodeOperatorClaim function
Return Parameter
Transaction details if the transaction was successful.
slash function
Slash KETH from the pool. This function can only be called by a reporter.
Input Parameters
slashType: the slash type (liveness & corruption) debtor: the debtor address amount: the slash amount recipient: the recipient address
Using slash function
Return Parameter
Transaction details if the transaction was successful.
terminate function
Terminate debt position
Input Parameters
debtor: ETH address of the debtor
Using terminate function
Return Parameter
Transaction details if the transaction was successful.
liquidate function
Liquidate debt position.
Input Parameters
debtor: ETH address of the debtor
Using liquidate function
Return Parameter
Transaction details if the transaction was successful.
topUpSlashAmount function
Top up kETH if it gets slashed.
Input Parameters
debtor: debtor address in string format
amount: amount of kETH to topup
Using topUpSlashAmount function
Return Parameter
Transaction details if the transaction was successful.
topUpAndTerminate function
Top up kETH if it gets slashed and terminate debt position.
Input Parameters
amount: amount of kETH to topup
Using topUpAndTerminate function
Return Parameter
Transaction details if the transaction was successful.
borrow function
Borrows KETH from the pool and records the debt to the debtor’s address
Input Parameters
debtPositionType: debt position type
designatedVerifier: The designated verifier of debtor
amount: The debt principal to borrow
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption
rstConfigParams: config params of type RSTConfigParamsT
Using borrow function
Return Parameter
Transaction details if the transaction was successful.
borrowFor function
Borrows KETH from the pool for another debtor and records the debt to the debtor’s address
Input Parameters
debtor: Address of the debtor
debtPositionType: debt position type
designatedVerifier: The designated verifier of debtor
amount: The debt principal to borrow
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption
rstConfigParams: config params of type RSTConfigParamsT
Using borrowFor function
Return Parameter
Transaction details if the transaction was successful.
increaseDebt function
Increase the SBP coverage and borrow a larger amount from K2 protocol which will cancel the old SBP.
Input Parameters
debtPositionType: debt position type
designatedVerifier: The designated verifier of debtor
amount: The debt principal to borrow
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption
resetDuration: If true, resets the duration else keeps the remaining duration of the borrow
Using increaseDebt function
Return Parameter
Transaction details if the transaction was successful.
increaseDebtFor function
Increase the SBP coverage and borrow a larger amount from K2 protocol for another debtor which will cancel the old SBP.
Input Parameters
debtor: Address of the debtor
debtPositionType: debt position type
designatedVerifier: The designated verifier of debtor
amount: The debt principal to borrow
maxSlashableAmountPerLiveness: Maximum slashable amount per liveness
maxSlashableAmountPerCorruption: Maximum slashable amount per corruption
resetDuration: If true, resets the duration else keeps the remaining duration of the borrow
Using increaseDebtFor function
Return Parameter
Transaction details if the transaction was successful.
totalSupply function
Returns the ERC-20 token supply for K2 LP.
Using totalSupply function
Return Parameter
Returns the total supply of the token.
getTotalBorrowableAmount function
The total amount that SBP can borrow from the K2 protocol.
Using getTotalBorrowableAmount function
Return Parameter
Returns the total amount that SBP can borrow from the protocol.
getOutstandingInterest function
Get the outstanding interest that is left for the SBP to pay the lenders.
Input Parameters
debtor: ETH address of the debtor
Using getOutstandingInterest function
Return Parameters
Returns the total outstanding interest that is left for the SBP to pay the lenders.
setHookAsDebtorForSBP function
External hook contract. Set to address(0) to disable the hook
Input Parameters
hookAddress: ETH address of the hook contract. Set to address(0) by default
Using setHookAsDebtorForSBP function
Return Parameter
Transaction details if the transaction was successful.
claimableKETHForNativelyDelegatedBLSKey function
Preview claimable kETH for a BLS public key delegated by the node operator.
Input Parameters
blsPublicKey: BLS public key in string
Using claimableKETHForNativelyDelegatedBLSKey function
Return Parameter
Transaction details if the transaction was successful.
getTotalBorrowableAmountWithMaxBorrowRatio function
Get the total borrowable max amount for the given max borrow ratio.
Input Parameters
debtPositionType: debt position type
Using getTotalBorrowableAmountWithMaxBorrowRatio function
Return Parameter
Returns the total borrowable amount with max borrow ratio.
getBorrowedLiquidity function
Get the borrowed liquidity.
Using getTotalBorrowableAmountWithMaxBorrowRatio function
Return Parameter
Returns the borrowed liquidity.
claimableKETH function
Get the kETH claimable by the lender.
Input Parameters
lender: ETH address of the lender
Using claimableKETH function
Return Parameter
Returns the claimable kETH amount.
nodeOperatorPayoutRecipientUpdate function
This function can be called by the node operator to update the payout recipient as per ability to change it on the node.
Input Parameters
newPayoutRecipient: ETH address of the new payout recipient
Using nodeOperatorPayoutRecipientUpdate function
Return Parameter
Transaction details if the transaction was successful.
updateLenderPosition function
Updates the KETH amount pending to the lender, and their last recorded cumulative reward per share.
Input Parameters
lender: ETH address of the lender
Using updateLenderPosition function
Return Parameter
Transaction details if the transaction was successful.
updateNodeOperatorPosition function
Updates the KETH amount pending to the node operator, and their last recorded cumulative reward per share.
Input Parameters
nodeOerator: ETH address of the node operator
Using updateNodeOperatorPosition function
Return Parameter
Transaction details if the transaction was successful.
updateInterest function
Updates the current cumulative interest index before executing the function the function.
Using updateInterest function
Return Parameter
Transaction details if the transaction was successful.