Skip to content

Instantly share code, notes, and snippets.

@AntonIXO
Created August 22, 2024 11:26
Show Gist options
  • Save AntonIXO/0b6579f65d9f1c82f9f11722e920970a to your computer and use it in GitHub Desktop.
Save AntonIXO/0b6579f65d9f1c82f9f11722e920970a to your computer and use it in GitHub Desktop.
Provide LP to stop fi from func sc example
;; message with body
() send_simple_message(int amount, slice to, cell body, int mode) impure inline_ref {
cell msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(to)
.store_coins(amount)
.store_uint(1, 107)
.store_ref(body)
.end_cell();
send_raw_message(msg, mode);
}
;; Generates forward payload for router
(cell) provideLiquidityBody(slice router_wallet) impure inline_ref {
return begin_cell()
.store_uint(provide_lp, 32) ;; opcode
.store_slice(router_wallet) ;; router wallet
.store_coins(1) ;; forward amount
.end_cell();
}
;; Generates body for token transfer
;; Note that you should end function with custom payload, forward amount, and forward payload or 0 bits
(builder) create_simple_transfer_body(int query_id, int jetton_amount, slice to) impure inline_ref {
return begin_cell()
.store_uint(0xf8a7ea5, 32) ;; opcode
.store_uint(query_id, 64)
.store_coins(jetton_amount)
.store_slice(to) ;; to_owner_address
.store_slice(to);
}
() send_liquidity(slice destination, slice router_wallet, int jetton_amount, int ton_amount, int forward_amount, slice jetton_destination, int query_id) impure inline_ref {
cell provideLiquidityBody = provideLiquidityBody(router_wallet);
builder body = create_simple_transfer_body(query_id, jetton_amount, jetton_destination);
;; Sending to our wallet
send_simple_message(ton_amount, destination, body.store_uint(0, 1).store_coins(forward_amount).store_uint(1, 1).store_ref(provideLiquidityBody).end_cell(), 0);
}
@AntonIXO
Copy link
Author

AntonIXO commented Aug 22, 2024

const provide_lp = "provide_lp"c;
Opcode for router payload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment