-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from clober-dex/test/vault-for-user
Test/Vault for user action
- Loading branch information
Showing
15 changed files
with
1,249 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
test.ts | ||
.graphclient/ | ||
docs | ||
|
||
|
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
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
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,48 @@ | ||
import { createWalletClient, http, parseUnits } from 'viem' | ||
import { arbitrumSepolia } from 'viem/chains' | ||
import { privateKeyToAccount } from 'viem/accounts' | ||
import * as dotenv from 'dotenv' | ||
import { getMarket, openMarket } from '@clober/v2-sdk' | ||
|
||
dotenv.config() | ||
|
||
const main = async () => { | ||
const walletClient = createWalletClient({ | ||
chain: arbitrumSepolia, | ||
account: privateKeyToAccount( | ||
(process.env.TESTNET_PRIVATE_KEY || '0x') as `0x${string}`, | ||
), | ||
transport: http(), | ||
}) | ||
|
||
const transaction1 = await openMarket({ | ||
chainId: arbitrumSepolia.id, | ||
inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0', | ||
outputToken: '0xF2e615A933825De4B39b497f6e6991418Fb31b78', | ||
}) | ||
const hash1 = await walletClient.sendTransaction({ | ||
...transaction1, | ||
gasPrice: parseUnits('1', 9), | ||
}) | ||
console.log(`open market hash: ${hash1}`) | ||
|
||
const transaction2 = await openMarket({ | ||
chainId: arbitrumSepolia.id, | ||
inputToken: '0xF2e615A933825De4B39b497f6e6991418Fb31b78', | ||
outputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0', | ||
}) | ||
const hash2 = await walletClient.sendTransaction({ | ||
...transaction2, | ||
gasPrice: parseUnits('1', 9), | ||
}) | ||
console.log(`open market hash: ${hash2}`) | ||
|
||
const market = await getMarket({ | ||
chainId: arbitrumSepolia.id, | ||
token0: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0', | ||
token1: '0xF2e615A933825De4B39b497f6e6991418Fb31b78', | ||
}) | ||
console.log(`market: `, market) | ||
} | ||
|
||
main() |
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,33 @@ | ||
import * as dotenv from 'dotenv' | ||
import { createWalletClient, http, parseUnits, zeroHash } from 'viem' | ||
import { arbitrumSepolia } from 'viem/chains' | ||
import { privateKeyToAccount } from 'viem/accounts' | ||
|
||
import { openPool } from '../../src' | ||
|
||
dotenv.config() | ||
|
||
const main = async () => { | ||
const walletClient = createWalletClient({ | ||
chain: arbitrumSepolia, | ||
account: privateKeyToAccount( | ||
(process.env.TESTNET_PRIVATE_KEY || '0x') as `0x${string}`, | ||
), | ||
transport: http(), | ||
}) | ||
|
||
const transaction = await openPool({ | ||
chainId: arbitrumSepolia.id, | ||
userAddress: '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49', | ||
tokenA: '0x00BFD44e79FB7f6dd5887A9426c8EF85A0CD23e0', | ||
tokenB: '0xF2e615A933825De4B39b497f6e6991418Fb31b78', | ||
salt: zeroHash, | ||
}) | ||
const hash = await walletClient.sendTransaction({ | ||
...transaction, | ||
gasPrice: parseUnits('1', 9), | ||
}) | ||
console.log(`open pool hash: ${hash}`) | ||
} | ||
|
||
main() |
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
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { zeroHash } from 'viem' | ||
|
||
export const emptyERC20PermitParams = { | ||
permitAmount: 0n, | ||
signature: { | ||
deadline: 0n, | ||
v: 0, | ||
r: '0x', | ||
s: '0x', | ||
r: zeroHash, | ||
s: zeroHash, | ||
}, | ||
} |
Oops, something went wrong.