Skip to content

Commit

Permalink
Choose airdrop community (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipzeta authored Apr 23, 2024
1 parent d468815 commit da27e5b
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zetamarkets/sdk",
"repository": "https://github.com/zetamarkets/sdk/",
"version": "1.28.1",
"version": "1.29.0",
"description": "Zeta SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
26 changes: 26 additions & 0 deletions src/cross-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,32 @@ export class CrossClient {
return txSig;
}

public async chooseAirdropCommunity(
community: types.AirdropCommunity
): Promise<TransactionSignature> {
this.delegatedCheck();
let tx = new Transaction();

tx.add(
instructions.chooseAirdropCommunityIx(
community,
this.accountManagerAddress,
this._provider.wallet.publicKey
)
);

return await utils.processTransaction(
this._provider,
tx,
undefined,
undefined,
undefined,
this._useVersionedTxs ? utils.getZetaLutArr() : undefined,
undefined,
this._txRetryAmount
);
}

public async editDelegatedPubkey(
delegatedPubkey: PublicKey
): Promise<TransactionSignature> {
Expand Down
32 changes: 31 additions & 1 deletion src/idl/zeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,27 @@
}
]
},
{
"name": "chooseAirdropCommunity",
"accounts": [
{
"name": "crossMarginAccountManager",
"isMut": true,
"isSigner": false
},
{
"name": "authority",
"isMut": false,
"isSigner": true
}
],
"args": [
{
"name": "community",
"type": "u8"
}
]
},
{
"name": "withdraw",
"accounts": [
Expand Down Expand Up @@ -8053,12 +8074,16 @@
"name": "referrer",
"type": "publicKey"
},
{
"name": "airdropCommunity",
"type": "u8"
},
{
"name": "padding",
"type": {
"array": [
"u8",
23
22
]
}
}
Expand Down Expand Up @@ -11278,6 +11303,11 @@
"code": 6170,
"name": "OrderPriceTooFarFromMarkPrice",
"msg": "Order price too far from mark price"
},
{
"code": 6171,
"name": "AirdropCommunityAlreadySet",
"msg": "Airdrop community already set, cannot set again"
}
]
}
13 changes: 13 additions & 0 deletions src/program-instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,19 @@ export function toggleMarketMakerIx(
});
}

export function chooseAirdropCommunityIx(
community: number,
accountManager: PublicKey,
authority: PublicKey
): TransactionInstruction {
return Exchange.program.instruction.chooseAirdropCommunity(community, {
accounts: {
crossMarginAccountManager: accountManager,
authority,
},
});
}

export function editDelegatedPubkeyIx(
delegatedPubkey: PublicKey,
account: PublicKey,
Expand Down
1 change: 1 addition & 0 deletions src/program-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export interface CrossMarginAccountManager {
authority: PublicKey;
accounts: Array<CrossMarginAccountInfo>;
referrer: PublicKey;
airdropCommunity: number;
padding: Array<number>;
}

Expand Down
13 changes: 13 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,16 @@ export interface PlaceMultiOrderArg {
tifOptions: TIFOptions;
clientOrderId?: number;
}


export enum AirdropCommunity {
UNASSIGNED = 0,
BACKPACK = 1,
JUP = 2,
PYTH = 3,
DEBRIDGE = 4,
SUPERTEAM = 5,
MADLADS = 6,
TENSORIANS = 7,
ASSETDASH = 8
}
64 changes: 62 additions & 2 deletions src/types/zeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,27 @@ export type Zeta = {
}
]
},
{
"name": "chooseAirdropCommunity",
"accounts": [
{
"name": "crossMarginAccountManager",
"isMut": true,
"isSigner": false
},
{
"name": "authority",
"isMut": false,
"isSigner": true
}
],
"args": [
{
"name": "community",
"type": "u8"
}
]
},
{
"name": "withdraw",
"accounts": [
Expand Down Expand Up @@ -8053,12 +8074,16 @@ export type Zeta = {
"name": "referrer",
"type": "publicKey"
},
{
"name": "airdropCommunity",
"type": "u8"
},
{
"name": "padding",
"type": {
"array": [
"u8",
23
22
]
}
}
Expand Down Expand Up @@ -11278,6 +11303,11 @@ export type Zeta = {
"code": 6170,
"name": "OrderPriceTooFarFromMarkPrice",
"msg": "Order price too far from mark price"
},
{
"code": 6171,
"name": "AirdropCommunityAlreadySet",
"msg": "Airdrop community already set, cannot set again"
}
]
};
Expand Down Expand Up @@ -13443,6 +13473,27 @@ export const IDL: Zeta = {
}
]
},
{
"name": "chooseAirdropCommunity",
"accounts": [
{
"name": "crossMarginAccountManager",
"isMut": true,
"isSigner": false
},
{
"name": "authority",
"isMut": false,
"isSigner": true
}
],
"args": [
{
"name": "community",
"type": "u8"
}
]
},
{
"name": "withdraw",
"accounts": [
Expand Down Expand Up @@ -19337,12 +19388,16 @@ export const IDL: Zeta = {
"name": "referrer",
"type": "publicKey"
},
{
"name": "airdropCommunity",
"type": "u8"
},
{
"name": "padding",
"type": {
"array": [
"u8",
23
22
]
}
}
Expand Down Expand Up @@ -22562,6 +22617,11 @@ export const IDL: Zeta = {
"code": 6170,
"name": "OrderPriceTooFarFromMarkPrice",
"msg": "Order price too far from mark price"
},
{
"code": 6171,
"name": "AirdropCommunityAlreadySet",
"msg": "Airdrop community already set, cannot set again"
}
]
};

0 comments on commit da27e5b

Please sign in to comment.