-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into langchain-tool-ci
- Loading branch information
Showing
11 changed files
with
486 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { z } from "zod"; | ||
import type { Action } from "../../types"; | ||
import { orcaClosePosition } from "../../tools"; | ||
import { PublicKey } from "@solana/web3.js"; | ||
|
||
const closeOrcaPositionAction: Action = { | ||
name: "CLOSE_ORCA_POSITION_ACTION", | ||
similes: [ | ||
"close orca liquidity position", | ||
"close orca whirlpool position", | ||
"close orca liquidity pool", | ||
"close my orca liquidity position", | ||
], | ||
description: | ||
"Close an existing liquidity position in an Orca Whirlpool. This functions fetches the position details using the provided mint address and closes the position with a 1% slippage", | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
positionMintAddress: "EPjasdf...", | ||
}, | ||
output: { | ||
status: "success", | ||
signature: "12Erx...", | ||
message: "Successfully closed Orca whirlpool position", | ||
}, | ||
explanation: "Close a USDC/SOL whirlpool position", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
positionMintAddress: z | ||
.string() | ||
.describe("The mint address of the liquidity position to close"), | ||
}), | ||
handler: async (agent, input) => { | ||
try { | ||
const signature = await orcaClosePosition( | ||
agent, | ||
new PublicKey(input.positionMintAddress), | ||
); | ||
|
||
return { | ||
status: "success", | ||
signature, | ||
message: "Successfully closed Orca whirlpool position", | ||
}; | ||
} catch (e) { | ||
return { | ||
status: "error", | ||
// @ts-expect-error - TS doesn't know that `e` has a `message` property | ||
message: `Failed to close Orca whirlpool position: ${e.message}`, | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
export default closeOrcaPositionAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { z } from "zod"; | ||
import type { Action } from "../../types"; | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { orcaCreateCLMM } from "../../tools"; | ||
import Decimal from "decimal.js"; | ||
|
||
const createOrcaCLMMAction: Action = { | ||
name: "CREATE_ORCA_CLMM_ACTION", | ||
description: | ||
"Create a Concentrated Liquidity Market Maker (CLMM) pool on Orca, the most efficient and capital-optimized CLMM on Solana. This function initializes a CLMM pool but does not add liquidity. You can add liquidity later using a centered position or a single-sided position.", | ||
similes: [ | ||
"create orca clmm", | ||
"create orca concentrated pool", | ||
"create orca clmm pool", | ||
"create orca concentrated liquidity", | ||
], | ||
examples: [ | ||
[ | ||
{ | ||
input: { | ||
mintDeploy: "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN", | ||
mintPair: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", | ||
initialPrice: 1.1, | ||
feeTier: 1, | ||
}, | ||
output: { | ||
status: "success", | ||
message: | ||
"CLMM pool created successfully. Note: No liquidity was added.", | ||
}, | ||
explanation: "Create a CLMM pool with USDC and JUP", | ||
}, | ||
], | ||
], | ||
schema: z.object({ | ||
mintDeploy: z | ||
.string() | ||
.describe("The mint address of the token you want to deploy"), | ||
mintPair: z | ||
.string() | ||
.describe( | ||
"The mint address of the token you want to pair the deployed mint with", | ||
), | ||
initialPrice: z | ||
.number() | ||
.positive() | ||
.describe("Initial price of mintDeploy in terms of mintPair"), | ||
feeTier: z | ||
.number() | ||
.positive() | ||
.min(1) | ||
.describe( | ||
"The fee tier in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200", | ||
), | ||
}), | ||
handler: async (agent, input) => { | ||
try { | ||
const [mintDeploy, mintPair, initialPrice, feeTier] = [ | ||
new PublicKey(input.mintDeploy), | ||
new PublicKey(input.mintPair), | ||
new Decimal(input.initialPrice), | ||
input.feeTier, | ||
]; | ||
|
||
const signature = await orcaCreateCLMM( | ||
agent, | ||
mintDeploy, | ||
mintPair, | ||
initialPrice, | ||
feeTier, | ||
); | ||
|
||
return { | ||
status: "success", | ||
message: | ||
"CLMM pool created successfully. Note: No liquidity was added.", | ||
signature, | ||
}; | ||
} catch (e) { | ||
return { | ||
status: "error", | ||
// @ts-expect-error - TS doesn't know that `e` has a `message` property | ||
message: `Failed to create Orca CLMM pool: ${e.message}`, | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
export default createOrcaCLMMAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { z } from "zod"; | ||
import type { Action } from "../../types"; | ||
import { orcaFetchPositions } from "../../tools"; | ||
|
||
const fetchOrcaPositionsAction: Action = { | ||
name: "FETCH_ORCA_POSITIONS_ACTION", | ||
description: | ||
"Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with position mint addresses as keys and position status details as values.", | ||
similes: [ | ||
"fetch orca liquidity positions", | ||
"fetch orca whirlpool positions", | ||
"fetch orca liquidity pools", | ||
"fetch my orca liquidity positions", | ||
], | ||
examples: [ | ||
[ | ||
{ | ||
input: {}, | ||
output: { | ||
status: "success", | ||
message: "Liquidity positions fetched.", | ||
positions: { | ||
positionMintAddress1: { | ||
whirlpoolAddress: "whirlpoolAddress1", | ||
positionInRange: true, | ||
distanceFromCenterBps: 250, | ||
}, | ||
}, | ||
}, | ||
explanation: "Fetch all Orca whirlpool positions", | ||
}, | ||
], | ||
], | ||
schema: z.object({}), | ||
handler: async (agent) => { | ||
try { | ||
const positions = JSON.parse(await orcaFetchPositions(agent)); | ||
|
||
return { | ||
status: "success", | ||
message: "Liquidity positions fetched.", | ||
positions, | ||
}; | ||
} catch (e) { | ||
return { | ||
status: "error", | ||
// @ts-expect-error - TS doesn't know that `e` has a `message` property | ||
message: `Failed to fetch Orca whirlpool positions: ${e.message}`, | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
export default fetchOrcaPositionsAction; |
Oops, something went wrong.