Skip to content

Commit

Permalink
new galgo distributor (#64)
Browse files Browse the repository at this point in the history
* new galgo distributor

* updated payouts go online fee
  • Loading branch information
gidonkatten authored Dec 24, 2024
1 parent 284356f commit 2f0e705
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-shrimps-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@folks-finance/algorand-sdk": patch
---

new galgo distributor
5 changes: 5 additions & 0 deletions src/algo-liquid-governance/v2/constants/mainnet-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const govDistributor13: Distributor = {
appId: 2330032485,
};

const govDistributor14: Distributor = {
appId: 2629511242,
};

export {
govDistributor7,
govDistributor8,
Expand All @@ -36,4 +40,5 @@ export {
govDistributor11,
govDistributor12,
govDistributor13,
govDistributor14,
};
18 changes: 16 additions & 2 deletions src/algo-liquid-governance/v2/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getAccountDetails,
getApplicationGlobalState,
getParsedValueFromState,
PAYOUTS_GO_ONLINE_FEE,
signer,
transferAlgoOrAsset,
} from "../../utils";
Expand Down Expand Up @@ -394,6 +395,7 @@ function prepareClaimPremintTransaction(
*
* @param distributor - distributor that has escrow
* @param senderAddr - account address for the sender
* @param registerFeeAmount - the register online transaction fee (to be used for consensus rewards)
* @param voteKey - vote key
* @param selectionKey - selection key
* @param stateProofKey - state proof key
Expand All @@ -406,6 +408,7 @@ function prepareClaimPremintTransaction(
function prepareRegisterEscrowOnlineTransaction(
distributor: Distributor,
senderAddr: string,
registerFeeAmount: number | bigint,
voteKey: Buffer,
selectionKey: Buffer,
stateProofKey: Buffer,
Expand All @@ -416,13 +419,23 @@ function prepareRegisterEscrowOnlineTransaction(
): Transaction {
const escrowAddr = getDistributorLogicSig(senderAddr).address();

// check register fee is either 0 ALGO or 0.2 ALGO
if (registerFeeAmount !== 0 && registerFeeAmount !== PAYOUTS_GO_ONLINE_FEE)
throw Error("Unexpected register fee amount");

const sendAlgo = {
txn: transferAlgoOrAsset(0, senderAddr, escrowAddr, registerFeeAmount, { ...params, flatFee: true, fee: 0 }),
signer,
};

const atc = new AtomicTransactionComposer();
atc.addMethodCall({
sender: senderAddr,
signer,
appID: distributor.appId,
method: getMethodByName(abiDistributor.methods, "register_online"),
methodArgs: [
sendAlgo,
escrowAddr,
encodeAddress(voteKey),
encodeAddress(selectionKey),
Expand All @@ -431,7 +444,7 @@ function prepareRegisterEscrowOnlineTransaction(
voteLastRound,
voteKeyDilution,
],
suggestedParams: { ...params, flatFee: true, fee: 2000 },
suggestedParams: { ...params, flatFee: true, fee: 3000 },
});
const txns = atc.buildGroup().map(({ txn }) => {
txn.group = undefined;
Expand Down Expand Up @@ -534,7 +547,8 @@ function prepareRemoveLiquidGovernanceEscrowTransactions(
appID: distributor.appId,
method: getMethodByName(abiDistributor.methods, "remove_escrow"),
methodArgs: [escrowAddr],
suggestedParams: { ...params, flatFee: true, fee: 4000 },
appAccounts: [ownerAddr],
suggestedParams: { ...params, flatFee: true, fee: 5000 },
});
const txns = atc.buildGroup().map(({ txn }) => {
txn.group = undefined;
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function unixTime(): number {
return Math.floor(Date.now() / 1000);
}

const PAYOUTS_GO_ONLINE_FEE = BigInt(2e6);

/**
* Wraps a call to Algorand client (algod/indexer) and returns global state
*/
Expand Down Expand Up @@ -253,6 +255,7 @@ export {
enc,
transferAlgoOrAsset,
signer,
PAYOUTS_GO_ONLINE_FEE,
unixTime,
getApplicationGlobalState,
getAccountApplicationLocalState,
Expand Down

0 comments on commit 2f0e705

Please sign in to comment.