Request & Response Types
Request Types
Request
An enum representing the 10 possible operations in a batch request.
rust
pub enum Request {
Deposit(StandardRequest),
Borrow(StandardRequest),
Withdraw(StandardRequest),
Repay(StandardRequest),
AddCollateral(StandardRequest),
RemoveCollateral(StandardRequest),
FlashBorrow(StandardRequest),
SwapExactTokens(SwapExactTokensRequest),
SwapForExactTokens(SwapForExactTokensRequest),
Liquidate(LiquidateRequest),
}typescript
// The TypeScript SDK flattens the Rust tagged enum into a struct
// with a numeric request_type discriminator:
export interface Request {
amount: i128;
pool_address: string;
request_type: u32;
}
export enum RequestType {
Deposit = 0,
Borrow = 1,
Withdraw = 2,
Repay = 3,
AddCollateral = 4,
RemoveCollateral = 5,
}
// FlashBorrow, SwapExactTokens, SwapForExactTokens, and Liquidate
// are not available as RequestType variants — use dedicated methods
// or submit_requests_batch with the Rust-level Request encoding.StandardRequest
Used for deposit, borrow, withdraw, repay, add/remove collateral, and flash borrow.
rust
pub struct StandardRequest {
pub amount: i128,
pub pool_address: Address,
}typescript
// In the TypeScript SDK, StandardRequest fields are inlined
// into the Request interface:
export interface Request {
amount: i128;
pool_address: string;
request_type: u32; // RequestType enum value
}SwapExactTokensRequest
Swap a precise amount of input tokens for at least a minimum output.
rust
pub struct SwapExactTokensRequest {
pub swap_provider: Address,
pub token_in: Address,
pub token_out: Address,
pub amount_in: i128,
pub min_amount_out: i128,
}typescript
// This type is not directly exposed in the TypeScript SDK.
// Swap requests are constructed at the Rust level within
// submit_requests_batch using the raw Request encoding.SwapForExactTokensRequest
Swap up to a maximum input for a precise output amount.
rust
pub struct SwapForExactTokensRequest {
pub swap_provider: Address,
pub token_in: Address,
pub token_out: Address,
pub max_amount_in: i128,
pub amount_out: i128,
}typescript
// This type is not directly exposed in the TypeScript SDK.
// Swap requests are constructed at the Rust level within
// submit_requests_batch using the raw Request encoding.LiquidateRequest
Liquidate another user's position within a batch.
rust
pub struct LiquidateRequest {
pub borrower_obligation_key: ObligationKey,
pub borrow_pool_address: Address,
pub collateral_pool_address: Address,
pub repay_amount: i128,
pub min_demanded_collateral_amount: i128,
}typescript
// This type is not directly exposed in the TypeScript SDK.
// Use the standalone liquidate method on the Client instead:
liquidate: (
{liquidator, borrower, borrower_obligation_seed,
borrow_pool_address, collateral_pool_address,
repay_amount, min_demanded_collateral_amount}: {
liquidator: string,
borrower: string,
borrower_obligation_seed: Option<Buffer>,
borrow_pool_address: string,
collateral_pool_address: string,
repay_amount: i128,
min_demanded_collateral_amount: i128,
},
options?: MethodOptions
) => Promise<AssembledTransaction<Result<void>>>