Skip to content

Commit

Permalink
Refactored code to separate files protocol wise (#180)
Browse files Browse the repository at this point in the history
Refactored code to separate files on a protocol folder basis and updated
agent code to be more maintainable..
This pull request was created for
https://app.gib.work/bounties/0b78790e-6d48-4ec3-b67f-46c96dac6b7d in an
attempt to solve a bounty #173 . Payment for the bounty is immediately
sent to the contributor after merge.
  • Loading branch information
thearyanag authored Jan 11, 2025
2 parents 677d174 + a6f9b05 commit dca508b
Show file tree
Hide file tree
Showing 206 changed files with 3,339 additions and 2,970 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { create_image } from "../tools/create_image";
import { create_image } from "../../tools/agent";

const createImageAction: Action = {
name: "CREATE_IMAGE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { SolanaAgentKit } from "..";
import { get_wallet_address } from "../tools";
import { Action } from "../types/action";
import { get_wallet_address } from "../../tools/agent";

const getWalletAddressAction: Action = {
name: "GET_WALLET_ADDRESS",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getAllDomainsTLDs } from "../tools";
import { getAllDomainsTLDs } from "../../tools";

const getAllDomainsTLDsAction: Action = {
name: "GET_ALL_TLDS",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getOwnedAllDomains } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getOwnedAllDomains } from "../../tools";

const getOwnedAllDomainsAction: Action = {
name: "GET_OWNED_ALL_DOMAINS",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getOwnedDomainsForTLD } from "../tools";
import { getOwnedDomainsForTLD } from "../../tools";

const getOwnedDomainsForTLDAction: Action = {
name: "GET_OWNED_DOMAINS_FOR_TLD",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { resolveAllDomains } from "../tools";
import { resolveAllDomains } from "../../tools";

const resolveDomainAction: Action = {
name: "RESOLVE_ALL_DOMAINS",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getTokenDataByTicker } from "../tools";
import { getTokenDataByTicker } from "../../tools/dexscreener";

const tokenDataByTickerAction: Action = {
name: "GET_TOKEN_DATA_BY_TICKER",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { flashCloseTrade } from "../tools";
import { flashCloseTrade } from "../../tools/flash";

const flashCloseTradeAction: Action = {
name: "FLASH_CLOSE_TRADE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { flashOpenTrade } from "../tools";
import { flashOpenTrade } from "../../tools/flash";

const flashOpenTradeAction: Action = {
name: "FLASH_OPEN_TRADE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { create_gibwork_task } from "../tools";
import { create_gibwork_task } from "../../tools/gibwork";

const createGibworkTaskAction: Action = {
name: "CREATE_GIBWORK_TASK",
Expand Down
64 changes: 32 additions & 32 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import deployTokenAction from "./deployToken";
import balanceAction from "./balance";
import transferAction from "./transfer";
import deployCollectionAction from "./deployCollection";
import mintNFTAction from "./mintNFT";
import tradeAction from "./trade";
import requestFundsAction from "./requestFunds";
import resolveDomainAction from "./resolveDomain";
import getTokenDataAction from "./getTokenData";
import getTPSAction from "./getTPS";
import fetchPriceAction from "./fetchPrice";
import stakeWithJupAction from "./stakeWithJup";
import stakeWithSolayerAction from "./stakeWithSolayer";
import registerDomainAction from "./registerDomain";
import lendAssetAction from "./lendAsset";
import createGibworkTaskAction from "./createGibworkTask";
import resolveSolDomainAction from "./resolveSolDomain";
import pythFetchPriceAction from "./pythFetchPrice";
import getOwnedDomainsForTLDAction from "./getOwnedDomainsForTLD";
import getPrimaryDomainAction from "./getPrimaryDomain";
import getAllDomainsTLDsAction from "./getAllDomainsTLDs";
import getOwnedAllDomainsAction from "./getOwnedAllDomains";
import createImageAction from "./createImage";
import getMainAllDomainsDomainAction from "./getMainAllDomainsDomain";
import getAllRegisteredAllDomainsAction from "./getAllRegisteredAllDomains";
import raydiumCreateCpmmAction from "./raydiumCreateCpmm";
import raydiumCreateAmmV4Action from "./raydiumCreateAmmV4";
import createOrcaSingleSidedWhirlpoolAction from "./createOrcaSingleSidedWhirlpool";
import launchPumpfunTokenAction from "./launchPumpfunToken";
import getWalletAddressAction from "./getWalletAddress";
import flashOpenTradeAction from "./flashOpenTrade";
import flashCloseTradeAction from "./flashCloseTrade";
import deployTokenAction from "./metaplex/deployToken";
import balanceAction from "./solana/balance";
import transferAction from "./solana/transfer";
import deployCollectionAction from "./metaplex/deployCollection";
import mintNFTAction from "./metaplex/mintNFT";
import tradeAction from "./jupiter/trade";
import requestFundsAction from "./solana/requestFunds";
import resolveDomainAction from "./sns/registerDomain";
import getTokenDataAction from "./jupiter/getTokenData";
import getTPSAction from "./solana/getTPS";
import fetchPriceAction from "./jupiter/fetchPrice";
import stakeWithJupAction from "./jupiter/stakeWithJup";
import stakeWithSolayerAction from "./solayer/stakeWithSolayer";
import registerDomainAction from "./sns/registerDomain";
import lendAssetAction from "./lulo/lendAsset";
import createGibworkTaskAction from "./gibwork/createGibworkTask";
import resolveSolDomainAction from "./sns/resolveSolDomain";
import pythFetchPriceAction from "./pyth/pythFetchPrice";
import getOwnedDomainsForTLDAction from "./alldomains/getOwnedDomainsForTLD";
import getPrimaryDomainAction from "./sns/getPrimaryDomain";
import getAllDomainsTLDsAction from "./alldomains/getAllDomainsTLDs";
import getOwnedAllDomainsAction from "./alldomains/getOwnedAllDomains";
import createImageAction from "./agent/createImage";
import getMainAllDomainsDomainAction from "./sns/getMainAllDomainsDomain";
import getAllRegisteredAllDomainsAction from "./sns/getAllRegisteredAllDomains";
import raydiumCreateCpmmAction from "./raydium/raydiumCreateCpmm";
import raydiumCreateAmmV4Action from "./raydium/raydiumCreateAmmV4";
import createOrcaSingleSidedWhirlpoolAction from "./orca/createOrcaSingleSidedWhirlpool";
import launchPumpfunTokenAction from "./pumpfun/launchPumpfunToken";
import getWalletAddressAction from "./agent/getWalletAddress";
import flashOpenTradeAction from "./flash/flashOpenTrade";
import flashCloseTradeAction from "./flash/flashCloseTrade";

export const ACTIONS = {
WALLET_ADDRESS_ACTION: getWalletAddressAction,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { fetchPrice } from "../tools";
import { fetchPrice } from "../../tools/jupiter";

const fetchPriceAction: Action = {
name: "FETCH_PRICE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { JupiterTokenData } from "../types";
import { getTokenAddressFromTicker, getTokenDataByAddress } from "../tools";
import { JupiterTokenData } from "../../types";
import { getTokenAddressFromTicker, getTokenDataByAddress } from "../../tools";

const getTokenDataAction: Action = {
name: "GET_TOKEN_DATA",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { stakeWithJup } from "../tools";
import { stakeWithJup } from "../../tools";

const stakeWithJupAction: Action = {
name: "STAKE_WITH_JUPITER",
Expand Down
6 changes: 3 additions & 3 deletions src/actions/trade.ts → src/actions/jupiter/trade.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { trade } from "../tools";
import { trade } from "../../tools";

const tradeAction: Action = {
name: "TRADE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { sendCompressedAirdrop } from "../tools";
import { sendCompressedAirdrop } from "../../tools";

const compressedAirdropAction: Action = {
name: "COMPRESSED_AIRDROP",
Expand Down
6 changes: 3 additions & 3 deletions src/actions/lendAsset.ts → src/actions/lulo/lendAsset.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { lendAsset } from "../tools";
import { lendAsset } from "../../tools/lulo";

const lendAssetAction: Action = {
name: "LEND_ASSET",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { deploy_collection } from "../tools";
import { deploy_collection } from "../../tools/metaplex";

interface CollectionOptions {
name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { deploy_token } from "../tools";
import { deploy_token } from "../../tools";

const deployTokenAction: Action = {
name: "DEPLOY_TOKEN",
Expand Down
6 changes: 3 additions & 3 deletions src/actions/mintNFT.ts → src/actions/metaplex/mintNFT.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { mintCollectionNFT } from "../tools";
import { mintCollectionNFT } from "../../tools/metaplex";

const mintNFTAction: Action = {
name: "MINT_NFT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { openbookCreateMarket } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { openbookCreateMarket } from "../../tools/openbook";

const createOpenbookMarketAction: Action = {
name: "CREATE_OPENBOOK_MARKET",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { Decimal } from "decimal.js";
import { orcaCreateSingleSidedLiquidityPool } from "../tools";
import { orcaCreateSingleSidedLiquidityPool } from "../../tools";

// Fee tiers mapping from the original tool
const FEE_TIERS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { launchPumpFunToken } from "../tools";
import { launchPumpFunToken } from "../../tools";

const launchPumpfunTokenAction: Action = {
name: "LAUNCH_PUMPFUN_TOKEN",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { fetchPythPrice, fetchPythPriceFeedID } from "../tools";
import { fetchPythPrice, fetchPythPriceFeedID } from "../../tools";

const pythFetchPriceAction: Action = {
name: "PYTH_FETCH_PRICE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { raydiumCreateAmmV4 } from "../tools";
import { raydiumCreateAmmV4 } from "../../tools";

const raydiumCreateAmmV4Action: Action = {
name: "RAYDIUM_CREATE_AMM_V4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { BN } from "@coral-xyz/anchor";
import Decimal from "decimal.js";
import { raydiumCreateClmm } from "../tools";
import { raydiumCreateClmm } from "../../tools";

const raydiumCreateClmmAction: Action = {
name: "RAYDIUM_CREATE_CLMM",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { raydiumCreateCpmm } from "../tools";
import { raydiumCreateCpmm } from "../../tools";

const raydiumCreateCpmmAction: Action = {
name: "RAYDIUM_CREATE_CPMM",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getAllRegisteredAllDomains } from "../tools";
import { getAllRegisteredAllDomains } from "../../tools";

const getAllRegisteredAllDomainsAction: Action = {
name: "GET_ALL_REGISTERED_ALL_DOMAINS",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getMainAllDomainsDomain } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getMainAllDomainsDomain } from "../../tools";

const getMainAllDomainsDomainAction: Action = {
name: "GET_MAIN_ALL_DOMAINS_DOMAIN",
Expand Down
Loading

0 comments on commit dca508b

Please sign in to comment.