Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,9 @@
[submodule "vendor/grammars/turtle.tmbundle"]
path = vendor/grammars/turtle.tmbundle
url = https://github.com/peta/turtle.tmbundle
[submodule "vendor/grammars/txtx-grammar"]
path = vendor/grammars/txtx-grammar
url = https://github.com/txtx/txtx-grammar.git
[submodule "vendor/grammars/typespec"]
path = vendor/grammars/typespec
url = https://github.com/microsoft/typespec.git
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,8 @@ vendor/grammars/toml.tmbundle:
vendor/grammars/turtle.tmbundle:
- source.sparql
- source.turtle
vendor/grammars/txtx-grammar:
- source.tx
vendor/grammars/typespec:
- source.tsp
vendor/grammars/typst-grammar:
Expand Down
10 changes: 10 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7909,6 +7909,16 @@ Twig:
codemirror_mode: twig
codemirror_mime_type: text/x-twig
language_id: 377
Txtx:
type: programming
color: "#00D992"
aliases:
- tx
extensions:
- ".tx"
tm_scope: source.tx
ace_mode: text
language_id: 871036660
Type Language:
type: data
aliases:
Expand Down
54 changes: 54 additions & 0 deletions samples/Txtx/bns-registration.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
addon "stacks" {
network_id = input.stacks_network_id
rpc_api_url = input.stacks_api_url
}

signer "alice" "stacks::web_wallet" {
expected_address = "ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC"
}

action "get_name_price" "stacks::call_readonly_fn" {
description = "Preorder name"
contract_id = "ST000000000000000000002AMW42H.bns"
function_name = "get-name-price"
function_args = [
stacks::cv_buff(encode_hex(variable.namespace)),
stacks::cv_buff(encode_hex(variable.name))
]
sender = "ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC"
}

action "send_name_preorder" "stacks::call_contract" {
description = "Send Preorder ${variable.name}.${variable.namespace} transaction"
contract_id = "ST000000000000000000002AMW42H.bns"
function_name = "name-preorder"
function_args = [
stacks::cv_buff(
ripemd160(sha256(
[
encode_hex("${variable.name}.${variable.namespace}"),
encode_hex(variable.salt)
]
))
),
stacks::cv_uint(action.get_name_price.value),
]
post_condition_mode = "allow"
signer = signer.alice
confirmations = 1
}

action "send_name_register" "stacks::call_contract" {
description = "Register name"
contract_id = "ST000000000000000000002AMW42H.bns"
function_name = "name-register"
function_args = [
stacks::cv_buff(encode_hex(variable.namespace)),
stacks::cv_buff(encode_hex(variable.name)),
stacks::cv_buff(encode_hex(variable.salt)),
stacks::cv_buff(encode_hex(variable.zonefile)),
]
signer = signer.alice
confirmations = 1
depends_on = [action.send_name_preorder]
}
35 changes: 35 additions & 0 deletions samples/Txtx/evm-deployment.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
addon "evm" {
chain_id = 11155111
rpc_api_url = "http://localhost:8545"
}

signer "alice" "evm::web_wallet" {
expected_address = "0xCe246168E59dd8e28e367BB49b38Dc621768F425"
}

variable "contract" {
value = evm::get_contract_from_foundry_project("SimpleStorage")
}

action "deploy_simple_storage" "evm::deploy_contract_create2" {
description = "Deploy SimpleStorage"
contract = evm::get_contract_from_foundry_project("SimpleStorage")
constructor_args = [14]
salt = "0x0000000000000000000000000000000000000000177317f7617d575e615800c7"
confirmations = 4
signer = signer.alice
expected_contract_address = "0x26eA4F95a9D93EB5B97b2cFE6D9D6Dee6DA09E9b"
}

action "call_simple_storage" "evm::call_contract" {
contract_abi = variable.contract.abi
contract_address = action.deploy_simple_storage.contract_address
function_name = "retrieve"
function_args = []
confirmations = 4
signer = signer.alice
}

output "contract_address" {
value = action.deploy_simple_storage.contract_address
}
15 changes: 15 additions & 0 deletions samples/Txtx/svm-program-deployment.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
################################################################
# Manage price-feed deployment through Crypto Infrastructure as Code
################################################################

addon "svm" {
rpc_api_url = input.rpc_api_url
network_id = input.network_id
}

action "deploy_price_feed" "svm::deploy_program" {
description = "Deploy price_feed program"
program = svm::get_program_from_anchor_project("price_feed")
authority = signer.authority
payer = signer.payer
}
69 changes: 69 additions & 0 deletions samples/Txtx/svm-pyth-arbitrage.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
addon "svm" {
rpc_api_url = input.rpc_api_url
network_id = input.network_id
}

variable "program" {
value = svm::get_program_from_anchor_project("hello_pyth")
}

variable "starting_pair" {
description = "BTC/USD"
value = "4cSM2e6rvbGQUFiJbqytoVMi5GgghSMr8LwVrT9VPSPo"
editable = true
}

variable "starting_pair_feed_id" {
description = "BTC/USD feed ID"
value = "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43"
editable = true
}

