Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: integrate addLiquidity and swap to sc #11179

Merged
merged 3 commits into from
Feb 10, 2025
Merged
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
209 changes: 0 additions & 209 deletions apps/ton/src/pages/testMint/index.tsx

This file was deleted.

62 changes: 2 additions & 60 deletions apps/ton/src/ton/logic/liquidity/useAddLiquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,70 +34,12 @@ export const useAddLiquidity = () => {
const routerJettonWallet0 = await getJettonWalletAddress(client, routerAddress, token0)
const routerJettonWallet1 = await getJettonWalletAddress(client, routerAddress, token1)

// const forwardPayload0 = beginCell()
// .storeUint(TON_OPCODES.ADD_LIQUIDITY, 32)
// .storeAddress(routerJettonWallet1)
// .storeCoins(toNano(900)) // MinLP
// .endCell()
// const payload0 = beginCell()
// .store(
// storeJettonTransferMessage({
// queryId: 1n,
// amount: amount0,
// destination: routerAddress,
// responseDestination: walletAddress,
// customPayload: null,
// forwardAmount: toNano('0.1'),
// forwardPayload: forwardPayload0,
// }),
// )
// .endCell()

// const forwardPayload1 = beginCell()
// .storeUint(TON_OPCODES.ADD_LIQUIDITY, 32)
// .storeAddress(routerJettonWallet0)
// .storeCoins(toNano(900)) // MinLP
// .endCell()
// const payload1 = beginCell()
// .store(
// storeJettonTransferMessage({
// queryId: 2n,
// amount: amount1,
// destination: routerAddress,
// responseDestination: walletAddress,
// customPayload: null,
// forwardAmount: toNano('0.1'),
// forwardPayload: forwardPayload1,
// }),
// )
// .endCell()

// const txRequest: SendTransactionRequest = {
// validUntil: Math.floor(Date.now() / 1000) + 60 * 2,
// messages: [
// {
// address: userJettonWallet0.toString(),
// amount: toNano('0.2').toString(),
// payload: payload0.toBoc().toString('base64'),
// },
// {
// address: userJettonWallet1.toString(),
// amount: toNano('0.2').toString(),
// payload: payload1.toBoc().toString('base64'),
// },
// ],
// }

// tonUI.sendTransaction(txRequest)

/// NEW WAY OF SENDING ADD LIQUIDITY TXN

const newForwardPayload0 = beginCell()
.store(
storeAddLiquidity({
queryId: 1n,
$$type: 'AddLiquidity',
minLPOut: 0n,
minLPOut: 1n,
tokenWallet: routerJettonWallet1,
}),
)
Expand All @@ -121,7 +63,7 @@ export const useAddLiquidity = () => {
storeAddLiquidity({
queryId: 2n,
$$type: 'AddLiquidity',
minLPOut: 0n,
minLPOut: 1n,
tokenWallet: routerJettonWallet0,
}),
)
Expand Down
1 change: 0 additions & 1 deletion apps/ton/src/ton/logic/swap/useSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export const useSwap = () => {
const routerAddress = parseAddress(Contracts[TonContractNames.PCSRouter].testnet.address)

const userJettonWallet0 = await getJettonWalletAddress(client, userAddress, token0)
const userJettonWallet1 = await getJettonWalletAddress(client, userAddress, token1)
const routerJettonWallet1 = await getJettonWalletAddress(client, routerAddress, token1)

const forwardPayload = beginCell()
Expand Down
8 changes: 4 additions & 4 deletions apps/ton/src/ton/wrappers/tact_Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4730,13 +4730,13 @@ function loadGetterTupleAddLiquidity(source: TupleReader) {
function storeTupleAddLiquidity(source: AddLiquidity) {
let builder = new TupleBuilder()
builder.writeNumber(source.queryId)
builder.writeNumber(source.newAmount0)
builder.writeNumber(source.newAmount1)
// builder.writeNumber(source.newAmount0)
// builder.writeNumber(source.newAmount1)
builder.writeNumber(source.minLPOut)
return builder.build()
}

function dictValueParserAddLiquidity(): DictionaryValue<AddLiquidity> {
/* function dictValueParserAddLiquidity(): DictionaryValue<AddLiquidity> {
return {
serialize: (src, builder) => {
builder.storeRef(beginCell().store(storeAddLiquidity(src)).endCell())
Expand All @@ -4745,7 +4745,7 @@ function dictValueParserAddLiquidity(): DictionaryValue<AddLiquidity> {
return loadAddLiquidity(src.loadRef().beginParse())
},
}
}
} */

export type LPAccountData = {
$$type: 'LPAccountData'
Expand Down
Loading