0.0.2 • Published 8 months ago

athenafi-ts-client v0.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

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.

  1. Get into root of AthenaFi Client project.
  2. Run npm run build
  3. Run npm link.
  4. Get into root of the project you want import AthenaFi Client to.
  5. Run npm link athenafi-ts-client.
  6. 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

  1. Instantiate Action object with right arguments
import { FluidSupplyAction } from 'athenafi-ts-client';

// ...

const fluidSupplyAction = new FluidSupplyAction(
  'TOKEN_ADDRESS',
  '1000000000',
  'FROM_ADDRESS',
  'TO_ADDRESS'
);
  1. Run encodeArgs() on the action object to get a string payload
const fluidSupplyPayload = fluidSupplyAction.encodeArgs();
  1. 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

  1. 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'
);
  1. 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]);
  1. Run encodeSequence() on Sequence object to get transaction payload
const sequencePayload = sequence.encodeSequence();
0.0.2

8 months ago

0.0.1

8 months ago