Skip to content

Commit f03e3b4

Browse files
committed
update abi
1 parent 5f502fa commit f03e3b4

File tree

3 files changed

+66
-38
lines changed

3 files changed

+66
-38
lines changed

typescript/aqua/src/abi/Aqua.abi.ts

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
export const AQUA_ABI = [
2-
{
3-
type: 'function',
4-
name: 'balances',
5-
inputs: [
6-
{ name: 'maker', type: 'address', internalType: 'address' },
7-
{ name: 'app', type: 'address', internalType: 'address' },
8-
{ name: 'strategyHash', type: 'bytes32', internalType: 'bytes32' },
9-
{ name: 'token', type: 'address', internalType: 'address' },
10-
],
11-
outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
12-
stateMutability: 'view',
13-
},
142
{
153
type: 'function',
164
name: 'dock',
@@ -48,6 +36,37 @@ export const AQUA_ABI = [
4836
outputs: [],
4937
stateMutability: 'nonpayable',
5038
},
39+
{
40+
type: 'function',
41+
name: 'rawBalances',
42+
inputs: [
43+
{ name: 'maker', type: 'address', internalType: 'address' },
44+
{ name: 'app', type: 'address', internalType: 'address' },
45+
{ name: 'strategyHash', type: 'bytes32', internalType: 'bytes32' },
46+
{ name: 'token', type: 'address', internalType: 'address' },
47+
],
48+
outputs: [
49+
{ name: 'balance', type: 'uint248', internalType: 'uint248' },
50+
{ name: 'tokensCount', type: 'uint8', internalType: 'uint8' },
51+
],
52+
stateMutability: 'view',
53+
},
54+
{
55+
type: 'function',
56+
name: 'safeBalances',
57+
inputs: [
58+
{ name: 'maker', type: 'address', internalType: 'address' },
59+
{ name: 'app', type: 'address', internalType: 'address' },
60+
{ name: 'strategyHash', type: 'bytes32', internalType: 'bytes32' },
61+
{ name: 'token0', type: 'address', internalType: 'address' },
62+
{ name: 'token1', type: 'address', internalType: 'address' },
63+
],
64+
outputs: [
65+
{ name: 'balance0', type: 'uint256', internalType: 'uint256' },
66+
{ name: 'balance1', type: 'uint256', internalType: 'uint256' },
67+
],
68+
stateMutability: 'view',
69+
},
5170
{
5271
type: 'function',
5372
name: 'ship',
@@ -131,6 +150,16 @@ export const AQUA_ABI = [
131150
{ name: 'token', type: 'address', internalType: 'address' },
132151
],
133152
},
153+
{
154+
type: 'error',
155+
name: 'SafeBalancesForTokenNotInActiveStrategy',
156+
inputs: [
157+
{ name: 'maker', type: 'address', internalType: 'address' },
158+
{ name: 'app', type: 'address', internalType: 'address' },
159+
{ name: 'strategyHash', type: 'bytes32', internalType: 'bytes32' },
160+
{ name: 'token', type: 'address', internalType: 'address' },
161+
],
162+
},
134163
{
135164
type: 'error',
136165
name: 'SafeCastOverflowedUintDowncast',

typescript/aqua/tests/aqua.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ describe('Aqua', () => {
2121
strategyHash: Hex,
2222
token: Address | Hex,
2323
): Promise<bigint> => {
24-
return forkNode.provider.readContract({
24+
const [balance] = await forkNode.provider.readContract({
2525
address: forkNode.addresses.aqua,
2626
abi: AQUA_ABI,
27-
functionName: 'balances',
27+
functionName: 'rawBalances',
2828
args: [maker.toString() as Hex, app.toString() as Hex, strategyHash, token.toString() as Hex],
2929
})
30+
31+
return balance
3032
}
3133

3234
beforeAll(async () => {

typescript/swap-vm/tests/swap-vm.spec.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Address, HexString } from '@1inch/sdk-core'
55
import { ADDRESSES } from '@1inch/sdk-core/test-utils'
66
import type { Hex } from 'viem'
77
import { decodeFunctionResult, parseUnits } from 'viem'
8-
import { ABI, AquaProtocolContract } from '@1inch/aqua-sdk'
8+
import { AquaProtocolContract, ABI } from '@1inch/aqua-sdk'
99
import { ReadyEvmFork } from './setup-evm.js'
1010
import { Order } from '../src/swap-vm/order.js'
1111
import { MakerTraits } from '../src/swap-vm/maker-traits.js'
@@ -32,12 +32,14 @@ describe('SwapVM', () => {
3232
strategyHash: Hex,
3333
token: Address | Hex,
3434
): Promise<bigint> => {
35-
return forkNode.provider.readContract({
35+
const [balance] = await forkNode.provider.readContract({
3636
address: forkNode.addresses.aqua,
3737
abi: ABI.AQUA_ABI,
38-
functionName: 'balances',
38+
functionName: 'rawBalances',
3939
args: [maker.toString() as Hex, app.toString() as Hex, strategyHash, token.toString() as Hex],
4040
})
41+
42+
return balance
4143
}
4244

4345
beforeAll(async () => {
@@ -66,14 +68,8 @@ describe('SwapVM', () => {
6668
const hashFromContract = await forkNode.provider.readContract({
6769
address: forkNode.addresses.swapVMAquaRouter,
6870
abi: SWAP_VM_ABI,
69-
functionName: 'hashOrder',
70-
args: [
71-
{
72-
maker: order.maker.toString(),
73-
program: order.program.toString(),
74-
traits: order.traits.asBigInt(),
75-
},
76-
],
71+
functionName: 'hash',
72+
args: [order.build()],
7773
})
7874

7975
expect(calculatedHash.toString()).toEqual(hashFromContract)
@@ -269,21 +265,22 @@ describe('SwapVM', () => {
269265
}
270266

271267
// Simulate the call to get the dstAmount
272-
const simulateResult = await forkNode.provider.call({
273-
account: swapperAddress,
274-
...swapVM.quote(swapParams),
275-
})
276-
277-
const [_, dstAmount] = decodeFunctionResult({
278-
abi: SWAP_VM_ABI,
279-
functionName: 'quote',
280-
data: simulateResult.data!,
281-
})
282-
268+
// const simulateResult = await forkNode.provider.call({
269+
// account: swapperAddress,
270+
// ...swapVM.quote(swapParams),
271+
// })
272+
273+
// const [_, dstAmount] = decodeFunctionResult({
274+
// abi: SWAP_VM_ABI,
275+
// functionName: 'quote',
276+
// data: simulateResult.data!,
277+
// })
278+
279+
const dstAmount = 1000n
283280
const swap = swapVM.swap(swapParams)
284281

285-
const { txHash: _swapTx } = await swapper.send({ ...swap, allowFail: false })
286-
// await forkNode.printTrace(swapTx)
282+
const { txHash: swapTx } = await swapper.send({ ...swap, allowFail: true })
283+
await forkNode.printTrace(swapTx)
287284

288285
const providerWethBalanceAfter = await getAquaBalance(
289286
liqProviderAddress,

0 commit comments

Comments
 (0)