Skip to content

Commit

Permalink
Merge branch 'main' into quangkeu95/main
Browse files Browse the repository at this point in the history
  • Loading branch information
thearyanag committed Jan 17, 2025
2 parents 15172ee + 68cb11b commit 89aed54
Show file tree
Hide file tree
Showing 130 changed files with 13,512 additions and 4,512 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ SOLANA_PRIVATE_KEY=
JUPITER_REFERRAL_ACCOUNT=
JUPITER_FEE_BPS=
FLASH_PRIVILEGE= referral | nft | none
HELIUS_API_KEY=
FLEXLEND_API_KEY=
HELIUS_API_KEY=
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"no-constant-condition": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"no-console": ["warn", { "allow": ["warn", "error"] }],
"curly": ["error", "all"],
Expand All @@ -30,4 +31,4 @@
"ecmaVersion": 2020,
"sourceType": "module"
}
}
}
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ jobs:
with:
version: 9.4.0

- name: Install node-gyp prerequisites
run: sudo apt update && sudo apt install -y build-essential python3 pkg-config libudev-dev libusb-1.0-0-dev

- uses: actions/setup-node@v4
with:
node-version: "23"
cache: "pnpm"

- name: Install dependencies
run: pnpm install -r --no-frozen-lockfile

- name: Run lint and fix
run: pnpm run lint:fix

Expand Down
221 changes: 205 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Anyone - whether an SF-based AI researcher or a crypto-native builder - can brin
- Pyth Price feeds for fetching Asset Prices
- Register/resolve Alldomains
- Perpetuals Trading with Adrena Protocol
- Drift Vaults, Perps, Lending and Borrowing

- **Solana Blinks**
- Lending by Lulo (Best APR for USDC)
Expand Down Expand Up @@ -133,10 +134,7 @@ console.log("Token Mint Address:", result.mint.toString());
```
### Create NFT Collection on 3Land
```typescript
const optionsWithBase58: StoreInitOptions = {
privateKey: "",
isMainnet: true, // if false, collection will be created on devnet 3.land (dev.3.land)
};
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet

const collectionOpts: CreateCollectionOptions = {
collectionName: "",
Expand All @@ -146,18 +144,16 @@ const optionsWithBase58: StoreInitOptions = {
};

const result = await agent.create3LandCollection(
optionsWithBase58,
collectionOpts
collectionOpts,
isDevnet, // (Optional) if not present TX takes place in Mainnet
);
```

### Create NFT on 3Land
When creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website
```typescript
const optionsWithBase58: StoreInitOptions = {
privateKey: "",
isMainnet: true, // if false, listing will be on devnet 3.land (dev.3.land)
};
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
const withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool for a specific SPL token
const collectionAccount = ""; //hash for the collection
const createItemOptions: CreateSingleOptions = {
itemName: "",
Expand All @@ -169,15 +165,15 @@ const createItemOptions: CreateSingleOptions = {
{ trait_type: "", value: "" },
],
price: 0, //100000000 == 0.1 sol, can be set to 0 for a free mint
splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL, must be present if "withPool" is true
poolName: "", // Only present if "withPool" is true
mainImageUrl: "",
splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL
};
const isMainnet = true;
const result = await agent.create3LandNft(
optionsWithBase58,
collectionAccount,
createItemOptions,
isMainnet
isDevnet, // (Optional) if not present TX takes place in Mainnet
withPool
);

```
Expand Down Expand Up @@ -309,6 +305,199 @@ const signature = await agent.closePerpTradeLong({
const { signature } = await agent.closeEmptyTokenAccounts();
```

### Create a Drift account

Create a drift account with an initial token deposit.

```typescript
const result = await agent.createDriftUserAccount()
```

### Create a Drift Vault

Create a drift vault.

```typescript
const signature = await agent.createDriftVault({
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
})
```

### 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")
```

### Get Voltr Vault Position Values

Get the current position values and total value of assets in a Voltr vault.

```typescript
const values = await agent.voltrGetPositionValues("7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K")
```

### Deposit into Voltr Strategy

Deposit assets into a specific strategy within a Voltr vault.

```typescript
const signature = await agent.voltrDepositStrategy(
new BN("1000000000"), // amount in base units (e.g., 1 USDC = 1000000)
"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K", // vault
"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk" // strategy
)
```

### Withdraw from Voltr Strategy

Withdraw assets from a specific strategy within a Voltr vault.

```typescript
const signature = await agent.voltrWithdrawStrategy(
new BN("1000000000"), // amount in base units (e.g., 1 USDC = 1000000)
"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K", // vault
"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk" // strategy
)
```

## Examples

### LangGraph Multi-Agent System
Expand Down Expand Up @@ -357,12 +546,12 @@ Refer to [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on how to co

Apache-2 License

## Funding
## Funding

If you wanna give back any tokens or donations to the OSS community -- The Public Solana Agent Kit Treasury Address:

Solana Network : EKHTbXpsm6YDgJzMkFxNU1LNXeWcUW7Ezf8mjUNQQ4Pa

## Security

This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.
This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.
2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 89aed54

Please sign in to comment.