0.0.2 • Published 8 months ago
athenafi-ts-client v0.0.2
AthenaFi TypeScript Client
Overview
Client provides high level functions to interact with AthenaFi Smart Contracts and use Safe Smart Account.
Usage in development
Use of npm link
is adviced until Client is deployed to remote registry.
- Get into root of AthenaFi Client project.
- Run
npm run build
- Run
npm link
. - Get into root of the project you want import AthenaFi Client to.
- Run
npm link athenafi-ts-client
. - You can now import and use AthenaFi Client tools using standard import syntax, e.g.
import { deploySafe, executeSafeTransaction } from "athenafi-ts-client";
Creating Action payload
- Instantiate Action object with right arguments
import { FluidSupplyAction } from 'athenafi-ts-client';
// ...
const fluidSupplyAction = new FluidSupplyAction(
'TOKEN_ADDRESS',
'1000000000',
'FROM_ADDRESS',
'TO_ADDRESS'
);
- Run
encodeArgs()
on the action object to get a string payload
const fluidSupplyPayload = fluidSupplyAction.encodeArgs();
- Now you can use returned payload to execute safe transaction
import { executeSafeTransaction, SafeOperation } from 'athenafi-ts-client';
const txResponse = await executeSafeTransaction(
safeAddress,
actionContractAddress,
0,
fluidSupplyPayload,
SafeOperation.DelegateCall,
signer
);
Creating Sequence payload
- Instantiate action objects
const fluidSupply = new FluidSupplyAction(
'TOKEN_ADDRESS',
'100000000',
'FROM_ADDRESS',
'TO_ADDRESS'
);
const yearnSupply = new YearnSupplyAction(
'TOKEN_ADDRESS',
'100000000',
'FROM_ADDRESS',
'TO_ADDRESS'
);
- Instantiate Sequence object. Sequence will execute actions in the same order as passed to sequence constructor
const sequence = new Sequence([fluidSupply, yearnSupply], [0, 0, 0, 0], [0, 0, 0, 0]);
- Run
encodeSequence()
on Sequence object to get transaction payload
const sequencePayload = sequence.encodeSequence();