|
| 1 | +# Suilend Protocol Integration |
| 2 | + |
| 3 | +This module provides integration with the Suilend lending protocol on Sui Network. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Lending Market Management |
| 8 | + - Create lending markets |
| 9 | + - Create and configure reserves |
| 10 | + - Update reserve configurations |
| 11 | + - Change reserve price feeds |
| 12 | +- Lending Operations |
| 13 | + - Borrow and send funds |
| 14 | + - Repay into obligation |
| 15 | + - Deposit into obligation |
| 16 | + - Withdraw and send to user |
| 17 | + - Deposit liquidity and get CTokens |
| 18 | + - Redeem CTokens and withdraw liquidity |
| 19 | +- Reward Management |
| 20 | + - Add rewards |
| 21 | + - Cancel rewards |
| 22 | + - Close rewards |
| 23 | + - Claim rewards and send to user |
| 24 | + - Claim rewards and deposit |
| 25 | +- Liquidation |
| 26 | + - Liquidate and redeem positions |
| 27 | +- Query Operations |
| 28 | + - Get lending market owner capability ID |
| 29 | + - Get obligation details |
| 30 | + |
| 31 | +## Tools |
| 32 | + |
| 33 | +### Lending Market Management |
| 34 | + |
| 35 | +#### `create_lending_market` |
| 36 | + |
| 37 | +Create a new lending market. |
| 38 | + |
| 39 | +Parameters: |
| 40 | + |
| 41 | +- `registry_id` (string, required): Registry ID |
| 42 | +- `lending_market_type` (string, required): Lending market type |
| 43 | + |
| 44 | +#### `create_reserve` |
| 45 | + |
| 46 | +Create a new reserve in a lending market. |
| 47 | + |
| 48 | +Parameters: |
| 49 | + |
| 50 | +- `lending_market_owner_cap_id` (string, required): Lending market owner capability ID |
| 51 | +- `pyth_price_id` (string, required): Pyth price feed ID |
| 52 | +- `coin_type` (string, required): Coin type |
| 53 | +- `config` (object, required): Reserve configuration |
| 54 | + |
| 55 | +### Lending Operations |
| 56 | + |
| 57 | +#### `borrow_and_send` |
| 58 | + |
| 59 | +Borrow and send funds to user. |
| 60 | + |
| 61 | +Parameters: |
| 62 | + |
| 63 | +- `owner_id` (string, required): Owner ID |
| 64 | +- `obligation_owner_cap_id` (string, required): Obligation owner capability ID |
| 65 | +- `obligation_id` (string, required): Obligation ID |
| 66 | +- `coin_type` (string, required): Coin type |
| 67 | +- `value` (string, required): Value to borrow |
| 68 | + |
| 69 | +## Usage Example |
| 70 | + |
| 71 | +```typescript |
| 72 | +// Initialize the protocol |
| 73 | +const client = await suilendClientWrapper(); |
| 74 | + |
| 75 | +// Create a lending market |
| 76 | +await tools.execute('create_lending_market', [ |
| 77 | + 'registry123', // registry_id |
| 78 | + 'type123', // lending_market_type |
| 79 | +]); |
| 80 | + |
| 81 | +// Borrow funds |
| 82 | +await tools.execute('borrow_and_send', [ |
| 83 | + 'owner123', // owner_id |
| 84 | + 'cap123', // obligation_owner_cap_id |
| 85 | + 'obligation123', // obligation_id |
| 86 | + 'sui', // coin_type |
| 87 | + '1000000', // value |
| 88 | +]); |
| 89 | +``` |
| 90 | + |
| 91 | +## Error Handling |
| 92 | + |
| 93 | +All tools return responses in a standardized format: |
| 94 | + |
| 95 | +```typescript |
| 96 | +{ |
| 97 | + reasoning: string; // Description of what happened |
| 98 | + response: string; // The actual response data |
| 99 | + status: string; // "success" or "failure" |
| 100 | + query: string; // The original query |
| 101 | + errors: string[]; // Array of error messages if any |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +## Dependencies |
| 106 | + |
| 107 | +- @suilend/sdk: Latest version |
| 108 | +- @mysten/sui: ^1.1.0 |
0 commit comments