variable "bridging_pair" {
description = "ETH/BTC"
value = "5JwbqPPMNpzE2jVAdobWo6m5gkhsDhRdGBo3FYbSfmaK"
editable = true
}

variable "bridging_pair_feed_id" {
description = "ETH/BTC feed ID"
value = "0xc96458d393fe9deb7a7d63a0ac41e2898a67a7750dbd166673279e06c868df0a"
editable = true
}

variable "crossing_pair" {
description = "ETH/USD"
value = "42amVS4KgzR9rA28tkVYqVXjq9Qa8dcZQMbH5EYFX6XC"
editable = true
}

variable "crossing_pair_feed_id" {
description = "ETH/USD feed ID"
value = "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"
editable = true
}

action "call" "svm::process_instructions" {
signers = [signer.caller]
instruction {
program_idl = variable.program.idl
instruction_name = "update_triangular_arbitrage"
instruction_args = [
variable.starting_pair_feed_id,
variable.bridging_pair_feed_id,
variable.crossing_pair_feed_id,
]
sender {
public_key = signer.caller.public_key
}
starting_pair_account {
public_key = variable.starting_pair
}
bridging_pair_account {
public_key = variable.bridging_pair
}
crossing_pair_account {
public_key = variable.crossing_pair
}
}
}
163 changes: 163 additions & 0 deletions samples/Txtx/svm-swap-clmm.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
################################################################
# Swap on Raydium CLMM (v3) - Concentrated Liquidity
#
# This runbook executes a swap on a Raydium CLMM pool.
# CLMM uses concentrated liquidity similar to Uniswap v3.
################################################################

addon "svm" {
rpc_api_url = input.rpc_api_url
network_id = input.network_id
}

signer "user" "svm::secret_key" {
description = "The account executing the swap"
keypair_json = "~/.config/solana/id.json"
}

variable "program" {
description = "The raydium_arbitrage program"
value = svm::get_program_from_anchor_project("raydium_arbitrage")
}

# Token configuration
variable "input_mint" {
description = "Input token mint address"
editable = true
}

variable "output_mint" {
description = "Output token mint address"
editable = true
}

# CLMM Pool configuration
variable "pool_state" {
description = "CLMM pool state account"
editable = true
}

variable "amm_config" {
description = "CLMM AMM config account"
editable = true
}

variable "input_vault" {
description = "CLMM input token vault"
editable = true
}

variable "output_vault" {
description = "CLMM output token vault"
editable = true
}

variable "observation_state" {
description = "CLMM oracle observation state"
editable = true
}

# Swap parameters
variable "amount" {
description = "Amount to swap (in smallest units)"
value = 1000000000
editable = true
}

variable "other_amount_threshold" {
description = "Minimum output or maximum input (depending on is_base_input)"
value = 0
editable = true
}

variable "sqrt_price_limit_x64" {
description = "Price limit for the swap (0 for no limit)"
value = 0
editable = true
}

variable "is_base_input" {
description = "True for exact input swap, false for exact output"
value = true
editable = true
}

# Programs
variable "token_program" {
value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}

variable "token_program_2022" {
value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
}

variable "memo_program" {
value = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
}

variable "clmm_program" {
value = "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"
}

action "swap_clmm" "svm::process_instructions" {
description = "Execute CLMM swap"
signers = [signer.user]

instruction {
program_idl = variable.program.idl
instruction_name = "swap_clmm"
instruction_args = [
variable.amount,
variable.other_amount_threshold,
variable.sqrt_price_limit_x64,
variable.is_base_input
]

payer {
public_key = signer.user.public_key
}
amm_config {
public_key = variable.amm_config
}
pool_state {
public_key = variable.pool_state
}
input_token_account {
public_key = svm::get_associated_token_address(signer.user.public_key, variable.input_mint)
}
output_token_account {
public_key = svm::get_associated_token_address(signer.user.public_key, variable.output_mint)
}
input_vault {
public_key = variable.input_vault
}
output_vault {
public_key = variable.output_vault
}
observation_state {
public_key = variable.observation_state
}
token_program {
public_key = variable.token_program
}
token_program_2022 {
public_key = variable.token_program_2022
}
memo_program {
public_key = variable.memo_program
}
input_vault_mint {
public_key = variable.input_mint
}
output_vault_mint {
public_key = variable.output_mint
}
clmm_program {
public_key = variable.clmm_program
}
}
}

output "signature" {
value = action.swap_clmm.signature
}
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Turing:** [Alhadis/language-turing](https://github.com/Alhadis/language-turing)
- **Turtle:** [peta/turtle.tmbundle](https://github.com/peta/turtle.tmbundle)
- **Twig:** [Anomareh/PHP-Twig.tmbundle](https://github.com/Anomareh/PHP-Twig.tmbundle)
- **Txtx:** [txtx/txtx-grammar](https://github.com/txtx/txtx-grammar)
- **Type Language:** [goodmind/language-typelanguage](https://github.com/goodmind/language-typelanguage)
- **TypeScript:** [tree-sitter/tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript) 🐌
- **TypeSpec:** [microsoft/typespec](https://github.com/microsoft/typespec)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/txtx-grammar
Submodule txtx-grammar added at 712048
Loading