-
Notifications
You must be signed in to change notification settings - Fork 36
/
withdraw-liquidity-anc.ts
40 lines (36 loc) · 1.13 KB
/
withdraw-liquidity-anc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Dec, Int, MsgExecuteContract } from '@terra-money/terra.js';
import { validateInput } from '../../utils/validate-input';
import { validateAddress } from '../../utils/validation/address';
import {
validateIsGreaterThanZero,
validateIsNumber,
} from '../../utils/validation/number';
import { createHookMsg } from '../../utils/cw20/create-hook-msg';
import { AddressProvider } from '../../address-provider/provider';
interface Option {
address: string;
amount: string;
}
export const fabricateTerraswapWithdrawLiquidityANC = ({
address,
amount,
}: Option) => (addressProvider: AddressProvider): MsgExecuteContract[] => {
validateInput([
validateAddress(address),
validateIsNumber(amount),
validateIsGreaterThanZero(amount),
]);
const lpToken = addressProvider.terraswapAncUstLPToken();
const pairAddress = addressProvider.terraswapAncUstPair();
return [
new MsgExecuteContract(address, lpToken, {
send: {
contract: pairAddress,
amount: new Int(new Dec(amount).mul(1000000)).toString(),
msg: createHookMsg({
withdraw_liquidity: {},
}),
},
}),
];
};