chore: drift integration docs

This commit is contained in:
michaelessiet
2025-01-14 21:07:24 +01:00
parent 2f05af13cb
commit fd95ac8682

133
README.md
View File

@@ -338,6 +338,139 @@ const signature = await agent.createDriftVault({
### Deposit into a Drift Vault
Deposit tokens into a drift vault.
```typescript
const signature = await agent.depositIntoDriftVault(100, "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
```
### Deposit into your Drift account
Deposit tokens into your drift account.
```typescript
const {txSig} = await agent.depositToDriftUserAccount(100, "USDC")
```
### Derive a Drift Vault address
Derive a drift vault address.
```typescript
const vaultPublicKey = await agent.deriveDriftVaultAddress("my-drift-vault")
```
### Do you have a Drift account
Check if agent has a drift account.
```typescript
const {hasAccount, account} = await agent.doesUserHaveDriftAccount()
```
### Get Drift account information
Get drift account information.
```typescript
const accountInfo = await agent.driftUserAccountInfo()
```
### Request withdrawal from Drift vault
Request withdrawal from drift vault.
```typescript
const signature = await agent.requestWithdrawalFromDriftVault(100, "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
```
### Carry out a perpetual trade using a Drift vault
Open a perpertual trade using a drift vault that is delegated to you.
```typescript
const signature = await agent.tradeUsingDelegatedDriftVault({
vault: "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU",
amount: 500,
symbol: "SOL",
action: "long",
type: "limit",
price: 180 // Please long limit order at $180/SOL
})
```
### Carry out a perpetual trade using your Drift account
Open a perpertual trade using your drift account.
```typescript
const signature = await agent.tradeUsingDriftPerpAccount({
amount: 500,
symbol: "SOL",
action: "long",
type: "limit",
price: 180 // Please long limit order at $180/SOL
})
```
### Update Drift vault parameters
Update drift vault parameters.
```typescript
const signature = await agent.updateDriftVault({
name: "my-drift-vault",
marketName: "USDC-SPOT",
redeemPeriod: 1, // in days
maxTokens: 100000, // in token units e.g 100000 USDC
minDepositAmount: 5, // in token units e.g 5 USDC
managementFee: 1, // 1%
profitShare: 10, // 10%
hurdleRate: 5, // 5%
permissioned: false, // public vault or whitelist
})
```
### Withdraw from Drift account
Withdraw tokens from your drift account.
```typescript
const {txSig} = await agent.withdrawFromDriftAccount(100, "USDC")
```
### Borrow from Drift
Borrow tokens from drift.
```typescript
const {txSig} = await agent.withdrawFromDriftAccount(1, "SOL", true)
```
### Repay Drift loan
Repay a loan from drift.
```typescript
const {txSig} = await agent.depositToDriftUserAccount(1, "SOL", true)
```
### Withdraw from Drift vault
Withdraw tokens from a drift vault after the redemption period has elapsed.
```typescript
const signature = await agent.withdrawFromDriftVault( "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
```
### Update the address a Drift vault is delegated to
Update the address a drift vault is delegated to.
```typescript
const signature = await agent.updateDriftVaultDelegate("41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU", "new-address")
```
## Examples
### LangGraph Multi-Agent System