https://github.com/Bucket-Protocol/bucket-protocol-sdk
Bucket Protocol TypeScript SDK
https://github.com/Bucket-Protocol/bucket-protocol-sdk
blockchain bucket-protocol sdk sui
Last synced: 5 months ago
JSON representation
Bucket Protocol TypeScript SDK
- Host: GitHub
- URL: https://github.com/Bucket-Protocol/bucket-protocol-sdk
- Owner: Bucket-Protocol
- License: apache-2.0
- Created: 2023-08-12T16:04:17.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T05:32:22.000Z (11 months ago)
- Last Synced: 2024-11-14T06:27:51.678Z (11 months ago)
- Topics: blockchain, bucket-protocol, sdk, sui
- Language: TypeScript
- Homepage: https://docs.bucketprotocol.io/
- Size: 1.11 MB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-sui - Bucket Protocol SDK - The TypeScript SDK for interacting with Bucket Protocol. (Client SDKs & Libraries / DeFi SDKs)
- awesome-sui - Bucket Protocol SDK - The TypeScript SDK for interacting with Bucket Protocol. (Client SDKs & Libraries / DeFi SDKs)
README
# Bucket Protocol TypeScript SDK
Bucket Protocol aims to be a DeFi Engine on Sui network. It allow users to draw 0% interest loans against $SUI $BTC $ETH and LST used as collateral.
Loans are paid out in $BUCK - a USD pegged stablecoin backed by multiple types of crypto, and need to maintain a minimum collateral ratio of 110%.
In addition to the collateral, the loans are secured by TANK containing $BUCK and by fellow borrowers collectively acting as guarantors of last resort.
## Install Bucket Protocol
Install Bucket Protocol using npm : `npm i bucket-protocol-sdk`
Install Bucket Protocol using npm and git : `npm install https://github.com/Bucket-Protocol/bucket-protocol-sdk.git`
## Quick start
Choose a package ID based `mainnet` or `testnet` by replacing `packageType` value. By default package ID is set to `mainnet`.
```ts
import { BucketClient } from 'bucket-protocol-sdk';// Instantiate BucketClient
const buck = new BucketClient();// Or create with rpc url
const buck = new BucketClient('https://sui-mainnet-endpoint.blockvision.org/');
```## Become a stable swap and start earning rebates by integrating psmIn
```ts
// Build psmIn transaction
const tx = new Transaction();const coinOut = await buck.psmSwapIn(
tx,
'0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', // e.g USDC coin type
usdcInput, // usdc coin object
'0xdummy...', // referrer address
);
```## Query Bucket Protocol
```ts
// Return overall information
await buck.getProtocol();// Return all available bottles
await buck.getAllBottes();// Return all destroyed bottles
await buck.getDestroyedBottles();// Return all tanks
await buck.getAllTanks();// Return all psms
await buck.getAllPsms();// Return all fountains
await buck.getAllFountains();// Return all strap fountains
await buck.getAllStrapFountains();
```## Query User state
```ts
// Return user tanks with address
await buck.getUserTanks(`0xdummy.....`);// Return user bottles with address
await buck.getUserBottles(`0xdummy.....`);// Return user positions with address
await buck.getUserLpProofs(`0xdummy.....`);
```## Get borrow transaction
```ts
const tx = new Transaction();tx = await buck.getBorrowTx(
tx,
`0x2::sui::SUI`, // collateral coin type
1_000_000_000, // collateral amount in raw
1_000_000_000, // borrow amount in raw
`0xdummy...`, // recipient address
true, // isUpdateOracle
`0xdummy...`, // you can fetch with findInsertionPlace function
strapId, // bottle's strapId
);
```